aboutsummaryrefslogtreecommitdiffstats
path: root/profiles/http/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'profiles/http/src/test')
-rw-r--r--profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java59
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");