aboutsummaryrefslogtreecommitdiffstats
path: root/dblib
diff options
context:
space:
mode:
authorSandeep J <sandeejh@in.ibm.com>2018-09-24 01:28:16 +0530
committerSandeep J <sandeejh@in.ibm.com>2018-09-24 01:28:23 +0530
commitcdd9c11b89444735350eed52d412caf3f6d85c16 (patch)
tree5e6d1247d7facb4667c23fd2e82f8df0a02562ef /dblib
parent9e8138f54edbf4cc8a0309f9e149953e08d3280e (diff)
added test cases to TestDBResourceManager
to increase code coverage Issue-ID: CCSDK-595 Change-Id: I8def1aa2e4108f48bc549e63e533f8a63e7a0377 Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
Diffstat (limited to 'dblib')
-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());
+ }
}