You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2022/10/26 08:21:08 UTC
[camel-quarkus] branch main updated: CxfSoapMtomIT fails in native mode #4208
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new a3b728e158 CxfSoapMtomIT fails in native mode #4208
a3b728e158 is described below
commit a3b728e1580e0d31c56bfc3f0e117e17e9ce0b41
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Oct 25 18:04:18 2022 +0200
CxfSoapMtomIT fails in native mode #4208
---
.../soap/mtom/awt/it/CxfSoapMtomAwtResource.java | 22 +++++++------
.../cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java | 23 -------------
.../cxf/soap/mtom/awt/it/IImageService.java | 6 ++--
.../awt/it/{IImageService.java => ImageData.java} | 38 +++++++++++++++++-----
.../cxf/soap/mtom/awt/it/ImageService.java | 23 +++++--------
.../cxf/soap/mtom/awt/it/CxfSoapMtomAwtTest.java | 9 ++---
6 files changed, 54 insertions(+), 67 deletions(-)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtResource.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtResource.java
index fac4c2d1f9..69be8bdf6a 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtResource.java
@@ -26,8 +26,10 @@ import javax.enterprise.context.ApplicationScoped;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
@@ -44,15 +46,16 @@ public class CxfSoapMtomAwtResource {
@Inject
ProducerTemplate producerTemplate;
- @Path("/upload")
+ @Path("/image/{imageName}")
@POST
+ @Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.TEXT_PLAIN)
- public Response upload(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled,
+ public Response upload(@PathParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled,
byte[] image) throws Exception {
try (ByteArrayInputStream bais = new ByteArrayInputStream(image)) {
final String response = producerTemplate.requestBodyAndHeader(
"direct:" + mtomEndpoint(mtomEnabled),
- new Object[] { ImageIO.read(bais), imageName },
+ new ImageData(ImageIO.read(bais), imageName),
OPERATION_NAME, "uploadImage", String.class);
return Response
.created(new URI("https://camel.apache.org/"))
@@ -61,18 +64,17 @@ public class CxfSoapMtomAwtResource {
}
}
- @Path("/download")
- @POST
- @Consumes(MediaType.TEXT_PLAIN)
- public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
+ @Path("/image/{imageName}")
+ @GET
+ public Response download(@PathParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
throws Exception {
- final BufferedImage response = (BufferedImage) producerTemplate.requestBodyAndHeader(
+ final ImageData image = (ImageData) producerTemplate.requestBodyAndHeader(
"direct:" + mtomEndpoint(mtomEnabled),
imageName,
OPERATION_NAME,
- "downloadImage", Image.class);
+ "downloadImage", ImageData.class);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- ImageIO.write(response, "png", baos);
+ ImageIO.write((BufferedImage) image.getData(), "png", baos);
byte[] bytes = baos.toByteArray();
return Response
.created(new URI("https://camel.apache.org/"))
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java
index 388a8cb093..0bb9e318c2 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java
@@ -26,12 +26,9 @@ import javax.inject.Named;
import javax.xml.ws.handler.Handler;
import io.quarkus.runtime.LaunchMode;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
import org.apache.cxf.ext.logging.LoggingFeature;
-import org.apache.cxf.message.MessageContentsList;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -58,30 +55,10 @@ public class CxfSoapMtomAwtRoutes extends RouteBuilder {
.to("direct:processAwtImage");
from("direct:processAwtImage")
- .process("imageAwtServiceProcessor")
.recipientList((simple("bean:imageAwtService?method=${header.operationName}")));
}
- @ApplicationScoped
- @Named("imageAwtServiceProcessor")
- static class ImageServiceProcessor implements Processor {
- @Override
- public void process(Exchange exchange) throws Exception {
- String operationName = (String) exchange.getIn().getHeaders().get("operationName");
- MessageContentsList list = (MessageContentsList) exchange.getIn().getBody();
- if ("uploadImage".equals(operationName)) {
- exchange.getIn().getHeaders().put("image", list.get(0));
- exchange.getIn().getHeaders().put("imageName", list.get(1));
- exchange.getIn().getHeaders()
- .put("operationName", "uploadImage(${header.image},${header.imageName})");
- } else if ("downloadImage".equals(operationName)) {
- exchange.getIn().setBody(list.get(0));
- }
- }
-
- }
-
@Produces
@ApplicationScoped
@Named("loggingMtomAwtFeatureClient")
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java
index 686c53bbc6..6816daae83 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.awt.it;
-import java.awt.*;
-
import javax.jws.WebMethod;
import javax.jws.WebService;
@@ -25,9 +23,9 @@ import javax.jws.WebService;
public interface IImageService {
@WebMethod
- Image downloadImage(String name);
+ ImageData downloadImage(String name);
@WebMethod
- String uploadImage(Image image, String name);
+ String uploadImage(ImageData image);
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageData.java
similarity index 58%
copy from integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java
copy to integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageData.java
index 686c53bbc6..e39a79a9c5 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/IImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageData.java
@@ -16,18 +16,38 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.awt.it;
-import java.awt.*;
+import java.awt.Image;
-import javax.jws.WebMethod;
-import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlType;
-@WebService
-public interface IImageService {
+@XmlType(name = "imageData", namespace = "http://org.jboss.ws/xop/doclit")
+public class ImageData {
- @WebMethod
- Image downloadImage(String name);
+ private Image data;
+ private String name;
- @WebMethod
- String uploadImage(Image image, String name);
+ public ImageData() {
+ }
+ public ImageData(Image data, String name) {
+ super();
+ this.data = data;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Image getData() {
+ return data;
+ }
+
+ public void setData(Image data) {
+ this.data = data;
+ }
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageService.java
index aa0f0ab5c4..6a213f9732 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageService.java
@@ -23,25 +23,20 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.jboss.logging.Logger;
@ApplicationScoped
@Named("imageAwtService")
public class ImageService implements IImageService {
public static final String MSG_SUCCESS = "Upload Successful";
- private static final Logger log = LoggerFactory.getLogger(ImageService.class);
+ private static final Logger log = Logger.getLogger(ImageService.class);
- private final Map<String, Image> imageRepository;
-
- public ImageService() {
- imageRepository = new ConcurrentHashMap<>();
- }
+ private final Map<String, ImageData> imageRepository = new ConcurrentHashMap<>();
@Override
- public Image downloadImage(String name) {
- final Image image = imageRepository.get(name);
+ public ImageData downloadImage(String name) {
+ final ImageData image = imageRepository.get(name);
if (image == null) {
throw new IllegalStateException("Image with name " + name + " does not exist.");
}
@@ -49,12 +44,12 @@ public class ImageService implements IImageService {
}
@Override
- public String uploadImage(Image image, String name) {
+ public String uploadImage(ImageData image) {
- log.info("Upload image: " + image + " with name: " + name);
+ log.infof("Upload image: %s", image.getName());
- if (image != null && name != null && !"".equals(name)) {
- imageRepository.put(name, image);
+ if (image.getData() != null && image.getName() != null) {
+ imageRepository.put(image.getName(), image);
return MSG_SUCCESS;
}
throw new IllegalStateException("Illegal Data Format.");
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtTest.java b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtTest.java
index ba52a03771..de6ff4da34 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/CxfSoapMtomAwtTest.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import javax.imageio.ImageIO;
-import io.quarkus.test.junit.DisabledOnIntegrationTest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
@@ -34,7 +33,6 @@ import org.junit.jupiter.params.provider.ValueSource;
@QuarkusTest
class CxfSoapMtomAwtTest {
- @DisabledOnIntegrationTest("https://github.com/apache/camel-quarkus/issues/4208")
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void uploadDownloadMtom(boolean mtomEnabled) throws IOException {
@@ -42,18 +40,15 @@ class CxfSoapMtomAwtTest {
String imageName = "linux-image-name";
RestAssured.given()
.contentType(ContentType.BINARY)
- .queryParam("imageName", imageName)
.queryParam("mtomEnabled", mtomEnabled)
.body(imageBytes)
- .post("/cxf-soap/mtom-awt/upload")
+ .post("/cxf-soap/mtom-awt/image/" + imageName)
.then()
.statusCode(201)
.body(CoreMatchers.equalTo(ImageService.MSG_SUCCESS));
byte[] downloadedImageBytes = RestAssured.given()
- .contentType(ContentType.TEXT)
- .queryParam("imageName", imageName)
.queryParam("mtomEnabled", mtomEnabled)
- .post("/cxf-soap/mtom-awt/download")
+ .get("/cxf-soap/mtom-awt/image/" + imageName)
.then()
.statusCode(201)
.extract().asByteArray();