You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/11/08 12:54:14 UTC

[GitHub] [camel-quarkus] llowinge opened a new pull request, #4264: Enhance test covarege of MTOM with PAYLOAD data format

llowinge opened a new pull request, #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264

   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #4264: Enhance test covarege of MTOM with PAYLOAD data format

Posted by GitBox <gi...@apache.org>.
ppalaga commented on code in PR #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264#discussion_r1016661885


##########
integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java:
##########
@@ -56,22 +74,30 @@ public Response upload(@QueryParam("imageName") String imageName, @QueryParam("m
 
     @Path("/download")
     @POST
+    @Produces(MediaType.APPLICATION_OCTET_STREAM)
     @Consumes(MediaType.TEXT_PLAIN)
-    public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
+    public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled,
+            @QueryParam("endpointDataFormat") String endpointDataFormat)
             throws Exception {
-        final ImageFile response = (ImageFile) producerTemplate.requestBodyAndHeader(
-                "direct:" + mtomEndpoint(mtomEnabled),
-                imageName,
-                OPERATION_NAME,
-                "downloadImage", ImageFile.class);
+        Map<String, Object> headers = new LinkedHashMap<>();
+        headers.put(OPERATION_NAME, "downloadImage");
+        headers.put("endpointDataFormat", endpointDataFormat);
+        headers.put("mtomEnabled", mtomEnabled);
+        Exchange result = producerTemplate.request("direct:invoker", exchange -> {
+            exchange.setPattern(ExchangePattern.InOut);
+            exchange.getIn().setBody(imageName);
+            exchange.getIn().setHeaders(headers);
+        });
+        Object response = null;
+        if ("PAYLOAD".equals(endpointDataFormat)) {
+            response = result.getMessage(AttachmentMessage.class).getAttachment(imageName).getContent();
+        } else {
+            response = result.getMessage().getBody(ImageFile.class).getContent();
+        }

Review Comment:
   I wonder whether we should make our assumption about the runtime type of `getAttachment(imageName).getContent()` explicit? In that way all future readers will clearly see what is sent back over the wire.
   
   Something like 
   
   ```suggestion
           final byte[] response = null;
           if ("PAYLOAD".equals(endpointDataFormat)) {
               response = (byte[]) result.getMessage(AttachmentMessage.class).getAttachment(imageName).getContent();
           } else {
               response = result.getMessage().getBody(ImageFile.class).getContent();
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] llowinge commented on a diff in pull request #4264: Enhance test covarege of MTOM with PAYLOAD data format

Posted by GitBox <gi...@apache.org>.
llowinge commented on code in PR #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264#discussion_r1017773220


##########
integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java:
##########
@@ -56,22 +74,30 @@ public Response upload(@QueryParam("imageName") String imageName, @QueryParam("m
 
     @Path("/download")
     @POST
+    @Produces(MediaType.APPLICATION_OCTET_STREAM)
     @Consumes(MediaType.TEXT_PLAIN)
-    public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
+    public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled,
+            @QueryParam("endpointDataFormat") String endpointDataFormat)
             throws Exception {
-        final ImageFile response = (ImageFile) producerTemplate.requestBodyAndHeader(
-                "direct:" + mtomEndpoint(mtomEnabled),
-                imageName,
-                OPERATION_NAME,
-                "downloadImage", ImageFile.class);
+        Map<String, Object> headers = new LinkedHashMap<>();
+        headers.put(OPERATION_NAME, "downloadImage");
+        headers.put("endpointDataFormat", endpointDataFormat);
+        headers.put("mtomEnabled", mtomEnabled);
+        Exchange result = producerTemplate.request("direct:invoker", exchange -> {
+            exchange.setPattern(ExchangePattern.InOut);
+            exchange.getIn().setBody(imageName);
+            exchange.getIn().setHeaders(headers);
+        });
+        Object response = null;
+        if ("PAYLOAD".equals(endpointDataFormat)) {
+            response = result.getMessage(AttachmentMessage.class).getAttachment(imageName).getContent();
+        } else {
+            response = result.getMessage().getBody(ImageFile.class).getContent();
+        }

Review Comment:
   Fixed, but i had to do it bit differently. Thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] llowinge commented on pull request #4264: Enhance test covarege of MTOM with PAYLOAD data format

Posted by GitBox <gi...@apache.org>.
llowinge commented on PR #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264#issuecomment-1307254452

   @ppalaga Can you check it, thank you


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [camel-quarkus] ppalaga merged pull request #4264: Enhance test covarege of MTOM with PAYLOAD data format

Posted by GitBox <gi...@apache.org>.
ppalaga merged PR #4264:
URL: https://github.com/apache/camel-quarkus/pull/4264


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org