aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
diff options
context:
space:
mode:
authorGaurav Agrawal <gaurav.agrawal@huawei.com>2017-09-27 16:13:04 +0530
committerGaurav Agrawal <gaurav.agrawal@huawei.com>2017-09-27 16:13:04 +0530
commitbebf6ea5839c87799602da01b166000f8b746b86 (patch)
tree23b1535e24058ff74ae4134b7a8d8b0f2442a120 /sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
parent3458e16a7f0c9b48337a295359cda65423dbd587 (diff)
Refinements to core
Changes includes: 1. Simplifying the test cases. 2. Critical Sonar issue fix for MdsalHelper 3. Critical sonar issue fix for SvcLogicServiceImpl 4. Use logger in-built formatting. https://sonar.onap.org/component_issues/index?id=org.onap.ccsdk.sli.core%3Accsdk-sli-core#resolved=false|severities=CRITICAL Change-Id: Ib85637fcd2351970f8d96bf6b855db05cf7d9834 Issue-Id: CCSDK-67 Signed-off-by: Gaurav Agrawal <gaurav.agrawal@huawei.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.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);
+ }
+ }
+ }
}