aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java50
-rw-r--r--appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java44
2 files changed, 94 insertions, 0 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java
new file mode 100644
index 000000000..919a13c94
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/JdbcLockManagerTest.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.lockmanager.impl.sql;
+
+import java.sql.Connection;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.appc.dao.util.api.JdbcConnectionFactory;
+import org.onap.appc.lockmanager.impl.sql.optimistic.MySqlLockManager;
+
+public class JdbcLockManagerTest {
+
+ @Test
+ public void testOpenDbConnection() {
+ JdbcLockManager manager = new MySqlLockManager();
+ JdbcConnectionFactory connectionFactory = Mockito.mock(JdbcConnectionFactory.class);
+ manager.setConnectionFactory(connectionFactory);
+ manager.openDbConnection();
+ Mockito.verify(connectionFactory).openDbConnection();
+ }
+
+ @Test
+ public void testCloseDbConnection() {
+ JdbcLockManager manager = new MySqlLockManager();
+ JdbcConnectionFactory connectionFactory = Mockito.mock(JdbcConnectionFactory.class);
+ manager.setConnectionFactory(connectionFactory);
+ Connection connection = Mockito.mock(Connection.class);
+ manager.closeDbConnection(connection);
+ Mockito.verify(connectionFactory).closeDbConnection(connection);
+ }
+}
diff --git a/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java
new file mode 100644
index 000000000..cf96a5748
--- /dev/null
+++ b/appc-dispatcher/appc-dispatcher-common/lock-manager-lib/lock-manager-impl/src/test/java/org/onap/appc/lockmanager/impl/sql/MySqlConnectionFactoryTest.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.lockmanager.impl.sql;
+
+import java.sql.SQLException;
+import java.sql.DriverManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(DriverManager.class)
+public class MySqlConnectionFactoryTest {
+
+ @Test
+ public void testRegisterDriver() throws SQLException {
+ PowerMockito.mockStatic(DriverManager.class);
+ MySqlConnectionFactory factory = new MySqlConnectionFactory();
+ factory.registedDriver();
+ PowerMockito.verifyStatic();
+ }
+
+}