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 e6ffa3b751 Test CXF client with a method referencing class with
runtime initialization #4208
https://github.com/quarkiverse/quarkus-cxf/issues/580
e6ffa3b751 is described below
commit e6ffa3b751b595dc1e2b73aa71ef31724deffe56
Author: Peter Palaga <[email protected]>
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 0cb3ce26fb..5bc8e6459f 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
@@ -54,7 +54,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/"))
@@ -67,13 +67,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 c26bbc0223..1b16e89d90 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
@@ -28,6 +28,7 @@ import jakarta.xml.ws.handler.Handler;
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;
@@ -54,6 +55,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 c9dcbd3931..cbb13a1c10 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 jakarta.jws.WebMethod;
import jakarta.jws.WebService;
@@ -23,9 +25,9 @@ import jakarta.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 78281881b6..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 jakarta.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 c533d28f28..8d572aaf63 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
@@ -31,11 +31,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.");
}
@@ -43,12 +43,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.");