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/24 10:57:54 UTC

[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #4293: Extend tests with RAW and CXF_MESSAGE dataFormats

ppalaga commented on code in PR #4293:
URL: https://github.com/apache/camel-quarkus/pull/4293#discussion_r1031370532


##########
integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java:
##########
@@ -38,16 +47,45 @@ public class CxfSoapClientRoutes extends RouteBuilder {
     @ConfigProperty(name = "camel-quarkus.it.calculator.baseUri")
     String serviceBaseUri;
 
+    public static final String MESSAGE_RAW_SIMPLE_ADD = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://www.jboss.org/eap/quickstarts/wscalculator/Calculator\">\n"
+            +
+            "   <soapenv:Header/>\n" +
+            "   <soapenv:Body>\n" +
+            "      <ser:add>\n" +
+            "         <arg0>%s</arg0>\n" +
+            "         <arg1>%s</arg1>\n" +
+            "      </ser:add>\n" +
+            "   </soapenv:Body>\n" +
+            "</soapenv:Envelope>";
+
     @Override
     public void configure() {
 
         from("direct:simpleUriBean")
-                .to("cxf:bean:soapClientEndpoint?dataFormat=PAYLOAD");
+                .to("cxf:bean:soapClientEndpoint?dataFormat=POJO");
 
         from("direct:simpleUriAddress")
                 .to(String.format("cxf://%s?wsdlURL=%s&dataFormat=POJO&serviceClass=%s", calculatorServiceAddress(),
                         calculatorServiceWsdlUrl(), CalculatorService.class.getName()));
 
+        from("direct:simpleAddDataFormat")
+                .process(exchange -> {
+                    Map<String, Object> headers = exchange.getIn().getHeaders();
+                    String endpointDataFormat = headers.get("endpointDataFormat").toString();
+                    int[] numbers = exchange.getIn().getBody(int[].class);
+                    String xmlRequest = String.format(MESSAGE_RAW_SIMPLE_ADD, numbers[0], numbers[1]);
+                    if (DataFormat.RAW.name().equals(endpointDataFormat)) {
+                        exchange.getIn().setBody(xmlRequest);
+                    } else if (DataFormat.CXF_MESSAGE.name().equals(endpointDataFormat)) {
+                        try (InputStream is = new ByteArrayInputStream(xmlRequest.getBytes())) {

Review Comment:
   The current machine's default encoding can be just anything.
   ```suggestion
                           try (InputStream is = new ByteArrayInputStream(xmlRequest.getBytes(StandardCharsets.UTF_8))) {
   ```



##########
integration-test-groups/cxf-soap/cxf-soap-client/src/main/java/org/apache/camel/quarkus/component/cxf/soap/client/it/CxfSoapClientRoutes.java:
##########
@@ -38,16 +47,45 @@ public class CxfSoapClientRoutes extends RouteBuilder {
     @ConfigProperty(name = "camel-quarkus.it.calculator.baseUri")
     String serviceBaseUri;
 
+    public static final String MESSAGE_RAW_SIMPLE_ADD = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://www.jboss.org/eap/quickstarts/wscalculator/Calculator\">\n"
+            +
+            "   <soapenv:Header/>\n" +
+            "   <soapenv:Body>\n" +
+            "      <ser:add>\n" +
+            "         <arg0>%s</arg0>\n" +
+            "         <arg1>%s</arg1>\n" +
+            "      </ser:add>\n" +
+            "   </soapenv:Body>\n" +
+            "</soapenv:Envelope>";
+
     @Override
     public void configure() {
 
         from("direct:simpleUriBean")
-                .to("cxf:bean:soapClientEndpoint?dataFormat=PAYLOAD");
+                .to("cxf:bean:soapClientEndpoint?dataFormat=POJO");

Review Comment:
   Why this change? I thought we are only adding tests here and not changing any thing that worked before. Or this did not work before?



-- 
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