X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=restapi-call-node%2Fprovider%2Fsrc%2Ftest%2Fjava%2Fjtest%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FTestRestapiCallNode.java;h=7a24ca1a9cb05d837d87e4805011b7d1cfb4c2bc;hb=a5fa2ea36c115aba01eb3328fd95a12dd654ed00;hp=5b047e4e7a024a0223456c788b183df44ed16573;hpb=e4c9cfddd142785d527f29ff5c2b5883cc255033;p=ccsdk%2Fsli%2Fplugins.git diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 5b047e4e..7a24ca1a 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -21,15 +21,22 @@ package jtest.org.onap.ccsdk.sli.plugins.restapicall; +import java.net.URI; import java.util.HashMap; import java.util.Map; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.glassfish.jersey.server.ResourceConfig; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; public class TestRestapiCallNode { @@ -654,4 +661,24 @@ public class TestRestapiCallNode { RestapiCallNode rcn = new RestapiCallNode(); rcn.sendRequest(p, ctx); } + + @Test + public void testMultipartFormData() throws SvcLogicException { + final ResourceConfig resourceConfig = new ResourceConfig( + MultipartServerMock.class, MultiPartFeature.class); + GrizzlyHttpServerFactory.createHttpServer( + URI.create("http://localhost:8080/"),resourceConfig); + + Map p = new HashMap<>(); + p.put("multipartFormData", "true"); + p.put("format", "none"); + p.put("multipartFile", "src/test/resources/test-template.json"); + p.put("restapiUrl", "http://localhost:8080/file-upload/upload"); + + SvcLogicContext ctx = new SvcLogicContext(); + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + assertThat(ctx.getAttribute("response-code"), is("200")); + assertThat(ctx.getAttribute("httpResponse"), is( "test-template.json")); + } }