summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-07 10:33:35 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-07 18:35:37 +0000
commit252c513f9d3278390303cc528b4be02e73e961ce (patch)
tree0ea66c857fb7c8439e3abb99550ef9b874715e19 /appc-dispatcher
parent6a470e0ca7b88d529ef14540f0df307c83cbe0ba (diff)
Coverage in lock-manager
Increased package coverage to 93% Issue-ID: APPC-1400 Change-Id: I4ff2a02466fc7a178c4d411ca4647b1c3877b405 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-dispatcher')
-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();
+ }
+
+}