aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2017-08-28 13:48:06 -0700
committerMarcus G K Williams <marcus.williams@intel.com>2017-08-28 13:51:56 -0700
commit6f3bb14fde75d785164c6ef3501b029c9bd145e9 (patch)
treee73f48443707cee1de313a03fae7ee416012ee90 /sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
parent1f2c69e5faab3b5007c45033df0097b3616f4d2f (diff)
Change 2 sli/core unit tests to int. tests
Change SvcLogicGraphExecutorTest and SvcLogicParserTest to IT Tests because they require outside dependencies (sql database). This change enables running jobs without skipping tests and futher enables SONAR scans of unit tests. Issue-Id: CCSDK-67 Change-Id: I74184b2f2d8cb5fcc7b065c3e2e859b85dd1630b Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java')
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java163
1 files changed, 163 insertions, 0 deletions
diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
new file mode 100644
index 00000000..ec18b876
--- /dev/null
+++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ *
+ */
+package org.onap.ccsdk.sli.core.sli;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.LinkedList;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
+import org.onap.ccsdk.sli.core.sli.SvcLogicParserException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * @author dt5972
+ *
+ */
+public class ITCaseSvcLogicParser extends TestCase {
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}.
+ */
+
+
+ public void testParse() {
+
+
+ try
+ {
+
+ URL propUrl = getClass().getResource("/svclogic.properties");
+
+ InputStream propStr = getClass().getResourceAsStream("/svclogic.properties");
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propStr);
+
+ assertNotNull(store);
+
+ store.registerNodeType("switch");
+ store.registerNodeType("block");
+ store.registerNodeType("get-resource");
+ store.registerNodeType("reserve");
+ store.registerNodeType("is-available");
+ store.registerNodeType("exists");
+ store.registerNodeType("configure");
+ store.registerNodeType("return");
+ store.registerNodeType("record");
+ store.registerNodeType("allocate");
+ store.registerNodeType("release");
+ store.registerNodeType("for");
+ store.registerNodeType("set");
+
+
+ InputStream testStr = getClass().getResourceAsStream("/parser-good.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+ String testCaseFile = null;
+ while ((testCaseFile = testsReader.readLine()) != null) {
+
+ testCaseFile = testCaseFile.trim();
+
+ if (testCaseFile.length() > 0)
+ {
+ if (!testCaseFile.startsWith("/"))
+ {
+ testCaseFile = "/"+testCaseFile;
+ }
+ URL testCaseUrl = getClass().getResource(testCaseFile);
+ if (testCaseUrl == null)
+ {
+ fail("Could not resolve test case file "+testCaseFile);
+ }
+
+ try {
+ SvcLogicParser.validate(testCaseUrl.getPath(), store);
+ } catch (Exception e) {
+ fail("Validation failure ["+e.getMessage()+"]");
+
+ }
+
+
+
+
+
+ }
+ }
+
+ testStr = getClass().getResourceAsStream("/parser-bad.tests");
+ testsReader = new BufferedReader(new InputStreamReader(testStr));
+ testCaseFile = null;
+ while ((testCaseFile = testsReader.readLine()) != null) {
+
+ testCaseFile = testCaseFile.trim();
+
+ if (testCaseFile.length() > 0)
+ {
+ if (!testCaseFile.startsWith("/"))
+ {
+ testCaseFile = "/"+testCaseFile;
+ }
+ URL testCaseUrl = getClass().getResource(testCaseFile);
+ if (testCaseUrl == null)
+ {
+ fail("Could not resolve test case file "+testCaseFile);
+ }
+
+ boolean valid = true;
+ try {
+ SvcLogicParser.load(testCaseUrl.getPath(), store);
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ valid = false;
+ }
+
+ if (valid) {
+ fail("Expected compiler error on "+testCaseFile+", but got success");
+ }
+
+
+ }
+ }
+ }
+ catch (SvcLogicParserException e)
+ {
+ fail("Parser error : "+e.getMessage());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Caught exception processing test cases");
+ }
+
+
+ }
+
+
+
+}