diff options
author | Dan Timoney <dt5972@att.com> | 2018-09-24 13:18:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-24 13:18:46 +0000 |
commit | d7cfc1a92a4a1a78f6b65e8be61352f2a05d9501 (patch) | |
tree | eeab9619d548b6380a63083e8a7b6f62b324169a /dblib/provider/src/test/java | |
parent | f029e358bf9318ac03ba1be27912f52d296feacd (diff) | |
parent | cdd9c11b89444735350eed52d412caf3f6d85c16 (diff) |
Merge "added test cases to TestDBResourceManager"
Diffstat (limited to 'dblib/provider/src/test/java')
-rw-r--r-- | dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java | 63 |
1 files changed, 39 insertions, 24 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 index dca07921b..8d7d34324 100644 --- 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 @@ -4,6 +4,7 @@ import static org.junit.Assert.*; import java.io.InputStream; import java.net.URL; +import java.sql.SQLException; import java.util.Properties; import org.junit.Before; @@ -14,42 +15,56 @@ import ch.vorburger.mariadb4j.DBConfigurationBuilder; public class TestDBResourceManager { - DbLibService dblibSvc; + DbLibService dblibSvc; + DBResourceManager dbm; - @Before - public void setUp() throws Exception { - URL propUrl = getClass().getResource("/dblib.properties"); + @Before + public void setUp() throws Exception { + URL propUrl = getClass().getResource("/dblib.properties"); - InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); + InputStream propStr = getClass().getResourceAsStream("/dblib.properties"); - Properties props = new Properties(); + Properties props = new Properties(); - props.load(propStr); + 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(); - // 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); + dbm = new DBResourceManager(props); + dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null); + dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null); - // 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")); + } + @Test + public void testForceRecovery() { + dbm.testForceRecovery(); + } - dblibSvc = new DBResourceManager(props); + @Test + public void testGetConnection() throws SQLException { + assertNotNull(dbm.getConnection()); + assertNotNull(dbm.getConnection("testUser", "testPaswd")); + } - dblibSvc.writeData("CREATE TABLE DBLIB_TEST (name varchar(20));", null, null); - dblibSvc.getData("SELECT * FROM DBLIB_TEST", null, null); + @Test + public void testCleanup() { + dbm.cleanUp(); - } + } - @Test - public void test() { - - - } + @Test + public void testGetLogWriter() throws SQLException { + assertNull(dbm.getLogWriter()); + } } |