You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ff...@apache.org on 2022/01/07 19:51:14 UTC
[camel] branch main updated: [CAMEL-17453]MTOM/XOP tests in camel-cxf are broken
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 983e204 [CAMEL-17453]MTOM/XOP tests in camel-cxf are broken
983e204 is described below
commit 983e204b8c538a444befec2425fda9452c972e53
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Fri Jan 7 14:50:39 2022 -0500
[CAMEL-17453]MTOM/XOP tests in camel-cxf are broken
---
.../cxf/mtom/CxfJavaMtomProducerPayloadTest.java | 28 ++++++++++++----------
.../cxf/mtom/CxfMtomConsumerPayloadModeTest.java | 2 --
.../component/cxf/mtom/CxfMtomConsumerTest.java | 16 +++++++++----
3 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfJavaMtomProducerPayloadTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfJavaMtomProducerPayloadTest.java
index a9b0e48..a8ab0e3 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfJavaMtomProducerPayloadTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfJavaMtomProducerPayloadTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.cxf.mtom;
import java.awt.*;
+import java.util.List;
import javax.xml.ws.Holder;
@@ -31,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class CxfJavaMtomProducerPayloadTest extends CxfMtomConsumerTest {
- protected static final String MTOM_ENDPOINT_URI_MTOM_ENABLE = MTOM_ENDPOINT_URI + "&properties.mtom-enabled=true"
+ protected static final String MTOM_ENDPOINT_URI_MTOM_ENABLE = MTOM_ENDPOINT_URI
+ "&defaultOperationName=Detail";
private static final Logger LOG = LoggerFactory.getLogger(CxfJavaMtomProducerPayloadTest.class);
@@ -56,18 +57,19 @@ public class CxfJavaMtomProducerPayloadTest extends CxfMtomConsumerTest {
});
- // Make sure we don't put the attachement into out message
- assertEquals(0, exchange.getOut(AttachmentMessage.class).getAttachments().size(), "The attachement size should be 0");
-
- Object[] result = exchange.getMessage().getBody(Object[].class);
-
- Holder<byte[]> photo1 = (Holder<byte[]>) result[1];
-
- Holder<Image> image1 = (Holder<Image>) result[2];
-
- assertEquals("ResponseFromCamel", new String(photo1.value, "UTF-8"));
- assertNotNull(image1.value);
-
+ AttachmentMessage out = exchange.getOut(AttachmentMessage.class);
+ assertEquals(2, out.getAttachments().size(), "We should get 2 attachements here.");
+ assertEquals("application/xop+xml", out.getHeader("Content-Type"), "Get a wrong Content-Type header");
+ // Get the parameter list
+ List<?> parameter = out.getBody(List.class);
+ // Get the operation name
+ final Holder<byte[]> responsePhoto = (Holder<byte[]>) parameter.get(1);
+ assertNotNull(responsePhoto.value, "The photo should not be null");
+ assertEquals(new String(responsePhoto.value, "UTF-8"),
+ "ResponseFromCamel", "Should get the right response");
+
+ final Holder<Image> responseImage = (Holder<Image>) parameter.get(2);
+ assertNotNull(responseImage.value, "We should get the image here");
}
}
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java
index ed7e26a..3344c70 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java
@@ -77,8 +77,6 @@ public class CxfMtomConsumerPayloadModeTest {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
- assertEquals("application/xop+xml", exchange.getIn().getHeader("Content-Type"),
- "Get a wrong Content-Type header");
List<Source> elements = new ArrayList<>();
elements.add(new DOMSource(StaxUtils.read(new StringReader(getRequestMessage())).getDocumentElement()));
CxfPayload<SoapHeader> body = new CxfPayload<>(
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java
index e4b2ab1..4e86b15 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java
@@ -34,18 +34,23 @@ import org.apache.camel.component.cxf.CXFTestSupport;
import org.apache.camel.cxf.mtom_feature.Hello;
import org.apache.camel.cxf.mtom_feature.HelloService;
import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.ext.logging.LoggingInInterceptor;
+import org.apache.cxf.ext.logging.LoggingOutInterceptor;
+import org.apache.cxf.frontend.ClientProxy;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class CxfMtomConsumerTest extends CamelTestSupport {
protected static final String MTOM_ENDPOINT_ADDRESS = "http://localhost:"
+ CXFTestSupport.getPort1() + "/CxfMtomConsumerTest/jaxws-mtom/hello";
protected static final String MTOM_ENDPOINT_URI = "cxf://" + MTOM_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.cxf.mtom_feature.Hello";
+ + "?serviceClass=org.apache.camel.cxf.mtom_feature.Hello&properties.mtom-enabled=true";
private static final Logger LOG = LoggerFactory.getLogger(CxfMtomConsumerTest.class);
@@ -60,15 +65,15 @@ public class CxfMtomConsumerTest extends CamelTestSupport {
@SuppressWarnings("unchecked")
public void process(final Exchange exchange) throws Exception {
AttachmentMessage in = exchange.getIn(AttachmentMessage.class);
- assertEquals(0, in.getAttachments().size(), "We should not get any attachements here.");
+ assertNull(in.getAttachments(), "We should not get any attachements here.");
assertEquals("application/xop+xml", in.getHeader("Content-Type"), "Get a wrong Content-Type header");
// Get the parameter list
List<?> parameter = in.getBody(List.class);
// Get the operation name
Holder<byte[]> photo = (Holder<byte[]>) parameter.get(0);
assertNotNull(photo.value, "The photo should not be null");
- assertEquals("Should get the right request", new String(photo.value, "UTF-8"),
- "RequestFromCXF");
+ assertEquals(new String(photo.value, "UTF-8"),
+ "RequestFromCXF", "Should get the right request");
photo.value = "ResponseFromCamel".getBytes("UTF-8");
Holder<Image> image = (Holder<Image>) parameter.get(1);
assertNotNull(image.value, "We should get the image here");
@@ -92,6 +97,9 @@ public class CxfMtomConsumerTest extends CamelTestSupport {
((BindingProvider) port).getRequestContext()
.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
MTOM_ENDPOINT_ADDRESS);
+ Client c = ClientProxy.getClient(port);
+ c.getInInterceptors().add(new LoggingInInterceptor());
+ c.getOutInterceptors().add(new LoggingOutInterceptor());
return port;
}