aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src/test/java/org
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2019-10-21 13:04:29 +0100
committerefiacor <fiachra.corcoran@est.tech>2019-10-21 15:01:24 +0100
commit68a9ca240970fceaf12bbe91b7bad8e1d98ecd93 (patch)
tree458de89da302f827442b5d0c6f21dd1751939951 /datarouter-prov/src/test/java/org
parentf3b3e701a48d529ee6dc88e3a867448498e23d36 (diff)
Refactor Prov DB handling
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: I8610d3a20ca0c11dafb98b161cbeb06c3ff63be6 Issue-ID: DMAAP-1284
Diffstat (limited to 'datarouter-prov/src/test/java/org')
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthTest.java4
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java2
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java52
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java5
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java63
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java9
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java1
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/LogServletTest.java26
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/ProxyServletTest.java1
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/PublishServletTest.java7
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java10
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java20
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java36
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTaskTest.java1
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java11
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java48
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java53
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java2
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java38
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java21
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java3
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java4
22 files changed, 212 insertions, 205 deletions
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthTest.java
index 7de4ea91..172df821 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/authz/impl/ProvAuthTest.java
@@ -35,9 +35,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
-import org.onap.dmaap.datarouter.authz.impl.ProvAuthorizer;
import org.onap.dmaap.datarouter.provisioning.StatisticsServlet;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@@ -53,7 +51,6 @@ public class ProvAuthTest {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@BeforeClass
public static void init() {
@@ -73,7 +70,6 @@ public class ProvAuthTest {
@Before
public void setUp() throws Exception {
- db = new DB();
provAuthorizer = new ProvAuthorizer(statisticsServlet);
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
index ca84e6d5..0013077d 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
@@ -26,8 +26,6 @@ package org.onap.dmaap.datarouter.provisioning;
import java.security.NoSuchAlgorithmException;
import javax.crypto.SecretKeyFactory;
import org.apache.commons.lang3.reflect.FieldUtils;
-import org.jetbrains.annotations.NotNull;
-import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Before;
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
index d014629d..06f488c0 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
@@ -22,8 +22,25 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.contains;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
+
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
@@ -37,22 +54,9 @@ import org.mockito.Mock;
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.authz.Authorizer;
import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
import org.powermock.modules.junit4.PowerMockRunner;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.*;
-import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
-
@RunWith(PowerMockRunner.class)
public class DRFeedsServletTest extends DrServletTestBase {
@@ -60,7 +64,6 @@ public class DRFeedsServletTest extends DrServletTestBase {
private static DRFeedsServlet drfeedsServlet;
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@Mock
private HttpServletRequest request;
@@ -89,7 +92,6 @@ public class DRFeedsServletTest extends DrServletTestBase {
public void setUp() throws Exception {
listAppender = setTestLogger(DRFeedsServlet.class);
drfeedsServlet = new DRFeedsServlet();
- db = new DB();
setAuthoriserToReturnRequestIsAuthorized();
setPokerToNotCreateTimersWhenDeleteFeedIsCalled();
setupValidAuthorisedRequest();
@@ -224,7 +226,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
when(request.getHeader(DRFeedsServlet.EXCLUDE_AAF_HEADER)).thenReturn("true");
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -245,7 +247,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
when(request.getHeader(DRFeedsServlet.EXCLUDE_AAF_HEADER)).thenReturn("true");
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -264,7 +266,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isCadiEnabled", "true", true);
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -283,7 +285,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isCadiEnabled", "true", true);
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -305,7 +307,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
JSONObject JSObject = buildRequestJsonObject();
when(request.isUserInRole("org.onap.dmaap-dr.feed|*|create")).thenReturn(true);
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -336,7 +338,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
throws Exception {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxFeeds", 0, true);
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
return new JSONObject();
}
};
@@ -348,7 +350,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_POST_And_Feed_Is_Not_Valid_Object_Bad_Request_Response_Is_Generated()
throws Exception {
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
return new JSONObject();
}
};
@@ -366,7 +368,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
when(request.isUserInRole("org.onap.dmaap-dr.feed|*|create")).thenReturn(true);
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -384,7 +386,7 @@ public class DRFeedsServletTest extends DrServletTestBase {
JSONObject JSObject = buildRequestJsonObject();
when(request.getHeader(DRFeedsServlet.EXCLUDE_AAF_HEADER)).thenReturn("true");
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java
index 42366dd0..03f5df1b 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DrServletTestBase.java
@@ -26,10 +26,11 @@ package org.onap.dmaap.datarouter.provisioning;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
+import java.lang.reflect.Field;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.junit.After;
import org.junit.Before;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.SynchronizerTask;
import org.slf4j.LoggerFactory;
import java.util.Properties;
@@ -48,7 +49,7 @@ public class DrServletTestBase {
props.setProperty("org.onap.dmaap.datarouter.provserver.spooldir", "unit-test-logs/spool");
props.setProperty("org.onap.dmaap.datarouter.provserver.https.relaxation", "false");
props.setProperty("org.onap.dmaap.datarouter.provserver.passwordencryption", "PasswordEncryptionKey#@$%^&1234#");
- FieldUtils.writeDeclaredStaticField(DB.class, "props", props, true);
+ FieldUtils.writeDeclaredStaticField(ProvRunner.class, "provProperties", props, true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "startmsgFlag", false, true);
SynchronizerTask synchronizerTask = mock(SynchronizerTask.class);
when(synchronizerTask.getPodState()).thenReturn(SynchronizerTask.UNKNOWN_POD);
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
index a1f714bb..c5e3e150 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
@@ -22,8 +22,28 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.contains;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
+
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
@@ -38,24 +58,9 @@ import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.authz.Authorizer;
import org.onap.dmaap.datarouter.provisioning.beans.Feed;
import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.modules.junit4.PowerMockRunner;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.*;
-import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
-
@RunWith(PowerMockRunner.class)
public class FeedServletTest extends DrServletTestBase {
@@ -69,7 +74,6 @@ public class FeedServletTest extends DrServletTestBase {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
private ListAppender<ILoggingEvent> listAppender;
@@ -93,7 +97,6 @@ public class FeedServletTest extends DrServletTestBase {
public void setUp() throws Exception {
listAppender = setTestLogger(FeedServlet.class);
feedServlet = new FeedServlet();
- db = new DB();
setAuthoriserToReturnRequestIsAuthorized();
setUpValidAuthorisedRequest();
setUpValidSecurityOnHttpRequest();
@@ -277,7 +280,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getInputStream()).thenReturn(inStream);
when(request.getPathInfo()).thenReturn("/2");
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
return null;
}
};
@@ -289,7 +292,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Request_Contains_Invalid_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn("/2");
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
return new JSONObject();
}
};
@@ -303,7 +306,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "1.0");
@@ -320,7 +323,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "not_stub_name");
jo.put("version", "1.0");
@@ -337,7 +340,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.2");
@@ -355,7 +358,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -372,7 +375,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -393,7 +396,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.isUserInRole("org.onap.dmaap-dr.feed|*|edit")).thenReturn(true);
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -419,7 +422,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -443,7 +446,7 @@ public class FeedServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
FeedServlet feedServlet = new FeedServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "AafFeed");
jo.put("version", "v0.1");
@@ -534,6 +537,8 @@ public class FeedServletTest extends DrServletTestBase {
feed.setFeedid(1);
feed.setGroupid(1);
feed.setDeleted(false);
- feed.doUpdate(db.getConnection());
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ feed.doUpdate(conn);
+ }
}
} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
index a0781264..67687d08 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
@@ -34,6 +34,7 @@ import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.authz.Authorizer;
import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
import org.powermock.modules.junit4.PowerMockRunner;
import javax.persistence.EntityManager;
@@ -294,7 +295,7 @@ public class GroupServletTest {
private GroupServlet overideGetJSONFromInputToReturnAnInvalidGroup(Boolean invalidName) {
GroupServlet groupServlet = new GroupServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject invalidGroup = new JSONObject();
String invalidEntry = "groupNameThatIsTooLongTooBeValidgroupNameThatIsTooLongTooBeValid";
invalidEntry = invalidEntry + invalidEntry + invalidEntry + invalidEntry + invalidEntry;
@@ -317,7 +318,7 @@ public class GroupServletTest {
private GroupServlet overideGetJSONFromInputToReturnAValidGroupWithFail() {
GroupServlet groupServlet = new GroupServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject validGroup = new JSONObject();
validGroup.put("name", "groupName");
validGroup.put("groupid", 2);
@@ -341,7 +342,7 @@ public class GroupServletTest {
private GroupServlet overideGetJSONFromInputToReturnGroupInDb() {
GroupServlet groupServlet = new GroupServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject validGroup = new JSONObject();
validGroup.put("name", "Group1");
validGroup.put("groupid", 2);
@@ -357,7 +358,7 @@ public class GroupServletTest {
private GroupServlet overideGetJSONFromInputToReturnNewGroupToInsert() {
GroupServlet groupServlet = new GroupServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject validGroup = new JSONObject();
validGroup.put("name", "Group2");
validGroup.put("groupid", 2);
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
index 5239b800..51531669 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
@@ -57,6 +57,7 @@ import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
import org.onap.dmaap.datarouter.provisioning.beans.LogRecord;
import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/LogServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/LogServletTest.java
index c2bccb71..a52f1a0b 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/LogServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/LogServletTest.java
@@ -60,9 +60,9 @@ public class LogServletTest extends DrServletTestBase {
private HttpServletResponse response;
@Mock
- private ServletOutputStream s;
+ private ServletOutputStream servletOutputStream;
- ListAppender<ILoggingEvent> listAppender;
+ private ListAppender<ILoggingEvent> listAppender;
@BeforeClass
public static void init() {
@@ -153,8 +153,7 @@ public class LogServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_GET_And_Is_FeedLog_A_STATUS_OK_Response_Is_Generated()
- throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_Is_FeedLog_A_STATUS_OK_Response_Is_Generated() {
logServlet.doGet(request, response);
verify(response).setStatus(eq(HttpServletResponse.SC_OK));
verifyEnteringExitCalled(listAppender);
@@ -177,8 +176,7 @@ public class LogServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_GetPublishRecordsForFeed_And_Type_Is_Publish_A_STATUS_OK_Response_Is_Generated()
- throws Exception {
+ public void Given_Request_Is_GetPublishRecordsForFeed_And_Type_Is_Publish_A_STATUS_OK_Response_Is_Generated() {
when(request.getParameter("type")).thenReturn("pub");
when(request.getParameter("expiryReason")).thenReturn(null);
logServlet.doGet(request, response);
@@ -196,9 +194,9 @@ public class LogServletTest extends DrServletTestBase {
when(request.getParameter("filename")).thenReturn("file123");
logServlet.doGet(request, response);
verify(response).setStatus(eq(HttpServletResponse.SC_OK));
- verify(s, times(1)).print("[");
- verify(s, times(1)).print(matches("\n\\{\"statusCode\":204,\"publishId\":\"ID\",\"requestURI\":\"URL/file123\",\"sourceIP\":\"172.0.0.8\",\"method\":\"PUT\",\"contentType\":\"application/vnd.dmaap-dr.log-list; version=1.0\",\"endpointId\":\"user\",\"type\":\"pub\",\"date\":\"2050-05-14T1[6-7]:46:04.422Z\",\"contentLength\":100,\"fileName\":\"file123\"}"));
- verify(s, times(1)).print("[");
+ verify(servletOutputStream, times(1)).print("[");
+ verify(servletOutputStream, times(1)).print(matches("\n\\{\"statusCode\":204,\"publishId\":\"ID\",\"requestURI\":\"URL/file123\",\"sourceIP\":\"172.0.0.8\",\"method\":\"PUT\",\"contentType\":\"application/vnd.dmaap-dr.log-list; version=1.0\",\"endpointId\":\"user\",\"type\":\"pub\",\"date\":\"2050-05-14T1[6-7]:46:04.422Z\",\"contentLength\":100,\"fileName\":\"file123\"}"));
+ verify(servletOutputStream, times(1)).print("[");
}
@Test
@@ -212,9 +210,9 @@ public class LogServletTest extends DrServletTestBase {
when(request.getParameter("filename")).thenReturn("file456");
logServlet.doGet(request, response);
verify(response).setStatus(eq(HttpServletResponse.SC_OK));
- verify(s, times(1)).print("[");
- verify(s, times(0)).print(matches("\n\\{\"statusCode\":204,\"publishId\":\"ID\",\"requestURI\":\"URL/file123\",\"sourceIP\":\"172.0.0.8\",\"method\":\"PUT\",\"contentType\":\"application/vnd.dmaap-dr.log-list; version=1.0\",\"endpointId\":\"user\",\"type\":\"pub\",\"date\":\"2050-05-14T1[6-7]:46:04.422Z\",\"contentLength\":100,\"fileName\":\"file123\"}"));
- verify(s, times(1)).print("[");
+ verify(servletOutputStream, times(1)).print("[");
+ verify(servletOutputStream, times(0)).print(matches("\n\\{\"statusCode\":204,\"publishId\":\"ID\",\"requestURI\":\"URL/file123\",\"sourceIP\":\"172.0.0.8\",\"method\":\"PUT\",\"contentType\":\"application/vnd.dmaap-dr.log-list; version=1.0\",\"endpointId\":\"user\",\"type\":\"pub\",\"date\":\"2050-05-14T1[6-7]:46:04.422Z\",\"contentLength\":100,\"fileName\":\"file123\"}"));
+ verify(servletOutputStream, times(1)).print("[");
}
@Test
@@ -268,7 +266,7 @@ public class LogServletTest extends DrServletTestBase {
when(request.getParameter("expiryReason")).thenReturn("other");
when(request.getParameter("start")).thenReturn("2536159564422");
when(request.getParameter("end")).thenReturn("2536159564422");
- s = mock(ServletOutputStream.class);
- when(response.getOutputStream()).thenReturn(s);
+ servletOutputStream = mock(ServletOutputStream.class);
+ when(response.getOutputStream()).thenReturn(servletOutputStream);
}
} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/ProxyServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/ProxyServletTest.java
index a0442c13..80fcb0e7 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/ProxyServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/ProxyServletTest.java
@@ -53,6 +53,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.onap.dmaap.datarouter.provisioning.utils.SynchronizerTask;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/PublishServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/PublishServletTest.java
index 2202550b..e1a11f3e 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/PublishServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/PublishServletTest.java
@@ -29,7 +29,7 @@ import org.apache.commons.lang3.reflect.FieldUtils;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -67,9 +67,8 @@ public class PublishServletTest extends DrServletTestBase {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
- ListAppender<ILoggingEvent> listAppender;
+ private ListAppender<ILoggingEvent> listAppender;
@BeforeClass
public static void init() {
@@ -92,7 +91,7 @@ public class PublishServletTest extends DrServletTestBase {
public void setUp() throws Exception {
listAppender = setTestLogger(PublishServlet.class);
publishServlet = new PublishServlet();
- db = new DB();
+ ProvDbUtils.getInstance().initProvDB();
}
@Test
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
index 3438627d..f9fcd687 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/StatisticsServletTest.java
@@ -35,21 +35,14 @@ import javax.persistence.Persistence;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-
@RunWith(PowerMockRunner.class)
public class StatisticsServletTest {
@@ -61,8 +54,6 @@ public class StatisticsServletTest {
@Mock
private HttpServletResponse response;
- private DB db;
-
private static EntityManagerFactory emf;
private static EntityManager em;
@@ -85,7 +76,6 @@ public class StatisticsServletTest {
@Before
public void setUp() throws Exception {
statisticsServlet = new StatisticsServlet();
- db = new DB();
buildRequestParameters();
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
index 57007489..979c2c4a 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
@@ -53,7 +53,8 @@ import org.mockito.Mock;
import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
import org.onap.dmaap.datarouter.authz.Authorizer;
import org.onap.dmaap.datarouter.provisioning.beans.Insertable;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -62,7 +63,6 @@ public class SubscribeServletTest extends DrServletTestBase {
private static SubscribeServlet subscribeServlet;
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@Mock
private HttpServletRequest request;
@@ -89,7 +89,7 @@ public class SubscribeServletTest extends DrServletTestBase {
@Before
public void setUp() throws Exception {
- db = new DB();
+ ProvDbUtils.getInstance().initProvDB();
listAppender = setTestLogger(SubscribeServlet.class);
subscribeServlet = new SubscribeServlet();
setAuthoriserToReturnRequestIsAuthorized();
@@ -192,7 +192,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/1");
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -216,7 +216,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/1");
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -243,7 +243,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -265,7 +265,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -290,7 +290,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.isUserInRole("org.onap.dmaap-dr.feed|*|approveSub")).thenReturn(true);
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -334,7 +334,7 @@ public class SubscribeServletTest extends DrServletTestBase {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxSubs", 0, true);
when(request.getPathInfo()).thenReturn("/1");
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
return new JSONObject();
}
};
@@ -347,7 +347,7 @@ public class SubscribeServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/2");
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
index 4a410ddd..cb0fa2bf 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
@@ -24,6 +24,7 @@ package org.onap.dmaap.datarouter.provisioning;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
+import java.sql.Connection;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;
@@ -39,8 +40,9 @@ import org.onap.dmaap.datarouter.provisioning.beans.Deleteable;
import org.onap.dmaap.datarouter.provisioning.beans.SubDelivery;
import org.onap.dmaap.datarouter.provisioning.beans.Subscription;
import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.PasswordProcessor;
+import org.onap.dmaap.datarouter.provisioning.utils.Poker;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -67,7 +69,6 @@ public class SubscriptionServletTest extends DrServletTestBase {
private static EntityManagerFactory emf;
private static EntityManager em;
private SubscriptionServlet subscriptionServlet;
- private DB db;
private final String URL= "https://172.100.0.5";
private final String USER = "user1";
private final String PASSWORD="password1";
@@ -100,7 +101,6 @@ public class SubscriptionServletTest extends DrServletTestBase {
public void setUp() throws Exception {
listAppender = setTestLogger(SubscriptionServlet.class);
subscriptionServlet = new SubscriptionServlet();
- db = new DB();
setAuthoriserToReturnRequestIsAuthorized();
setPokerToNotCreateTimersWhenDeleteSubscriptionIsCalled();
setupValidAuthorisedRequest();
@@ -253,7 +253,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription; version=1.0");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -278,7 +278,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getPathInfo()).thenReturn("/3");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -307,7 +307,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
PowerMockito.mockStatic(PasswordProcessor.class);
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -347,7 +347,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Subscription_Object_Is_Invalid_Bad_Request_Response_Is_Generated() throws Exception {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription; version=1.0");
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
return jo;
}
@@ -362,7 +362,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription; version=1.0");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -388,7 +388,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription; version=1.0");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -421,7 +421,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
PowerMockito.mockStatic(PasswordProcessor.class);
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -502,7 +502,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription-control; version=1.0");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -524,7 +524,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.dmaap-dr.subscription-control; version=1.0");
JSONObject JSObject = buildRequestJsonObject();
SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
- protected JSONObject getJSONfromInput(HttpServletRequest req) {
+ public JSONObject getJSONfromInput(HttpServletRequest req) {
JSONObject jo = new JSONObject();
jo.put("name", "stub_name");
jo.put("version", "2.0");
@@ -610,7 +610,9 @@ public class SubscriptionServletTest extends DrServletTestBase {
subscription.setPrivilegedSubscriber(false);
subscription.setDecompress(false);
subscription.changeOwnerShip();
- subscription.doUpdate(db.getConnection());
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ subscription.doUpdate(conn);
+ }
}
private void resetAafSubscriptionInDB() throws SQLException {
@@ -626,7 +628,9 @@ public class SubscriptionServletTest extends DrServletTestBase {
subscription.setAafInstance("https://aaf-onap-test.osaaf.org:8095");
subscription.setDecompress(false);
subscription.setPrivilegedSubscriber(false);
- subscription.doUpdate(db.getConnection());
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ subscription.doUpdate(conn);
+ }
}
private void addNewSubscriptionInDB() throws SQLException {
@@ -640,6 +644,8 @@ public class SubscriptionServletTest extends DrServletTestBase {
subscription.setMetadataOnly(false);
subscription.setSuspended(false);
subscription.setDecompress(false);
- subscription.doInsert(db.getConnection());
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ subscription.doInsert(conn);
+ }
}
} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTaskTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTaskTest.java
index 8c48d705..7ebe45d9 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTaskTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SynchronizerTaskTest.java
@@ -54,6 +54,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
+import org.onap.dmaap.datarouter.provisioning.utils.SynchronizerTask;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
index 7b77a1ea..40d2d61d 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/EgressRouteTest.java
@@ -20,6 +20,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
+import java.sql.Connection;
import java.sql.SQLException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -30,7 +31,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@@ -40,7 +41,6 @@ public class EgressRouteTest {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@BeforeClass
public static void init() {
@@ -59,7 +59,6 @@ public class EgressRouteTest {
}
@Before
public void setUp() throws Exception {
- db = new DB();
egressRoute = new EgressRoute(2, 1);
}
@@ -67,12 +66,14 @@ public class EgressRouteTest {
public void Verify_EgressRoute_Is_Removed_Successfully() throws SQLException {
Assert.assertEquals(1, EgressRoute.getAllEgressRoutes().size());
EgressRoute egressRoute = new EgressRoute(1, 1);
- egressRoute.doDelete(db.getConnection());
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ egressRoute.doDelete(conn);
+ }
Assert.assertEquals(0, EgressRoute.getAllEgressRoutes().size());
}
@Test
- public void Verify_EgressRoute_Is_Updated_Successfully() throws SQLException {
+ public void Verify_EgressRoute_Is_Updated_Successfully() {
EgressRoute egressRoute = new EgressRoute(1, 1);
EgressRoute egressRoute1 = new EgressRoute(1, 1);
Assert.assertEquals(egressRoute.hashCode(), egressRoute1.hashCode());
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
index 37e69c84..ec401075 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/FeedTest.java
@@ -22,31 +22,33 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning.beans;
-import org.json.JSONObject;
-import org.junit.*;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
-import org.powermock.modules.junit4.PowerMockRunner;
+import static org.mockito.Matchers.anyString;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import java.io.InvalidObjectException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
-import static org.mockito.Matchers.anyString;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
+import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class FeedTest {
private static EntityManagerFactory emf;
private static EntityManager em;
private Feed feed;
- private DB db;
+ private ProvDbUtils provDbUtils;
@BeforeClass
public static void init() {
@@ -66,7 +68,7 @@ public class FeedTest {
@Before
public void setUp() throws Exception {
- db = new DB();
+ provDbUtils = ProvDbUtils.getInstance();
feed = new Feed("Feed1","v0.1", "First Feed for testing", "First Feed for testing");
feed.setFeedid(1);
feed.setGroupid(1);
@@ -76,25 +78,25 @@ public class FeedTest {
@Test
public void Given_getFilteredFeedUrlList_With_Name_Then_Method_Returns_Self_Links() {
- List<String> list= feed.getFilteredFeedUrlList("name","Feed1");
+ List<String> list= Feed.getFilteredFeedUrlList("name","Feed1");
Assert.assertEquals("self_link",list.get(0));
}
@Test
public void Given_getFilteredFeedUrlList_With_Publ_Then_Method_Returns_Self_Links() {
- List<String> list= feed.getFilteredFeedUrlList("publ","pub");
+ List<String> list= Feed.getFilteredFeedUrlList("publ","pub");
Assert.assertEquals("self_link",list.get(0));
}
@Test
public void Given_getFilteredFeedUrlList_With_Subs_Then_Method_Returns_Self_Links() {
- List<String> list= feed.getFilteredFeedUrlList("subs","sub123");
+ List<String> list= Feed.getFilteredFeedUrlList("subs","sub123");
Assert.assertEquals("self_link",list.get(0));
}
@Test
- public void Given_doDelete_Succeeds_Then_doInsert_To_Put_Feed_Back_And_Bool_Is_True() throws SQLException, InvalidObjectException {
- Boolean bool = feed.doDelete(db.getConnection());
+ public void Given_doDelete_Succeeds_Then_doInsert_To_Put_Feed_Back_And_Bool_Is_True() throws SQLException {
+ Boolean bool = feed.doDelete(provDbUtils.getConnection());
Assert.assertEquals(true, bool);
JSONObject jo = new JSONObject();
jo.put("self","self_link");
@@ -102,7 +104,7 @@ public class FeedTest {
jo.put("subscribe","subscribe_link");
jo.put("log","log_link");
feed.setLinks(new FeedLinks(jo));
- bool = feed.doInsert(db.getConnection());
+ bool = feed.doInsert(provDbUtils.getConnection());
Assert.assertEquals(true, bool);
}
@@ -134,7 +136,7 @@ public class FeedTest {
@Test
public void Given_doInsert_Throws_SQLException_Then_Returns_False() throws SQLException {
- Connection connection = db.getConnection();
+ Connection connection = provDbUtils.getConnection();
FeedAuthorization fa = new FeedAuthorization();
Set setA = new HashSet();
setA.add(new FeedEndpointID("1", "Name"));
@@ -176,11 +178,11 @@ public class FeedTest {
@Test
public void Given_IsFeedValid_Called_And_Feed_Exists_Returns_True(){
- Assert.assertEquals(feed.isFeedValid(1), true);
+ Assert.assertTrue(Feed.isFeedValid(1));
}
private Connection CreateSpyForDbConnection() throws SQLException {
- Connection conn = db.getConnection();
+ Connection conn = provDbUtils.getConnection();
return Mockito.spy(conn);
}
} \ No newline at end of file
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java
index b785fdc2..82ee0837 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/GroupTest.java
@@ -22,24 +22,28 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning.beans;
-import org.junit.*;
-import org.junit.runner.RunWith;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
-import org.powermock.modules.junit4.PowerMockRunner;
-
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
+import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class GroupTest {
private static EntityManagerFactory emf;
private static EntityManager em;
private Group group;
- private DB db;
+ private ProvDbUtils provDbUtils = ProvDbUtils.getInstance();
@BeforeClass
public static void init() {
@@ -59,9 +63,17 @@ public class GroupTest {
@Before
public void setUp() throws Exception {
- db = new DB();
- group = new Group("GroupTest", "", "");
- group.doInsert(db.getConnection());
+ group = new Group("GroupTest", "This group has a description", "");
+ try (Connection conn = provDbUtils.getConnection()) {
+ group.doInsert(conn);
+ }
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ try (Connection conn = provDbUtils.getConnection()) {
+ group.doDelete(conn);
+ }
}
@Test
@@ -79,26 +91,21 @@ public class GroupTest {
public void Given_Group_Inserted_With_Same_Name_GetGroupMatching_With_Id_Returns_Correct_Group()
throws Exception {
Group sameGroupName = new Group("GroupTest", "This group has a description", "");
- sameGroupName.doInsert(db.getConnection());
+ sameGroupName.doInsert(provDbUtils.getConnection());
Assert.assertEquals(
"This group has a description", Group.getGroupMatching(group, 2).getDescription());
- sameGroupName.doDelete(db.getConnection());
- }
-
- @Test
- public void Given_Group_Inserted_GetGroupById_Returns_Correct_Group() {
- Assert.assertEquals(group, Group.getGroupById(group.getGroupid()));
+ sameGroupName.doDelete(provDbUtils.getConnection());
}
@Test
public void Given_Group_AuthId_Updated_GetGroupByAuthId_Returns_Correct_Group() throws Exception {
group.setAuthid("Basic TmFtZTp6Z04wMFkyS3gybFppbXltNy94ZDhuMkdEYjA9");
- group.doUpdate(db.getConnection());
+ group.doUpdate(provDbUtils.getConnection());
Assert.assertEquals(group, Group.getGroupByAuthId("Basic TmFtZTp6Z04wMFkyS3gybFppbXltNy94ZDhuMkdEYjA9"));
}
- @After
- public void tearDown() throws Exception {
- group.doDelete(db.getConnection());
+ @Test
+ public void Given_Group_Inserted_GetGroupById_Returns_Correct_Group() {
+ Assert.assertEquals(group, Group.getGroupById(group.getGroupid()));
}
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java
index ad259a59..b26b0000 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/IngressRouteTest.java
@@ -52,7 +52,7 @@ public class IngressRouteTest {
Feed feed = mock(Feed.class);
PowerMockito.when(Feed.getFeedById(1)).thenReturn(feed);
Map<String, Integer> map = new HashMap<>();
- FieldUtils.writeDeclaredStaticField(NodeClass.class, "map", map, true);
+ FieldUtils.writeDeclaredStaticField(NodeClass.class, "nodesMap", map, true);
}
@Test
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
index bd0ebdcb..24400f63 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
@@ -20,13 +20,6 @@
package org.onap.dmaap.datarouter.provisioning.beans;
-import org.junit.*;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
-import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
@@ -34,15 +27,21 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
+import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
public class LogRecordTest {
- private LogRecord logRecord;
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
- private static final String INSERT_SQL = "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- private PreparedStatement ps;
@BeforeClass
public static void init() {
@@ -62,9 +61,7 @@ public class LogRecordTest {
@Before
public void setUp() throws ParseException, SQLException {
- db = new DB();
- Connection conn = db.getConnection();
- ps = conn.prepareStatement(INSERT_SQL);
+
}
@Test
@@ -103,9 +100,14 @@ public class LogRecordTest {
private void setArgsLoadAndAssertEquals(String type, String s) throws ParseException, SQLException {
String[] args = {"2018-08-29-10-10-10-543.", "LOG", "ID", "1", "URL/file123", "PUT", "application/vnd.dmaap-.log-list; version=1.0", "100", type, "1", "172.0.0.8", "user", "204", "1", "1", "204", "0", "other", "1", "100", "file123"};
- logRecord = new LogRecord(args);
- logRecord.load(ps);
- String compare_string = ps.toString().substring(ps.toString().indexOf("{1:"), ps.toString().indexOf("2:")) + ps.toString().substring(ps.toString().indexOf("3:"));
- Assert.assertEquals(compare_string, s);
+ LogRecord logRecord = new LogRecord(args);
+ try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
+ PreparedStatement ps = conn.prepareStatement(
+ "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ logRecord.load(ps);
+ String compare_string = ps.toString().substring(ps.toString().indexOf("{1:"), ps.toString().indexOf("2:")) + ps
+ .toString().substring(ps.toString().indexOf("3:"));
+ Assert.assertEquals(compare_string, s);
+ }
}
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
index d727bc77..d02f39d4 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/NetworkRouteTest.java
@@ -20,6 +20,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
+import java.sql.Connection;
import java.sql.SQLException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -30,17 +31,18 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
+import org.onap.dmaap.datarouter.provisioning.utils.ProvDbUtils;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class NetworkRouteTest {
- private NetworkRoute networkRoute;
+ private NetworkRoute networkRoute = new NetworkRoute("node01.","node03.","node02.");
+ private ProvDbUtils provDbUtils = ProvDbUtils.getInstance();
+
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@BeforeClass
public static void init() {
@@ -59,23 +61,22 @@ public class NetworkRouteTest {
}
@Before
public void setUp() throws Exception {
- db = new DB();
- networkRoute = new NetworkRoute("node01.","node03.","node02.");
+ try (Connection conn = provDbUtils.getConnection()) {
+ networkRoute.doInsert(conn);
+ }
}
@Test
public void Verify_NetworkRoute_Is_Removed_Successfully() throws SQLException {
+ Assert.assertEquals(2, NetworkRoute.getAllNetworkRoutes().size());
+ networkRoute.doDelete(provDbUtils.getConnection());
Assert.assertEquals(1, NetworkRoute.getAllNetworkRoutes().size());
- NetworkRoute networkRoute = new NetworkRoute("stub_from.", "stub_to.");
- networkRoute.doDelete(db.getConnection());
- Assert.assertEquals(0, NetworkRoute.getAllNetworkRoutes().size());
}
@Test
public void Verify_NetworkRoute_Is_Updated_Successfully() throws SQLException {
NetworkRoute networkRoute = new NetworkRoute("stub_from.", "stub_to.", "node02.");
- networkRoute.doUpdate(db.getConnection());
- //Assert.assertTrue(NetworkRoute.getAllNetworkRoutes().contains(networkRoute));
+ networkRoute.doUpdate(provDbUtils.getConnection());
for (NetworkRoute net :
NetworkRoute.getAllNetworkRoutes()) {
Assert.assertEquals(5, net.getVianode());
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
index 214cc6e7..7f049e5d 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/SubscriptionTest.java
@@ -32,7 +32,6 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@@ -42,7 +41,6 @@ public class SubscriptionTest {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db;
@BeforeClass
public static void init() {
@@ -61,7 +59,6 @@ public class SubscriptionTest {
}
@Before
public void setUp() throws Exception {
- db = new DB();
subscription = new Subscription();
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java
index 056469a8..d1bedabb 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/utils/DbTest.java
@@ -35,8 +35,6 @@ public class DbTest {
private static EntityManagerFactory emf;
private static EntityManager em;
- private DB db = new DB();
-
@BeforeClass
public static void init() {
emf = Persistence.createEntityManagerFactory("db-unit-tests");
@@ -55,7 +53,7 @@ public class DbTest {
@Test
public void Verify_DB_Is_Initialised_Successfully() {
- Assert.assertTrue(db.runRetroFits());
+ Assert.assertTrue(ProvDbUtils.getInstance().initProvDB());
}
}