summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/TestDBResourceManager.java63
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 dca07921..8d7d3432 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());
+ }
}