Merge "added test cases to CheckParametersTest"
diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
index 6385c1b..c463f38 100644
--- a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
+++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/CachedDataSourceTest.java
@@ -1,6 +1,9 @@
 package org.onap.ccsdk.sli.core.dblib;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.Properties;
@@ -14,81 +17,81 @@
 
 public class CachedDataSourceTest {
 
-    private static final Properties props = new Properties();
+	private static final Properties props = new Properties();
+	private static BaseDBConfiguration config;
+	private static CachedDataSource ds;
 
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-        props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10");
-        props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20");
-        props.setProperty("org.onap.dblib.connection.recovery", "false");
-    }
+	@BeforeClass
+	public static void setUpBeforeClass() throws Exception {
+		props.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.hosts", "localhost");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.url", "jdbc:mysql://dbhost:3306/test");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.user", "dbuser");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.password", "passw0rd");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.connection.name", "testdb01");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.connection.timeout", "50");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.request.timeout", "100");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.limit.init", "10");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.limit.min", "10");
+		props.setProperty("org.onap.ccsdk.sli.jdbc.limit.max", "20");
+		props.setProperty("org.onap.dblib.connection.recovery", "false");
 
-    @Test
-    public void testCachedDataSource() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        assertNotNull(ds);
-    }
+		config = new JDBCConfiguration(props);
+		ds = new JdbcDBCachedDataSource(config);
+	}
 
-    @Test
-    public void testConfigure() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
+	@Test
+	public void testCachedDataSource() {
+		assertNotNull(ds);
+	}
 
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        assertNotNull(ds.configure(config));
-    }
+	@Test
+	public void testConfigure() {
 
-    @Test
-    public void testSetInitialDelay() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        ds.setInitialDelay(1000L);
-        assertTrue(ds.getInitialDelay() == 1000L);
-    }
+		assertNotNull(ds.configure(config));
+	}
 
-    @Test
-    public void testSetInterval() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        ds.setInterval(1000L);
-        assertTrue(ds.getInterval() == 1000L);
-    }
+	@Test
+	public void testSetInitialDelay() {
+		ds.setInitialDelay(1000L);
+		assertTrue(ds.getInitialDelay() == 1000L);
+	}
 
-    @Test
-    public void testSetExpectedCompletionTime() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        ds.setExpectedCompletionTime(100L);
-        assertTrue(ds.getExpectedCompletionTime() == 100L);
-    }
+	@Test
+	public void testSetInterval() {
+		ds.setInterval(1000L);
+		assertTrue(ds.getInterval() == 1000L);
+	}
 
-    @Test
-    public void testSetUnprocessedFailoverThreshold() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        ds.setUnprocessedFailoverThreshold(100L);
-        assertTrue(ds.getUnprocessedFailoverThreshold() == 100L);
-    }
+	@Test
+	public void testSetExpectedCompletionTime() {
+		ds.setExpectedCompletionTime(100L);
+		assertTrue(ds.getExpectedCompletionTime() == 100L);
+	}
 
-    @Test
-    public void testGetParentLogger() {
-        BaseDBConfiguration config = new JDBCConfiguration(props);
-        CachedDataSource ds = new JdbcDBCachedDataSource(config);
-        try {
-            assertNull(ds.getParentLogger());
-        } catch (SQLFeatureNotSupportedException e) {
-            LoggerFactory.getLogger(CachedDataSourceTest.class).warn("Test Failure", e);
-        }
-    }
+	@Test
+	public void testSetUnprocessedFailoverThreshold() {
+		ds.setUnprocessedFailoverThreshold(100L);
+		assertTrue(ds.getUnprocessedFailoverThreshold() == 100L);
+	}
+
+	@Test
+	public void testGetParentLogger() {
+		try {
+			assertNull(ds.getParentLogger());
+		} catch (SQLFeatureNotSupportedException e) {
+			LoggerFactory.getLogger(CachedDataSourceTest.class).warn("Test Failure", e);
+		}
+	}
+
+	@Test
+	public void testGettersForJdbcDBCachedDataSource() {
+
+		assertEquals("jdbc:mysql://dbhost:3306/test", ((JdbcDBCachedDataSource) ds).getDbUrl());
+		assertEquals("dbuser", ((JdbcDBCachedDataSource) ds).getDbUserId());
+		assertEquals("passw0rd", ((JdbcDBCachedDataSource) ds).getDbPasswd());
+		assertEquals("testdb01", ((JdbcDBCachedDataSource) ds).toString());
+	}
 }
\ No newline at end of file
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 dca0792..8d7d343 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 java.io.InputStream;
 import java.net.URL;
+import java.sql.SQLException;
 import java.util.Properties;
 
 import org.junit.Before;
@@ -14,42 +15,56 @@
 
 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());
+    }
 
 }