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 2023/05/15 15:09:03 UTC
[camel-quarkus] 01/06: Test CXF client with a method referencing class with runtime initialization #4208 https://github.com/quarkiverse/quarkus-cxf/issues/580
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch 2.13.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 8c01cbd304bbbfac8c659a4870e50128c4945ce8
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue May 9 22:23:24 2023 +0200
Test CXF client with a method referencing class with runtime initialization #4208 https://github.com/quarkiverse/quarkus-cxf/issues/580
---
.../soap/mtom/awt/it/CxfSoapMtomAwtResource.java | 8 ++--
.../cxf/soap/mtom/awt/it/CxfSoapMtomAwtRoutes.java | 13 ++++++
.../cxf/soap/mtom/awt/it/IImageService.java | 6 ++-
.../component/cxf/soap/mtom/awt/it/ImageData.java | 53 ----------------------
.../cxf/soap/mtom/awt/it/ImageService.java | 14 +++---
5 files changed, 28 insertions(+), 66 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 69be8bdf6a..bcd6bb648c 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
@@ -55,7 +55,7 @@ public class CxfSoapMtomAwtResource {
try (ByteArrayInputStream bais = new ByteArrayInputStream(image)) {
final String response = producerTemplate.requestBodyAndHeader(
"direct:" + mtomEndpoint(mtomEnabled),
- new ImageData(ImageIO.read(bais), imageName),
+ new Object[] { ImageIO.read(bais), imageName },
OPERATION_NAME, "uploadImage", String.class);
return Response
.created(new URI("https://camel.apache.org/"))
@@ -68,13 +68,13 @@ public class CxfSoapMtomAwtResource {
@GET
public Response download(@PathParam("imageName") String imageName, @QueryParam("mtomEnabled") boolean mtomEnabled)
throws Exception {
- final ImageData image = (ImageData) producerTemplate.requestBodyAndHeader(
+ final java.awt.Image image = producerTemplate.requestBodyAndHeader(
"direct:" + mtomEndpoint(mtomEnabled),
imageName,
OPERATION_NAME,
- "downloadImage", ImageData.class);
+ "downloadImage", java.awt.Image.class);
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- ImageIO.write((BufferedImage) image.getData(), "png", baos);
+ ImageIO.write((BufferedImage) image, "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 0bb9e318c2..78988487d9 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
@@ -29,6 +29,7 @@ import io.quarkus.runtime.LaunchMode;
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;
@@ -55,6 +56,18 @@ public class CxfSoapMtomAwtRoutes extends RouteBuilder {
.to("direct:processAwtImage");
from("direct:processAwtImage")
+ .process(exchange -> {
+ String operationName = (String) exchange.getIn().getHeaders().get("operationName");
+ MessageContentsList list = exchange.getIn().getBody(MessageContentsList.class);
+ 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));
+ }
+ })
.recipientList((simple("bean:imageAwtService?method=${header.operationName}")));
}
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 6816daae83..cf963420d9 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,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.mtom.awt.it;
+import java.awt.Image;
+
import javax.jws.WebMethod;
import javax.jws.WebService;
@@ -23,9 +25,9 @@ import javax.jws.WebService;
public interface IImageService {
@WebMethod
- ImageData downloadImage(String name);
+ Image downloadImage(String name);
@WebMethod
- String uploadImage(ImageData image);
+ String uploadImage(Image image, String imageName);
}
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/ImageData.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
deleted file mode 100644
index e39a79a9c5..0000000000
--- a/integration-test-groups/cxf-soap/cxf-soap-mtom-awt/src/main/java/org/apache/camel/quarkus/component/cxf/soap/mtom/awt/it/ImageData.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.cxf.soap.mtom.awt.it;
-
-import java.awt.Image;
-
-import javax.xml.bind.annotation.XmlType;
-
-@XmlType(name = "imageData", namespace = "http://org.jboss.ws/xop/doclit")
-public class ImageData {
-
- private Image data;
- private 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 6a213f9732..cd1e6c00b3 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
@@ -32,11 +32,11 @@ public class ImageService implements IImageService {
public static final String MSG_SUCCESS = "Upload Successful";
private static final Logger log = Logger.getLogger(ImageService.class);
- private final Map<String, ImageData> imageRepository = new ConcurrentHashMap<>();
+ private final Map<String, Image> imageRepository = new ConcurrentHashMap<>();
@Override
- public ImageData downloadImage(String name) {
- final ImageData image = imageRepository.get(name);
+ public Image downloadImage(String name) {
+ final Image image = imageRepository.get(name);
if (image == null) {
throw new IllegalStateException("Image with name " + name + " does not exist.");
}
@@ -44,12 +44,12 @@ public class ImageService implements IImageService {
}
@Override
- public String uploadImage(ImageData image) {
+ public String uploadImage(Image image, String imageName) {
- log.infof("Upload image: %s", image.getName());
+ log.infof("Upload image: %s", imageName);
- if (image.getData() != null && image.getName() != null) {
- imageRepository.put(image.getName(), image);
+ if (image != null && imageName != null) {
+ imageRepository.put(imageName, image);
return MSG_SUCCESS;
}
throw new IllegalStateException("Illegal Data Format.");