diff options
author | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-05-05 08:47:19 +0000 |
---|---|---|
committer | priyanka.akhade <priyanka.akhade@huawei.com> | 2020-05-06 09:26:17 +0000 |
commit | 19684879f5742847e2e903d6c039de7e13fab6e3 (patch) | |
tree | c8a7a459dc4acfc5a9e3194756b8b3b572722825 /profiles/http/src/test | |
parent | 1db7e72d979afa03bca38d3008f55246f8d6a6c1 (diff) |
sonar bug fix- Use the "equals" method if value comparison was intended
Signed-off-by: priyanka.akhade <priyanka.akhade@huawei.com>
Issue-ID: CLI-270
Change-Id: I0c379ae2a6798303daf676c0e741aace48e673ca
Diffstat (limited to 'profiles/http/src/test')
-rw-r--r-- | profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
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<CloseableHttpClient>() { + @Mock + public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context) + throws IOException, ClientProtocolException { + + throw new IOException("IO Exception"); + } + }; + new MockUp<HttpInput>() { + + @Mock + public boolean isBinaryData() { + return true; + } + }; + Map<String, String> 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<CloseableHttpClient>() { + @Mock + public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context) + throws IOException, ClientProtocolException { + + throw new IOException("IO Exception"); + } + }; + new MockUp<HttpInput>() { + + @Mock + public boolean isBinaryData() { + return true; + } + }; + Map<String, String> 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"); |