summaryrefslogtreecommitdiffstats
path: root/dblib/provider/src/test/java/org
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-10-03 08:17:38 -0400
committerDan Timoney <dtimoney@att.com>2017-10-03 08:17:38 -0400
commitd73d257d76fa8211113fa3ef1a4e4058e67f4f2c (patch)
treec7470982a3d0bab1b8babbd08187391aa2f1400e /dblib/provider/src/test/java/org
parentdd9e2cbc650434d7c0da1976f9eb1bfe161f721a (diff)
Add unit tests for dblib
Add unit test case for dblib/provider, using MariaDB4J as database. Change-Id: I18492595a9d54999c3d52b56ecfe33d0d2cae019 Issue-ID: CCSDK-106 Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'dblib/provider/src/test/java/org')
-rw-r--r--dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java
new file mode 100644
index 000000000..dca07921b
--- /dev/null
+++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java
@@ -0,0 +1,55 @@
+package org.onap.ccsdk.sli.core.dblib;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.vorburger.mariadb4j.DB;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+
+public class TestDBResourceManager {
+
+ DbLibService dblibSvc;
+
+ @Before
+ public void setUp() throws Exception {
+ URL propUrl = getClass().getResource("/dblib.properties");
+
+ InputStream propStr = getClass().getResourceAsStream("/dblib.properties");
+
+ 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"));
+
+
+ dblibSvc = new DBResourceManager(props);
+
+ dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null);
+ dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null);
+
+ }
+
+ @Test
+ public void test() {
+
+
+ }
+
+}