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/25 18:27:24 UTC
[camel-quarkus] 02/02: Not use awt.* in MTOM test app
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
commit c6d14014193ff39d495e68b1fe4b3c83576e55e7
Author: Lukas Lowinger <ll...@redhat.com>
AuthorDate: Tue Oct 25 09:21:02 2022 +0200
Not use awt.* in MTOM test app
---
.../cxf-soap/cxf-soap-mtom/pom.xml | 4 ---
.../cxf/soap/mtom/it/CxfSoapMtomResource.java | 39 ++++++++--------------
.../component/cxf/soap/mtom/it/IImageService.java | 6 ++--
.../mtom/it/{IImageService.java => ImageFile.java} | 26 ++++++++++-----
.../component/cxf/soap/mtom/it/ImageService.java | 9 +++--
.../cxf/soap/mtom/it/CxfSoapMtomTest.java | 2 --
6 files changed, 37 insertions(+), 49 deletions(-)
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/pom.xml b/integration-test-groups/cxf-soap/cxf-soap-mtom/pom.xml
index 4214e253a0..bb06cef676 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/pom.xml
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/pom.xml
@@ -32,10 +32,6 @@
<description>Integration tests for Camel Quarkus CXF extension Mtom</description>
<dependencies>
- <dependency><!-- for java.awt.Image -->
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-awt</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java
index 4a4b08ed08..405241bc9e 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomResource.java
@@ -16,14 +16,9 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.it;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.net.URI;
import javax.enterprise.context.ApplicationScoped;
-import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
@@ -49,16 +44,14 @@ public class CxfSoapMtomResource {
@Produces(MediaType.TEXT_PLAIN)
public Response upload(@QueryParam("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 },
- OPERATION_NAME, "uploadImage", String.class);
- return Response
- .created(new URI("https://camel.apache.org/"))
- .entity(response)
- .build();
- }
+ final String response = producerTemplate.requestBodyAndHeader(
+ "direct:" + mtomEndpoint(mtomEnabled),
+ new Object[] { new ImageFile(image), imageName },
+ OPERATION_NAME, "uploadImage", String.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(response)
+ .build();
}
@Path("/download")
@@ -66,19 +59,15 @@ public class CxfSoapMtomResource {
@Consumes(MediaType.TEXT_PLAIN)
public Response download(@QueryParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
throws Exception {
- final BufferedImage response = (BufferedImage) producerTemplate.requestBodyAndHeader(
+ final ImageFile response = (ImageFile) producerTemplate.requestBodyAndHeader(
"direct:" + mtomEndpoint(mtomEnabled),
imageName,
OPERATION_NAME,
- "downloadImage", Image.class);
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- ImageIO.write(response, "png", baos);
- byte[] bytes = baos.toByteArray();
- return Response
- .created(new URI("https://camel.apache.org/"))
- .entity(bytes)
- .build();
- }
+ "downloadImage", ImageFile.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(response.getContent())
+ .build();
}
private String mtomEndpoint(boolean mtomEnabled) {
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java
index 3340c2cfbf..9bf9f898df 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.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);
+ ImageFile downloadImage(String name);
@WebMethod
- String uploadImage(Image image, String name);
+ String uploadImage(ImageFile image, String name);
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageFile.java
similarity index 69%
copy from integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java
copy to integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageFile.java
index 3340c2cfbf..c479fbd350 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/IImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageFile.java
@@ -16,18 +16,26 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.it;
-import java.awt.*;
+import javax.xml.bind.annotation.XmlType;
-import javax.jws.WebMethod;
-import javax.jws.WebService;
+@XmlType(name = "imageFile")
+public class ImageFile {
-@WebService
-public interface IImageService {
+ public ImageFile() {
+ }
- @WebMethod
- Image downloadImage(String name);
+ private byte[] content;
- @WebMethod
- String uploadImage(Image image, String name);
+ public ImageFile(byte[] content) {
+ this.content = content;
+ }
+
+ public byte[] getContent() {
+ return this.content;
+ }
+
+ public void setContent(byte[] content) {
+ this.content = content;
+ }
}
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageService.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageService.java
index 93ec42986d..54433237f7 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageService.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/ImageService.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.it;
-import java.awt.*;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -33,15 +32,15 @@ public class ImageService implements IImageService {
public static final String MSG_SUCCESS = "Upload Successful";
private static final Logger log = LoggerFactory.getLogger(ImageService.class);
- private final Map<String, Image> imageRepository;
+ private final Map<String, ImageFile> imageRepository;
public ImageService() {
imageRepository = new ConcurrentHashMap<>();
}
@Override
- public Image downloadImage(String name) {
- final Image image = imageRepository.get(name);
+ public ImageFile downloadImage(String name) {
+ final ImageFile image = imageRepository.get(name);
if (image == null) {
throw new IllegalStateException("Image with name " + name + " does not exist.");
}
@@ -49,7 +48,7 @@ public class ImageService implements IImageService {
}
@Override
- public String uploadImage(Image image, String name) {
+ public String uploadImage(ImageFile image, String name) {
log.info("Upload image: " + image + " with name: " + name);
diff --git a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomTest.java b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomTest.java
index 9fdc27c1f8..01c7249d48 100644
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomTest.java
+++ b/integration-test-groups/cxf-soap/cxf-soap-mtom/src/test/java/org/apache/camel/quarkus/component/cxf/soap/mtom/it/CxfSoapMtomTest.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 CxfSoapMtomTest {
- @DisabledOnIntegrationTest("https://github.com/apache/camel-quarkus/issues/4208")
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void uploadDownloadMtom(boolean mtomEnabled) throws IOException {