aboutsummaryrefslogtreecommitdiffstats
path: root/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-09-13 16:32:45 -0400
committerDan Timoney <dtimoney@att.com>2017-09-13 16:32:45 -0400
commit3fa9671f720dd95bf15a5a4668aa89a7c3dd93e7 (patch)
treea05c9b61c7f3629571c5f9c4f8e4866ab6302565 /sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java
parentd315e6996052dc81c7e5deebd7fc4229a4e93c0c (diff)
Use oparent-odlparent in sli/core
Update sli/core to use oparent-odlparent. To prevent verify builds from failing due to unit test errors, also changed unit tests that require database access to use MariaDB4j to start up a local MariaDB database. Change-Id: I928b7e1e83bdb328ca9e0785c8b81f67f982eeda Issue-ID: CCSDK-43 Signed-off-by: Dan Timoney <dtimoney@att.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.java78
1 files changed, 51 insertions, 27 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 0e6000fb..07f40a2e 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
@@ -8,9 +8,9 @@
* 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.
@@ -20,7 +20,7 @@
*/
/**
- *
+ *
*/
package org.onap.ccsdk.sli.core.sli;
@@ -28,7 +28,10 @@ import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.util.Properties;
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import junit.framework.TestCase;
/**
@@ -40,22 +43,43 @@ 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);
-
+
+ Properties props = new Properties();
+
+ props.load(propStr);
+
+
+ // Start MariaDB4j database
+ DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
+ config.setPort(0); // 0 => autom. detect free port
+ DB db = DB.newEmbeddedDB(config.build());
+ db.start();
+
+
+
+ // Override jdbc URL and database name
+ props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
+ props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
+
+
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(props);
+
assertNotNull(store);
-
+
store.registerNodeType("switch");
store.registerNodeType("block");
store.registerNodeType("get-resource");
@@ -69,15 +93,15 @@ public class ITCaseSvcLogicParser extends TestCase {
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("/"))
@@ -94,23 +118,23 @@ public class ITCaseSvcLogicParser extends TestCase {
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("/"))
@@ -134,7 +158,7 @@ public class ITCaseSvcLogicParser extends TestCase {
if (valid) {
fail("Expected compiler error on "+testCaseFile+", but got success");
}
-
+
}
}
@@ -148,10 +172,10 @@ public class ITCaseSvcLogicParser extends TestCase {
e.printStackTrace();
fail("Caught exception processing test cases");
}
-
-
+
+
}
-
-
+
+
}