From 19684879f5742847e2e903d6c039de7e13fab6e3 Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Tue, 5 May 2020 08:47:19 +0000 Subject: sonar bug fix- Use the "equals" method if value comparison was intended Signed-off-by: priyanka.akhade Issue-ID: CLI-270 Change-Id: I0c379ae2a6798303daf676c0e741aace48e673ca --- .../onap/cli/fw/http/OnapHttpConnectionTest.java | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'profiles/http/src/test') diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java index f0115580..2860388b 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java @@ -156,6 +156,65 @@ public class OnapHttpConnectionTest { con.request(inp); } + @Test(expected = OnapCommandHttpFailure.class) + public void testGetMultipartEntityWithoutMultipartEntityName() throws OnapCommandHttpFailure { + new MockUp() { + @Mock + public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context) + throws IOException, ClientProtocolException { + + throw new IOException("IO Exception"); + } + }; + new MockUp() { + + @Mock + public boolean isBinaryData() { + return true; + } + }; + Map reqHeaders = new HashMap<>(); + reqHeaders.put("Content-Disposition","form-data"); + reqHeaders.put("name","upload"); + reqHeaders.put("filename","upload.txt"); + reqHeaders.put("Content-Type","application/octet-stream"); + reqHeaders.put("Content-Transfer-Encoding","binary"); + inp.setReqHeaders(reqHeaders); + inp.setMethod("post"); + con = new OnapHttpConnection(); + con.request(inp); + } + + @Test(expected = OnapCommandHttpFailure.class) + public void testGetMultipartEntityWithMultipartEntityName() throws OnapCommandHttpFailure { + new MockUp() { + @Mock + public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context) + throws IOException, ClientProtocolException { + + throw new IOException("IO Exception"); + } + }; + new MockUp() { + + @Mock + public boolean isBinaryData() { + return true; + } + }; + Map reqHeaders = new HashMap<>(); + reqHeaders.put("Content-Disposition","form-data"); + reqHeaders.put("name","upload"); + reqHeaders.put("filename","upload.txt"); + reqHeaders.put("Content-Type","application/octet-stream"); + reqHeaders.put("Content-Transfer-Encoding","binary"); + inp.setReqHeaders(reqHeaders); + inp.setMethod("post"); + inp.setMultipartEntityName("test"); + con = new OnapHttpConnection(); + con.request(inp); + } + @Test() public void httpUnSecuredCloseExceptionTest() throws OnapCommandHttpFailure { inp.setMethod("other"); -- cgit 1.2.3-korg