summaryrefslogtreecommitdiffstats
path: root/datarouter-node
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2020-04-04 17:51:53 +0100
committerefiacor <fiachra.corcoran@est.tech>2020-04-09 16:35:42 +0100
commit8552e04175c7091d0d748e0c0f4b14a0d9321b40 (patch)
tree4312baf8a99e5294ccbcb8a8a418e4f53e12b67e /datarouter-node
parent3d3b9def088b171329dc47fd7a1c471d25aafc06 (diff)
[DMaaP DR] JKD 11 migration
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: Ib9d326f4bdf5c4e208dea5a4a00be0c3be3a3067 Issue-ID: DMAAP-1386
Diffstat (limited to 'datarouter-node')
-rwxr-xr-xdatarouter-node/pom.xml48
-rw-r--r--datarouter-node/src/main/resources/docker/Dockerfile11
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilterTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java3
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTaskTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/LogManagerTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigManagerTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServerTest.java3
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServletTest.java78
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/RedirManagerTest.java2
-rw-r--r--datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/StatusLogTest.java2
15 files changed, 122 insertions, 41 deletions
diff --git a/datarouter-node/pom.xml b/datarouter-node/pom.xml
index fd859bef..3f0bd546 100755
--- a/datarouter-node/pom.xml
+++ b/datarouter-node/pom.xml
@@ -64,6 +64,12 @@
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>powermock-api-mockito</artifactId>
+ <groupId>org.powermock</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
@@ -103,7 +109,7 @@
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
+ <artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -115,6 +121,24 @@
<groupId>org.sonatype.http-testing-harness</groupId>
<artifactId>junit-runner</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>powermock-api-mockito</artifactId>
+ <groupId>org.powermock</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>powermock-reflect</artifactId>
+ <groupId>org.powermock</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jetty-security</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jsr305</artifactId>
+ <groupId>com.google.code.findbugs</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -128,7 +152,7 @@
</dependency>
<dependency>
<groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
+ <artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -142,6 +166,26 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.bytebuddy</groupId>
+ <artifactId>byte-buddy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.bytebuddy</groupId>
+ <artifactId>byte-buddy-agent</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.1.6</version>
diff --git a/datarouter-node/src/main/resources/docker/Dockerfile b/datarouter-node/src/main/resources/docker/Dockerfile
index 0d2331fd..7357d931 100644
--- a/datarouter-node/src/main/resources/docker/Dockerfile
+++ b/datarouter-node/src/main/resources/docker/Dockerfile
@@ -18,14 +18,17 @@
# limitations under the License.
# ============LICENSE_END====================================================
#
-FROM openjdk:8-jre-alpine
+FROM openjdk:11.0.6-jre-slim
MAINTAINER DMAAP Team
COPY /opt /opt
# curl used for healthcheck
-RUN apk update && apk add curl && apk add vim
+RUN apt-get update && \
+ apt-get install -y \
+ curl \
+ vim
EXPOSE 8080 8443
@@ -33,8 +36,8 @@ WORKDIR /opt
RUN chmod 0700 startup.sh
ENTRYPOINT ["sh", "startup.sh"]
-RUN addgroup -S -g 1001 onap \
- && adduser -S -u 1000 dradmin -G onap \
+RUN groupadd -g 1001 onap \
+ && useradd -u 1000 dradmin -g onap \
&& chown -R dradmin:onap /opt/ /var/
USER dradmin
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilterTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilterTest.java
index bb367186..0796aa56 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilterTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DRNodeCadiFilterTest.java
@@ -39,6 +39,7 @@ import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.filter.CadiFilter;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.api.support.membermodification.MemberMatcher;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -46,6 +47,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
@PrepareForTest({CadiFilter.class})
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
public class DRNodeCadiFilterTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java
index 5b2b9ea1..fa4966c9 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryQueueTest.java
@@ -36,7 +36,6 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
import org.apache.commons.lang3.reflect.FieldUtils;
@@ -46,11 +45,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class DeliveryQueueTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTaskTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTaskTest.java
index 596d56a7..0f019161 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTaskTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTaskTest.java
@@ -34,12 +34,14 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest({URL.class})
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class DeliveryTaskTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
index 18d9d56c..25830cdd 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/DeliveryTest.java
@@ -39,11 +39,13 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.onap.dmaap.datarouter.node.Delivery.DelItem;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class DeliveryTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/LogManagerTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/LogManagerTest.java
index da690206..7eacd838 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/LogManagerTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/LogManagerTest.java
@@ -38,11 +38,13 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.onap.dmaap.datarouter.node.LogManager.Uploader;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.NodeConfigManager"})
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class LogManagerTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigManagerTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigManagerTest.java
index 9c945725..88e6e48d 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigManagerTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigManagerTest.java
@@ -30,6 +30,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
+import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.nio.file.Files;
@@ -46,7 +47,6 @@ import org.junit.Test;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
-import sun.net.www.URLConnection;
@PowerMockIgnore({"javax.net.ssl.*", "javax.security.auth.x500.X500Principal", "javax.crypto.*"})
@PrepareForTest({InetAddress.class})
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
index b03407bf..05cd0dce 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeConfigTest.java
@@ -31,11 +31,13 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.node.ProvData"})
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class NodeConfigTest {
private static NodeConfig nodeConfig;
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServerTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServerTest.java
index f72e581d..153753e9 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServerTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServerTest.java
@@ -34,11 +34,13 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class NodeServerTest {
private NodeConfigManager config = mock(NodeConfigManager.class);
@@ -47,7 +49,6 @@ public class NodeServerTest {
setUpConfig();
setUpNodeMainDelivery();
createFilesAndDirectories();
- mock(Delivery.class);
}
@AfterClass
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServletTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServletTest.java
index 136e21d4..4340b018 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServletTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeServletTest.java
@@ -22,32 +22,43 @@
******************************************************************************/
package org.onap.dmaap.datarouter.node;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.read.ListAppender;
-import ch.qos.logback.classic.Logger;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
-import org.junit.*;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.LoggerFactory;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
public class NodeServletTest {
private NodeServlet nodeServlet;
@@ -128,7 +139,7 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_PUT_And_Endpoint_Is_Incorrect_Then_Not_Found_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn("/incorrect/");
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -136,7 +147,7 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_PUT_And_Request_Is_Not_Secure_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -144,7 +155,7 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_PUT_And_File_Id_Is_Null_Then_Not_Found_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn(null);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -152,7 +163,7 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_PUT_And_Authorization_Is_Null_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.getHeader("Authorization")).thenReturn(null);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -160,16 +171,17 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_PUT_And_Publish_Does_Not_Include_File_Id_Then_Not_Found_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn("/publish/");
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@Test
public void Given_Request_Is_HTTP_PUT_And_Publish_Not_Permitted_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn("/publish/1/fileName");
+ when(request.getRemoteAddr()).thenReturn("1.2.3.4");
setNodeConfigManagerIsPublishPermittedToReturnAReason();
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -184,16 +196,19 @@ public class NodeServletTest {
@Test
public void Given_Request_Is_HTTP_PUT_And_Internal_Publish_But_Invalid_File_Id_Then_Not_Found_Response_Is_Generated() throws Exception {
- when(request.getPathInfo()).thenReturn("/internal/publish/1/");
+ when(request.getPathInfo()).thenReturn("/internal/publish/1/blah");
+ when(request.getRemoteAddr()).thenReturn("1.2.3.4");
+ when(config.isAnotherNode(anyString(), anyString())).thenReturn(true);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@Test
public void Given_Request_Is_HTTP_PUT_On_Publish_And_Ingress_Node_Is_Provided_Then_Request_Is_Redirected() throws Exception {
- when(request.getPathInfo()).thenReturn("/publish/1/fileName");
setNodeConfigManagerToAllowRedirectOnIngressNode();
+ when(request.getPathInfo()).thenReturn("/publish/1/fileName");
+ when(request.getRemoteAddr()).thenReturn("1.2.3.4");
nodeServlet.doPut(request, response);
verify(response).sendRedirect(anyString());
verifyEnteringExitCalled(listAppender);
@@ -204,7 +219,7 @@ public class NodeServletTest {
when(request.getPathInfo()).thenReturn("/publish/1/fileName");
setHeadersForValidRequest(true);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), anyString());
}
@Test
@@ -212,7 +227,7 @@ public class NodeServletTest {
when(request.getPathInfo()).thenReturn("/publish/1/fileName");
setHeadersForValidRequest(false);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), anyString());
}
@Test
@@ -222,7 +237,7 @@ public class NodeServletTest {
when(request.getPathInfo()).thenReturn("/publish/1/fileName");
setHeadersForValidRequest(true);
nodeServlet.doPut(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -231,14 +246,14 @@ public class NodeServletTest {
when(request.getPathInfo()).thenReturn("/publish/1/fileName");
setHeadersForValidRequest(false);
nodeServlet.doDelete(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), anyString());
}
@Test
public void Given_Request_Is_HTTP_DELETE_File_With_Invalid_Endpoint_Then_Not_Found_Response_Is_Generated() throws Exception {
when(request.getPathInfo()).thenReturn("/delete/1");
nodeServlet.doDelete(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -273,7 +288,7 @@ public class NodeServletTest {
public void Given_Request_Is_HTTP_DELETE_File_And_File_Does_Not_Exist_Then_Not_Found_Response_Is_Generated() throws IOException {
when(request.getPathInfo()).thenReturn("/delete/1/nonExistingFile");
nodeServlet.doDelete(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
+ verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), anyString());
verifyEnteringExitCalled(listAppender);
}
@@ -302,7 +317,7 @@ public class NodeServletTest {
when(config.getSpoolBase()).thenReturn("spool");
when(config.getLogDir()).thenReturn("log/dir");
when(config.getPublishId()).thenReturn("User1");
- when(config.isAnotherNode(anyString(), anyString())).thenReturn(true);
+ when(config.isAnotherNode(anyString(), anyString())).thenReturn(false);
when(config.getEventLogInterval()).thenReturn("40");
when(config.isDeletePermitted("1")).thenReturn(true);
when(config.getAllDests()).thenReturn(new DestInfo[0]);
@@ -348,10 +363,11 @@ public class NodeServletTest {
private void setNodeConfigManagerIsPublishPermittedToReturnAReason() throws IllegalAccessException{
NodeConfigManager config = mock(NodeConfigManager.class);
when(config.isShutdown()).thenReturn(false);
+ when(config.getMyName()).thenReturn("dmaap-dr-node");
when(config.isConfigured()).thenReturn(true);
when(config.getSpoolDir()).thenReturn("spool/dir");
when(config.getLogDir()).thenReturn("log/dir");
- when(config.isPublishPermitted(anyString(), anyString(), anyString())).thenReturn("Not Permitted");
+ when(config.isPublishPermitted(anyString(), anyString(), anyString())).thenReturn("Publisher not permitted for this feed");
when(config.isAnotherNode(anyString(), anyString())).thenReturn(false);
FieldUtils.writeDeclaredStaticField(NodeServlet.class, "config", config, true);
}
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java
index 9832785e..d139d0e3 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/NodeUtilsTest.java
@@ -34,7 +34,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.MDC;
@RunWith(PowerMockRunner.class)
-@PowerMockIgnore({"java.net.ssl", "javax.security.auth.x500.X500Principal"})
+@PowerMockIgnore({"java.net.ssl", "javax.security.auth.x500.X500Principal", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
public class NodeUtilsTest {
@Mock
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java
index 1fd79d9a..1a4564ab 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/ProvDataTest.java
@@ -29,9 +29,11 @@ import java.io.Reader;
import java.nio.charset.StandardCharsets;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ProvDataTest {
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/RedirManagerTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/RedirManagerTest.java
index 2c8a0e52..87abe84e 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/RedirManagerTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/RedirManagerTest.java
@@ -33,9 +33,11 @@ import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class RedirManagerTest {
private RedirManager redirManager;
diff --git a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/StatusLogTest.java b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/StatusLogTest.java
index d3793069..28dcba9a 100644
--- a/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/StatusLogTest.java
+++ b/datarouter-node/src/test/java/org/onap/dmaap/datarouter/node/StatusLogTest.java
@@ -30,6 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -37,6 +38,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.node.NodeConfigManager")
@PrepareForTest(StatusLog.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class StatusLogTest {
@Before