diff options
author | 2021-02-03 14:18:39 +0100 | |
---|---|---|
committer | 2021-02-05 22:55:53 +0000 | |
commit | 8bbecead253c30da60577ecd014d59983e4b6113 (patch) | |
tree | 870e2c2051598724cad30e0fa5e539378737e3c7 /sdnr/wt/apigateway/provider/src/test | |
parent | 2f9e781a7c3e22bf25df83dcc3ff44b885a80957 (diff) |
Migrate apigateway and helpserver
Migrate apigateway and helpserver to Aluminium
Issue-ID: CCSDK-3129
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I6a669b7e0e5d805cab4a9e59e2b21a95fb6506f8
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/apigateway/provider/src/test')
-rw-r--r-- | sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java index b12281e32..4048012bb 100644 --- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java +++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java @@ -26,28 +26,23 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; import java.io.IOException; import java.io.OutputStream; -import java.io.StringWriter; import java.net.InetSocketAddress; import java.util.Enumeration; import java.util.Map; import java.util.Vector; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.junit.After; import org.junit.Before; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; +import org.onap.ccsdk.features.sdnr.wt.common.test.ServletInputStreamFromByteArrayInputStream; +import org.onap.ccsdk.features.sdnr.wt.common.test.ServletOutputStreamToStringWriter; @SuppressWarnings("restriction") public class HelpServletBase { @@ -89,21 +84,8 @@ public class HelpServletBase { HttpServletRequest mockRequest = mock(HttpServletRequest.class); HttpServletResponse mockResponse = mock(HttpServletResponse.class); - StringWriter out = new StringWriter(); - ServletOutputStream printOut = new ServletOutputStream() { - - @Override - public void write(int arg0) throws IOException { - out.write(arg0); - } - }; - ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes()); - ServletInputStream inputStream = new ServletInputStream() { - @Override - public int read() throws IOException { - return bis.read(); - } - }; + ServletOutputStreamToStringWriter printOut = new ServletOutputStreamToStringWriter(); + ServletInputStreamFromByteArrayInputStream inputStream = new ServletInputStreamFromByteArrayInputStream(data.getBytes()); Vector<String> headers = new Vector<String>(); headers.addElement("Accept"); headers.add("User-Agent"); @@ -134,9 +116,9 @@ public class HelpServletBase { verify(mockResponse).setStatus(200); if (exact) - assertEquals(expectedResponse, out.toString()); + assertEquals(expectedResponse, printOut.getStringWriter().toString()); else - assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse)); + assertTrue("response not for method " + method + "correct", printOut.getStringWriter().toString().contains(expectedResponse)); // currently unable to check extra headers if (headersToCheck != null) { |