aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
diff options
context:
space:
mode:
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.java191
1 files changed, 78 insertions, 113 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
index 7af4c1c5..0912ee9f 100644
--- 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
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
@@ -103,117 +104,81 @@ public class ITCaseSvcLogicParser {
store.registerNodeType("save");
store.registerNodeType("update");
store.registerNodeType("break");
- }
-
- @Before
- public void setUp() throws Exception {
- LOG.info("before");
- }
-
- @After
- public void tearDown() throws Exception {
- LOG.info("after");
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- LOG.info("after class");
- }
-
- /**
- * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}.
- */
- @Test
- public void testParseValidXml() {
-
- try
- {
- 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()+"]");
- }
- }
- }
- }
- catch (SvcLogicParserException e)
- {
- fail("Parser error : "+e.getMessage());
- }
- catch (Exception e)
- {
- LOG.error("", e);
- fail("Caught exception processing test cases");
- }
- }
-
- @Test
- public void testParseInvalidXml() {
-
- try
- {
- InputStream testStr = getClass().getResourceAsStream("/parser-bad.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);
- }
-
- 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)
- {
- LOG.error("", e);
- fail("Caught exception processing test cases");
- }
-
- }
-
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ LOG.info("after class");
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ LOG.info("before");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ LOG.info("after");
+ }
+
+ /**
+ * Test method for {@link org.onap.ccsdk.sli.core.sli.SvcLogicParser#parse(java.lang.String)}.
+ */
+ @Test
+ public void testParseValidXml() {
+
+ try {
+ 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() + "]");
+ }
+ }
+ }
+ } catch (SvcLogicParserException e) {
+ fail("Parser error : " + e.getMessage());
+ } catch (Exception e) {
+ LOG.error("", e);
+ fail("Caught exception processing test cases");
+ }
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testParseInvalidXml() throws SvcLogicException, IOException {
+
+ InputStream testStr = getClass().getResourceAsStream("/parser-bad.tests");
+ BufferedReader testsReader = new BufferedReader(new InputStreamReader(testStr));
+ String testCaseFile;
+ 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);
+ }
+ SvcLogicParser.load(testCaseUrl.getPath(), store);
+ }
+ }
+ }
}