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/11/24 13:59:18 UTC
[camel-spring-boot] branch camel-spring-boot-3.19.x updated: Revert "[CAMEL-18729]add more tests in camel-cxf-soap-starter"
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch camel-spring-boot-3.19.x
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/camel-spring-boot-3.19.x by this push:
new 981c57a81c0 Revert "[CAMEL-18729]add more tests in camel-cxf-soap-starter"
981c57a81c0 is described below
commit 981c57a81c0e66f41e061b00d44424964345293b
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Nov 24 08:59:01 2022 -0500
Revert "[CAMEL-18729]add more tests in camel-cxf-soap-starter"
This reverts commit a5b2a7032fcf8126bd34b121fe798fea18af1004.
---
components-starter/camel-cxf-soap-starter/pom.xml | 76 +-
.../ImageService.java => jaxws/HelloService.java} | 25 +-
.../{springxml => }/CXFMultiPartTest.java | 18 +-
.../springboot/CxfComponentEnableMtomTest.java | 145 ---
.../soap/springboot/CxfConsumerMessageTest.java | 32 +-
.../CxfConsumerPayLoadConverterTest.java | 9 +-
.../CxfConsumerPayloadFaultCauseEnabledTest.java | 159 ----
.../soap/springboot/CxfConsumerPayloadTest.java | 38 +-
.../soap/springboot/CxfConsumerProviderTest.java | 16 +-
.../cxf/soap/springboot/CxfEndpointBeanTest.java | 157 ----
.../springboot/CxfMessageHeaderTimeoutTest.java | 167 ----
.../cxf/soap/springboot/CxfNonWrapperTest.java | 142 ---
.../cxf/soap/springboot/CxfOneWayRouteTest.java | 219 -----
.../CxfPayLoadMessageXmlBindingRouterTest.java | 177 ----
.../springboot/CxfPayLoadSoapHeaderSpringTest.java | 213 -----
.../CxfSpringCustomizedExceptionTest.java | 146 ---
.../cxf/soap/springboot/CxfSpringRouterTest.java | 163 ----
.../cxf/soap/springboot/CxfTimeoutTest.java | 266 ------
.../springboot/FileToCxfMessageDataFormatTest.java | 176 ----
.../cxf/soap/springboot/JaxwsTestHandler.java | 82 --
.../LoggingInterceptorInMessageModeTest.java | 209 -----
.../cxf/soap/springboot/MultiPartInvokeImpl.java | 52 ++
.../ImageService.java => ServiceProvider.java} | 27 +-
.../cxf/soap/springboot/SpringBusFactoryTest.java | 70 --
.../{springxml => }/WSSUsernameTokenHandler.java | 2 +-
.../{springxml => }/WSSUsernameTokenTest.java | 10 +-
...ce.java => WriteXmlDeclarationInterceptor.java} | 31 +-
.../converter/PayLoadConvertToPOJOTest.java | 130 ---
.../dispatch/CxfDispatchMessageTest.java | 159 ----
.../dispatch/CxfDispatchPayloadTest.java | 161 ----
.../dispatch/CxfDispatchTestSupport.java | 122 ---
.../dispatch/CxfSoapMessageProviderTest.java | 188 ----
.../greeterroute/AbstractCXFGreeterRouterTest.java | 132 ---
.../greeterroute/CXFGreeterEnrichTest.java | 120 ---
.../greeterroute/CXFGreeterRouterTest.java | 120 ---
.../CxfGreeterCXFMessageRouterTest.java | 113 ---
.../CxfGreeterCXFMessageWithoutSEIRouterTest.java | 118 ---
.../CxfGreeterConverterRouterTest.java | 117 ---
.../CxfGreeterMessageCamelHttpRouterTest.java | 106 ---
.../greeterroute/CxfGreeterMessageRouterTest.java | 113 ---
.../greeterroute/CxfGreeterPayLoadRouterTest.java | 115 ---
.../CxfGreeterPayLoadWithFeatureRouterTest.java | 115 ---
.../greeterroute/CxfGreeterWSDLOnlyRouterTest.java | 113 ---
.../greeterroute/CxfPayloadProviderRouterTest.java | 186 ----
.../springboot/jms/CxfEndpointJMSConsumerTest.java | 127 ---
.../mtom/CxfJavaMtomProducerPayloadTest.java | 104 ---
.../mtom/CxfMtomConsumerMutipleParameterTest.java | 152 ----
.../mtom/CxfMtomConsumerPayloadModeTest.java | 206 -----
.../soap/springboot/mtom/CxfMtomConsumerTest.java | 168 ----
.../CxfMtomDisabledConsumerPayloadModeTest.java | 192 ----
.../CxfMtomDisabledProducerPayloadModeTest.java | 287 ------
.../springboot/mtom/CxfMtomPOJOProducerTest.java | 192 ----
.../mtom/CxfMtomProducerPayloadModeTest.java | 241 -----
.../mtom/CxfMtomRouterCxfMessageModeTest.java | 102 ---
.../mtom/CxfMtomRouterPayloadMode12Test.java | 109 ---
.../mtom/CxfMtomRouterPayloadModeTest.java | 214 -----
.../springboot/mtom/CxfMtomRouterRawModeTest.java | 102 ---
.../cxf/soap/springboot/mtom/MtomTestHelper.java | 102 ---
...dConsumerDuplicateNamespaceStreamCacheTest.java | 70 --
...ConsumerNamespaceOnEnvelopeStreamCacheTest.java | 75 --
.../CxfPayloadConsumerNamespaceOnEnvelopeTest.java | 150 ----
...ProducerNamespaceOnEnvelopeStreamCacheTest.java | 84 --
.../CxfPayloadProducerNamespaceOnEnvelopeTest.java | 151 ----
.../cxf/soap/springboot/noparam/NoParamTest.java | 125 ---
.../soap/headers/CxfMessageHeadersRelayTest.java | 977 ---------------------
.../soap/springboot/ssl/SslBuilderCustomizer.java | 231 -----
.../cxf/soap/springboot/ssl/SslGlobalTest.java | 250 ------
.../component/cxf/soap/springboot/ssl/SslTest.java | 253 ------
.../undertowhandler/AccessLogHandlerTest.java | 188 ----
.../DisallowedMethodsHandlerTest.java | 169 ----
.../RequestLimitingHandlerTest.java | 191 ----
.../springboot/wsa/WSAddressingPAYLOADTest.java | 192 ----
.../cxf/soap/springboot/wsa/WSAddressingTest.java | 189 ----
.../springboot/wsdl/AbstractCxfWsdlFirstTest.java | 169 ----
.../cxf/soap/springboot/wsdl/CXFWsdlOnlyTest.java | 234 -----
.../wsdl/CxfPayloadWsdlWithoutSEITest.java | 168 ----
.../wsdl/CxfWsdlFirstPayloadModeTest.java | 148 ----
.../springboot/wsdl/CxfWsdlFirstProcessorTest.java | 185 ----
.../cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java | 130 ---
.../cxf/soap/springboot/wsdl/OrderTest.java | 156 ----
.../cxf/soap/springboot/wsrm/WSRMTest.java | 193 ----
.../cxf/soap/springboot/wssecurity/CxfServer.java | 18 -
.../springboot/wssecurity/WSSecurityRouteTest.java | 319 -------
.../org/apache/camel/wsdl_first/PersonImpl.java | 41 -
.../src/test/resources/MultiPartTest.wsdl | 56 ++
.../soap/springboot/wssecurity/client/wssec.xml | 129 ---
.../soap/springboot/wssecurity/server/wssec.xml | 151 ----
.../src/test/resources/routes/MultiPartTest.xml | 4 +-
88 files changed, 235 insertions(+), 12514 deletions(-)
diff --git a/components-starter/camel-cxf-soap-starter/pom.xml b/components-starter/camel-cxf-soap-starter/pom.xml
index 8cbf9dee300..35dc287eb24 100644
--- a/components-starter/camel-cxf-soap-starter/pom.xml
+++ b/components-starter/camel-cxf-soap-starter/pom.xml
@@ -57,32 +57,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-cxf-spring-soap</artifactId>
- <version>${camel-version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-cxf-soap</artifactId>
- <version>${camel-version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jaxb</artifactId>
- <version>${camel-version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -105,33 +85,6 @@
<scope>test</scope>
<version>${cxf-version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-ws-rm</artifactId>
- <scope>test</scope>
- <version>${cxf-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-testutils</artifactId>
- <scope>test</scope>
- <version>${cxf-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-jms</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-kahadb-store</artifactId>
- <scope>test</scope>
- </dependency>
<!--START OF GENERATED CODE-->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
@@ -142,10 +95,31 @@
<build>
<plugins>
<plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <rerunFailingTestsCount>0</rerunFailingTestsCount>
- </configuration>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>${cxf-version}</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <fork>${cxf.codegenplugin.forkmode}</fork>
+ <additionalJvmArgs>${cxf.codegen.jvmArgs}</additionalJvmArgs>
+ <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
+ <defaultOptions>
+ <frontEnd>jaxws21</frontEnd>
+ </defaultOptions>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>${basedir}/src/test/resources/MultiPartTest.wsdl</wsdl>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/jaxws/HelloService.java
similarity index 63%
copy from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
copy to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/jaxws/HelloService.java
index 7c0b6f74e1f..2b75b4d1d66 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/jaxws/HelloService.java
@@ -14,20 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.mtom;
+package org.apache.camel.component.cxf.jaxws;
-import java.awt.Image;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.ws.soap.MTOM;
+import java.util.List;
-@WebService(name = "ImageService", targetNamespace = "http://apache.org/camel/cxf/mtom_feature")
-@MTOM
-public interface ImageService {
+public interface HelloService {
+ String sayHello();
- Image downloadImage(@WebParam(name = "name") String name);
+ void ping();
-
- String uploadImage(@WebParam(name = "data") Image data, @WebParam(name = "name") String name);
+ int getInvocationCount();
-}
\ No newline at end of file
+ String echo(String text) throws Exception;
+
+ Boolean echoBoolean(Boolean bool);
+
+ String complexParameters(List<String> par1, List<String> par2);
+
+}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/CXFMultiPartTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CXFMultiPartTest.java
similarity index 86%
rename from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/CXFMultiPartTest.java
rename to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CXFMultiPartTest.java
index a40f4655b8b..de5e711c741 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/CXFMultiPartTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CXFMultiPartTest.java
@@ -14,14 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.springxml;
+package org.apache.camel.component.cxf.soap.springboot;
import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Service;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.multipart.MultiPartInvokeImpl;
import org.apache.camel.cxf.multipart.MultiPartInvoke;
import org.apache.camel.cxf.multipart.types.InE;
import org.apache.camel.cxf.multipart.types.ObjectFactory;
@@ -40,9 +38,7 @@ import org.springframework.context.annotation.ImportResource;
import org.springframework.test.annotation.DirtiesContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-/*
- * This test uses xml beans and camel route definition
- */
+
@DirtiesContext
@CamelSpringBootTest
@SpringBootTest(classes = {
@@ -65,18 +61,15 @@ public class CXFMultiPartTest {
public static final QName ROUTE_PORT_NAME = new QName("http://camel.apache.org/cxf/multipart",
"MultiPartInvokePort");
protected static Endpoint endpoint;
-
- static int backendSerivcePort = CXFTestSupport.getPort1();
- static int servletPort = CXFTestSupport.getPort2();
@Bean
public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(servletPort);
+ return new UndertowServletWebServerFactory();
}
public void startService() {
Object implementor = new MultiPartInvokeImpl();
- String address = "http://localhost:" + backendSerivcePort
+ String address = "http://localhost:16231"
+ "/CXFMultiPartTest/SoapContext/SoapPort";
endpoint = Endpoint.publish(address, implementor);
@@ -92,8 +85,7 @@ public class CXFMultiPartTest {
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
startService();
- String reply = invokeMultiPartService("http://localhost:" + servletPort
- + "/services/CXFMultiPartTest/CamelContext/RouterPort", "in0", "in1");
+ String reply = invokeMultiPartService("http://localhost:8080/services/CXFMultiPartTest/CamelContext/RouterPort", "in0", "in1");
assertNotNull(reply, "No response received from service");
assertEquals("in0 in1", reply);
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfComponentEnableMtomTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfComponentEnableMtomTest.java
deleted file mode 100644
index 0d5c74e5a9f..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfComponentEnableMtomTest.java
+++ /dev/null
@@ -1,145 +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.component.cxf.soap.springboot;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfComponentEnableMtomTest.class,
- CxfComponentEnableMtomTest.TestConfig.class,
- CxfAutoConfiguration.class
-})
-public class CxfComponentEnableMtomTest {
-
- @Autowired
- private CamelContext camelContext;
-
-
- @Test
- public void testIsMtomEnabledEnabledThroughBeanSetter() throws InterruptedException {
- Endpoint endpoint = camelContext.getEndpoint("cxf:bean:mtomByBeanSetter");
-
- if (endpoint instanceof CxfEndpoint) {
- CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
- assertTrue(cxfEndpoint.isMtomEnabled(), "Mtom should be enabled");
- } else {
- fail("CXF Endpoint not found");
- }
- }
-
- @Test
- public void testIsMtomEnabledEnabledThroughBeanProperties() throws InterruptedException {
- Endpoint endpoint = camelContext.getEndpoint("cxf:bean:mtomByBeanProperties");
-
- if (endpoint instanceof CxfEndpoint) {
- CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
- assertTrue(cxfEndpoint.isMtomEnabled(), "Mtom should be enabled");
- } else {
- fail("CXF Endpoint not found");
- }
- }
-
- @Test
- public void testIsMtomEnabledEnabledThroughURIProperties() throws InterruptedException {
- Endpoint endpoint = camelContext.getEndpoint("cxf:bean:mtomByURIProperties?properties.mtom-enabled=true");
-
- if (endpoint instanceof CxfEndpoint) {
- CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
- assertTrue(cxfEndpoint.isMtomEnabled(), "Mtom should be enabled");
- } else {
- fail("CXF Endpoint not found");
- }
- }
-
- @Test
- public void testIsMtomEnabledEnabledThroughQueryParameters() throws InterruptedException {
- Endpoint endpoint = camelContext.getEndpoint("cxf:bean:mtomByQueryParameters?mtomEnabled=true");
-
- if (endpoint instanceof CxfEndpoint) {
- CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
- assertTrue(cxfEndpoint.isMtomEnabled(), "Mtom should be enabled");
- } else {
- fail("CXF Endpoint not found");
- }
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
-
- static class TestConfig {
-
- @Bean("mtomByQueryParameters")
- public CxfEndpoint mtomByQueryParameters(CamelContext context) {
- CxfEndpoint endpoint = new CxfSpringEndpoint();
- return endpoint;
- }
-
- @Bean("mtomByURIProperties")
- public CxfEndpoint mtomByURIProperties() {
- return new CxfSpringEndpoint();
- }
-
- @Bean("mtomByBeanProperties")
- public CxfEndpoint mtomByBeanProperties() {
- CxfEndpoint endpoint = new CxfSpringEndpoint();
- Map<String, Object> properties = new HashMap<>();
- properties.put(Message.MTOM_ENABLED, true);
-
- endpoint.setProperties(properties);
- return endpoint;
-
- }
-
- @Bean("mtomByBeanSetter")
- public CxfEndpoint mtomByBeanSetter() {
- CxfEndpoint endpoint = new CxfSpringEndpoint();
- endpoint.setMtomEnabled(true);
- return endpoint;
-
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerMessageTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerMessageTest.java
index fa7c76f7fb5..71c130ba172 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerMessageTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerMessageTest.java
@@ -23,8 +23,7 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.HelloService;
+import org.apache.camel.component.cxf.jaxws.HelloService;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.junit.jupiter.api.Test;
@@ -55,7 +54,6 @@ import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
CamelAutoConfiguration.class,
CxfConsumerMessageTest.class,
CxfConsumerMessageTest.TestConfiguration.class,
- CxfConsumerMessageTest.ServletConfiguration.class,
CxfAutoConfiguration.class
}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
@@ -64,35 +62,36 @@ public class CxfConsumerMessageTest {
private static final String TEST_MESSAGE = "Hello World!";
- private static final String ECHO_METHOD = "ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\"";
+ private static final String ECHO_METHOD = "ns1:echo xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\"";
private static final String ECHO_RESPONSE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
- + "<soap:Body><ns1:echoResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<return xmlns=\"http://cxf.component.camel.apache.org/\">echo Hello World!</return>"
+ + "<soap:Body><ns1:echoResponse xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">echo Hello World!</return>"
+ "</ns1:echoResponse></soap:Body></soap:Envelope>";
private static final String ECHO_BOOLEAN_RESPONSE
= "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
- + "<soap:Body><ns1:echoBooleanResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<return xmlns=\"http://cxf.component.camel.apache.org/\">true</return>"
+ + "<soap:Body><ns1:echoBooleanResponse xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">true</return>"
+ "</ns1:echoBooleanResponse></soap:Body></soap:Envelope>";
protected final String simpleEndpointAddress = "/" + getClass().getSimpleName() + "-test";
protected final String simpleEndpointURI = "cxf://" + simpleEndpointAddress
- + "?serviceClass=org.apache.camel.component.cxf.HelloService";
+ + "?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService";
- static int port = CXFTestSupport.getPort1();
@Autowired
ProducerTemplate template;
-
+ @Bean
+ public ServletWebServerFactory servletWebServerFactory() {
+ return new UndertowServletWebServerFactory();
+ }
@Test
public void testInvokingServiceFromClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress("http://localhost:" + port
- + "/services" + simpleEndpointAddress);
+ clientBean.setAddress("http://localhost:8080/services" + simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
@@ -143,11 +142,4 @@ public class CxfConsumerMessageTest {
}
}
- @Configuration
- class ServletConfiguration {
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
- }
}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayLoadConverterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayLoadConverterTest.java
index a12ecefd852..4a4f6ce1906 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayLoadConverterTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayLoadConverterTest.java
@@ -32,6 +32,8 @@ import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
+import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
@@ -47,14 +49,17 @@ import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
CamelAutoConfiguration.class,
CxfConsumerPayLoadConverterTest.class,
CxfConsumerPayLoadConverterTest.TestConfiguration.class,
- CxfConsumerMessageTest.ServletConfiguration.class,
CxfAutoConfiguration.class
}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
public class CxfConsumerPayLoadConverterTest extends CxfConsumerPayloadTest {
-
+ @Bean
+ public ServletWebServerFactory servletWebServerFactory() {
+ return new UndertowServletWebServerFactory();
+ }
+
// *************************************
// Config
// *************************************
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadFaultCauseEnabledTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadFaultCauseEnabledTest.java
deleted file mode 100644
index c11463c2630..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadFaultCauseEnabledTest.java
+++ /dev/null
@@ -1,159 +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.component.cxf.soap.springboot;
-
-
-
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPFault;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Holder;
-import javax.xml.ws.soap.SOAPFaultException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.camel.wsdl_first.Person;
-import org.apache.camel.wsdl_first.PersonService;
-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.apache.cxf.interceptor.Fault;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfConsumerPayloadFaultCauseEnabledTest.class,
- CxfConsumerPayloadFaultCauseEnabledTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfConsumerPayloadFaultCauseEnabledTest {
-
- protected static final QName SERVICE_QNAME = new QName("http://camel.apache.org/wsdl-first", "PersonService");
- protected static final QName PORT_QNAME = new QName("http://camel.apache.org/wsdl-first", "soap");
-
- static int port = CXFTestSupport.getPort1();
-
-
- @Test
- public void testInvokingFromCxfClient() throws Exception {
-
- URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
- PersonService ss = new PersonService(wsdlURL, SERVICE_QNAME);
-
- Person client = ss.getSoap();
-
- Client c = ClientProxy.getClient(client);
- c.getInInterceptors().add(new LoggingInInterceptor());
- c.getOutInterceptors().add(new LoggingOutInterceptor());
- ((BindingProvider) client).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port
- + "/services/CxfConsumerPayloadFaultCauseEnabledTest/PersonService");
-
- Holder<String> personId = new Holder<>();
- personId.value = "";
- Holder<String> ssn = new Holder<>();
- Holder<String> name = new Holder<>();
- try {
- client.getPerson(personId, ssn, name);
- fail("SOAPFault expected!");
- } catch (Exception e) {
- assertTrue(e instanceof SOAPFaultException);
- SOAPFault fault = ((SOAPFaultException) e).getFault();
- assertEquals("Someone messed up the service. Caused by: Homer", fault.getFaultString());
- }
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint consumerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/CxfConsumerPayloadFaultCauseEnabledTest/PersonService");
- cxfEndpoint.setWsdlURL("classpath:person.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("exceptionMessageCauseEnabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:consumerEndpoint").process(new Processor() {
- public void process(final Exchange exchange) throws Exception {
- Throwable cause = new IllegalArgumentException("Homer");
- Fault fault = new Fault("Someone messed up the service.", (ResourceBundle) null, cause);
- exchange.setException(fault);
- }
- });
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadTest.java
index 0bc605e4989..b5a8d89c10a 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerPayloadTest.java
@@ -35,6 +35,8 @@ import org.apache.camel.spring.boot.CamelAutoConfiguration;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
+import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
@@ -45,36 +47,38 @@ import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
@DirtiesContext
@CamelSpringBootTest
@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfConsumerPayloadTest.class,
+ CamelAutoConfiguration.class, CxfConsumerPayloadTest.class,
CxfConsumerPayloadTest.TestConfiguration.class,
- CxfConsumerMessageTest.ServletConfiguration.class,
CxfAutoConfiguration.class
}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CxfConsumerPayloadTest extends CxfConsumerMessageTest {
- protected static final String ECHO_RESPONSE = "<ns1:echoResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<return xmlns=\"http://cxf.component.camel.apache.org/\">echo Hello World!</return>"
+ protected static final String ECHO_RESPONSE = "<ns1:echoResponse xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">echo Hello World!</return>"
+ "</ns1:echoResponse>";
- protected static final String ECHO_BOOLEAN_RESPONSE = "<ns1:echoBooleanResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<return xmlns=\"http://cxf.component.camel.apache.org/\">true</return>"
+ protected static final String ECHO_BOOLEAN_RESPONSE = "<ns1:echoBooleanResponse xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">true</return>"
+ "</ns1:echoBooleanResponse>";
- protected static final String ECHO_REQUEST = "<ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">Hello World!</arg0></ns1:echo>";
- protected static final String ECHO_BOOLEAN_REQUEST = "<ns1:echoBoolean xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
- + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">true</arg0></ns1:echoBoolean>";
+ protected static final String ECHO_REQUEST = "<ns1:echo xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<arg0 xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">Hello World!</arg0></ns1:echo>";
+ protected static final String ECHO_BOOLEAN_REQUEST = "<ns1:echoBoolean xmlns:ns1=\"http://jaxws.cxf.component.camel.apache.org/\">"
+ + "<arg0 xmlns=\"http://jaxws.cxf.component.camel.apache.org/\">true</arg0></ns1:echoBoolean>";
- protected static final String ELEMENT_NAMESPACE = "http://cxf.component.camel.apache.org/";
+ protected static final String ELEMENT_NAMESPACE = "http://jaxws.cxf.component.camel.apache.org/";
-
+ @Bean
+ public ServletWebServerFactory servletWebServerFactory() {
+ return new UndertowServletWebServerFactory();
+ }
+
protected void checkRequest(String expect, String request) {
if (expect.equals("ECHO_REQUEST")) {
- assertTrue(request.startsWith(ECHO_REQUEST.substring(0, 60))
- && request.endsWith(ECHO_REQUEST.substring(61)), "Get a wrong request");
+ assertTrue(request.startsWith(ECHO_REQUEST.substring(0, 66))
+ && request.endsWith(ECHO_REQUEST.substring(67)), "Get a wrong request");
} else {
- assertTrue(request.startsWith(ECHO_BOOLEAN_REQUEST.substring(0, 67))
- && request.endsWith(ECHO_BOOLEAN_REQUEST.substring(68)), "Get a wrong request");
+ assertTrue(request.startsWith(ECHO_BOOLEAN_REQUEST.substring(0, 73))
+ && request.endsWith(ECHO_BOOLEAN_REQUEST.substring(74)), "Get a wrong request");
}
}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerProviderTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerProviderTest.java
index 53b1cb8b8b1..c601b66e0cc 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerProviderTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfConsumerProviderTest.java
@@ -24,7 +24,6 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
import org.apache.camel.converter.jaxp.XmlConverter;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
@@ -70,17 +69,19 @@ public class CxfConsumerProviderTest {
protected final String relativeAddress = "/" + getClass().getSimpleName() + "/test";
- protected final String simpleEndpointAddress = "http://localhost:" + port + "/services"
+ protected final String simpleEndpointAddress = "http://localhost:8080/services"
+ relativeAddress;
protected final String simpleEndpointURI = "cxf://" + relativeAddress
- + "?serviceClass=org.apache.camel.component.cxf.ServiceProvider";
+ + "?serviceClass=org.apache.camel.component.cxf.soap.springboot.ServiceProvider";
- static int port = CXFTestSupport.getPort1();
@Autowired
ProducerTemplate template;
-
+ @Bean
+ public ServletWebServerFactory servletWebServerFactory() {
+ return new UndertowServletWebServerFactory();
+ }
@Test
public void testInvokingServiceFromHttpCompnent() throws Exception {
@@ -109,11 +110,6 @@ public class CxfConsumerProviderTest {
@Configuration
public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
@Bean
public RouteBuilder routeBuilder() {
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfEndpointBeanTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfEndpointBeanTest.java
deleted file mode 100644
index 69da17b4357..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfEndpointBeanTest.java
+++ /dev/null
@@ -1,157 +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.component.cxf.soap.springboot;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.handler.Handler;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.jaxws.CxfProducer;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.Soap12;
-import org.apache.cxf.binding.soap.SoapBindingConfiguration;
-import org.apache.cxf.configuration.security.AuthorizationPolicy;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.transport.http.HTTPConduit;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfEndpointBeanTest.class,
- CxfEndpointBeanTest.TestConfiguration.class
-})
-public class CxfEndpointBeanTest {
-
- private QName serviceName = QName.valueOf("{http://camel.apache.org/wsdl-first}PersonService");
- private QName endpointName = QName.valueOf("{http://camel.apache.org/wsdl-first}soap");
- static int port = CXFTestSupport.getPort1();
- @Autowired
- ApplicationContext ctx;
-
- @Test
- public void testCxfEndpointsWithCamelContext() {
- CamelContext context = ctx.getBean("camelContext", CamelContext.class);
- // try to create a new CxfEndpoint which could override the old bean's setting
- CxfEndpoint myLocalCxfEndpoint = (CxfEndpoint)context
- .getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:" + port + "/services"
- + "/CxfEndpointBeanTest/myCamelContext/");
- assertEquals("http://localhost:" + port + "/services" + "/CxfEndpointBeanTest/myCamelContext/",
- myLocalCxfEndpoint.getAddress(), "Got the wrong endpoint address");
-
- CxfEndpoint routerEndpoint = ctx.getBean("routerEndpoint", CxfEndpoint.class);
- assertEquals("http://localhost:" + port + "/services" + "/CxfEndpointBeanTest/myCamelContext/",
- routerEndpoint.getAddress(), "Got the wrong endpoint address");
- }
-
- @Test
- public void testPropertiesSettingOnCxfClient() throws Exception {
- CxfEndpoint clientEndpoint = ctx.getBean("clientEndpoint", CxfEndpoint.class);
- CxfProducer producer = (CxfProducer) clientEndpoint.createProducer();
- // need to start the producer to get the client
- producer.start();
- Client client = producer.getClient();
- HTTPConduit conduit = (HTTPConduit) client.getConduit();
- assertEquals("test", conduit.getAuthorization().getUserName(), "Got the wrong user name");
- }
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- cxfEndpoint.setAddress("/CxfEndpointBeanTest/router");
- cxfEndpoint.setContinuationTimeout(60000);
- List<String> schemaLocations = new ArrayList<String>();
- schemaLocations.add("classpath:wsdl/Message.xsd");
- cxfEndpoint.setSchemaLocations(schemaLocations);
- List<Handler> handlers = new ArrayList<Handler>();
- handlers.add(new JaxwsTestHandler());
- cxfEndpoint.setHandlers(handlers);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint clientEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
-
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfEndpointBeanTest/helloworld");
-
- Map<String, Object> properties = new HashMap<String, Object>();
- AuthorizationPolicy policy = new AuthorizationPolicy();
- policy.setUserName("test");
- properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy", policy);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint myEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.wsdl_first.Person.class);
- cxfEndpoint.setAddress("/CxfEndpointBeanTest/test");
- cxfEndpoint.setWsdlURL("person.wsdl");
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setLoggingFeatureEnabled(true);
- cxfEndpoint.setLoggingSizeLimit(200);
-
- SoapBindingConfiguration bindingCfg = new SoapBindingConfiguration();
- bindingCfg.setVersion(Soap12.getInstance());
- cxfEndpoint.setBindingConfig(bindingCfg);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start")
- .to("cxf:bean:myEndpoint");
- from("cxf:bean:myEndpoint").to("mock:result");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfMessageHeaderTimeoutTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfMessageHeaderTimeoutTest.java
deleted file mode 100644
index 27dded0c7ae..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfMessageHeaderTimeoutTest.java
+++ /dev/null
@@ -1,167 +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.component.cxf.soap.springboot;
-
-
-
-
-import java.net.SocketTimeoutException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.GreeterImplWithSleep;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
-import org.apache.hello_world_soap_http.Greeter;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfMessageHeaderTimeoutTest.class,
- CxfMessageHeaderTimeoutTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfMessageHeaderTimeoutTest {
-
-
- protected static final String GREET_ME_OPERATION = "greetMe";
- protected static final String TEST_MESSAGE = "Hello World!";
- protected static final String SERVER_ADDRESS
- = "/CxfMessageHeaderTimeoutTest/SoapContext/SoapPort";
-
-
-
- static int port = CXFTestSupport.getPort1();
-
- private Endpoint endpoint;
-
- @BeforeEach
- public void startService() {
- Greeter implementor = new GreeterImplWithSleep();
- endpoint = Endpoint.publish(SERVER_ADDRESS, implementor);
- }
-
- @AfterEach
- public void stopService() {
- endpoint.stop();
- }
-
-
- @Autowired
- ProducerTemplate template;
-
- @Test
- public void testInvokingJaxWsServerWithCxfEndpoint() throws Exception {
- sendTimeOutMessage("cxf://bean:springEndpoint");
- }
-
- protected void sendTimeOutMessage(String endpointUri) throws Exception {
- Exchange reply = sendJaxWsMessage(endpointUri);
- Exception e = reply.getException();
- assertNotNull(e, "We should get the exception cause here");
- assertTrue(e instanceof SocketTimeoutException, "We should get the socket time out exception here");
- }
-
- protected Exchange sendJaxWsMessage(String endpointUri) throws InterruptedException {
- Exchange exchange = template.send(endpointUri, new Processor() {
- public void process(final Exchange exchange) {
- final List<String> params = new ArrayList<>();
- params.add(TEST_MESSAGE);
- exchange.getIn().setBody(params);
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION);
- // setup the receive timeout dynamically
- Map<String, Object> requestContext = new HashMap<>();
- HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
- clientPolicy.setReceiveTimeout(100);
- requestContext.put(HTTPClientPolicy.class.getName(), clientPolicy);
- exchange.getIn().setBody(params);
- exchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
-
- }
- });
- return exchange;
- }
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("direct:start").to("cxf:bean:springEndpoint");
- }
- };
- }
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public CxfEndpoint springEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services" + SERVER_ADDRESS);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- return cxfEndpoint;
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfNonWrapperTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfNonWrapperTest.java
deleted file mode 100644
index f0b6477c12c..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfNonWrapperTest.java
+++ /dev/null
@@ -1,142 +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.component.cxf.soap.springboot;
-
-
-
-
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.non_wrapper.Person;
-import org.apache.camel.non_wrapper.PersonProcessor;
-import org.apache.camel.non_wrapper.PersonService;
-import org.apache.camel.non_wrapper.UnknownPersonFault;
-import org.apache.camel.non_wrapper.types.GetPerson;
-import org.apache.camel.non_wrapper.types.GetPersonResponse;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfNonWrapperTest.class,
- CxfNonWrapperTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfNonWrapperTest {
-
- private static final QName SERVICE_NAME = new QName("http://camel.apache.org/wsdl-first", "PersonService");
- private static final QName PORT_NAME = new QName("http://camel.apache.org/wsdl-first", "soap");
-
-
- static int port = CXFTestSupport.getPort1();
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
-
- URL wsdlURL = getClass().getClassLoader().getResource("person-non-wrapper.wsdl");
- PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/non-wrapper", "PersonService"));
- Person client = ss.getSoap();
- ((BindingProvider) client).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfNonWrapperTest/PersonService/");
-
- GetPerson request = new GetPerson();
- request.setPersonId("hello");
- GetPersonResponse response = client.getPerson(request);
-
- assertEquals("Bonjour", response.getName(), "we should get the right answer from router");
-
- request.setPersonId("");
- try {
- client.getPerson(request);
- fail("We expect to get the UnknowPersonFault here");
- } catch (UnknownPersonFault fault) {
- // We expect to get fault here
- }
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public PersonProcessor personProcessor() {
- return new PersonProcessor();
- }
-
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_NAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_NAME);
- cxfEndpoint.setServiceClass(org.apache.camel.non_wrapper.Person.class);
- cxfEndpoint.setAddress("/CxfNonWrapperTest/PersonService/");
- cxfEndpoint.setDataFormat(DataFormat.POJO);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .process("personProcessor");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfOneWayRouteTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfOneWayRouteTest.java
deleted file mode 100644
index b80190cea7e..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfOneWayRouteTest.java
+++ /dev/null
@@ -1,219 +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.component.cxf.soap.springboot;
-
-
-
-
-import java.io.ByteArrayOutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.jaxws.DefaultCxfBinding;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spi.Synchronization;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.Greeter;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfOneWayRouteTest.class,
- CxfOneWayRouteTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfOneWayRouteTest {
-
- private static final QName SERVICE_NAME = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
- private static final QName PORT_NAME = new QName("http://apache.org/hello_world_soap_http", "SoapPort");
- private static final String ROUTER_ADDRESS = "/CxfOneWayRouteTest/router";
-
- private static Exception bindingException;
- private static boolean bindingDone;
- private static boolean onCompeletedCalled;
-
- static int port = CXFTestSupport.getPort1();
-
- @BeforeEach
- public void setup() {
- bindingException = null;
- bindingDone = false;
- onCompeletedCalled = false;
- }
-
-
- protected Greeter getCXFClient() throws Exception {
- Service service = Service.create(SERVICE_NAME);
- service.addPort(PORT_NAME, "http://schemas.xmlsoap.org/soap/",
- "http://localhost:" + port
- + "/services" + ROUTER_ADDRESS);
- Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
- return greeter;
- }
-
-
-
- @EndpointInject("mock:result")
- MockEndpoint mock;
-
-
- @Bean
- TestProcessor testProcessor() {
- return new TestProcessor();
- }
-
- @Test
- public void testInvokingOneWayServiceFromCXFClient() throws Exception {
- mock.expectedMessageCount(1);
- mock.expectedFileExists("target/camel-file/cxf-oneway-route");
-
- Greeter client = getCXFClient();
- client.greetMeOneWay("lemac");
-
- // may need to wait until the oneway call completes
- long waitUntil = System.currentTimeMillis() + 10000;
- while (!bindingDone && System.currentTimeMillis() < waitUntil) {
- Thread.sleep(1000);
- }
-
- mock.assertIsSatisfied();
- assertTrue(onCompeletedCalled, "UnitOfWork done should be called");
- assertNull(bindingException, "exception occured: " + bindingException);
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_NAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_NAME);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress(ROUTER_ADDRESS);
- cxfEndpoint.getInInterceptors().add(new org.apache.cxf.ext.logging.LoggingInInterceptor());
- cxfEndpoint.getOutInterceptors().add(new org.apache.cxf.ext.logging.LoggingOutInterceptor());
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("org.apache.cxf.oneway.robust", true);
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setCxfBinding(new TestCxfBinding());
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .to("log:org.apache.camel?level=DEBUG")
- .to("bean:testProcessor")
- .to("file://target/camel-file/cxf-oneway-route")
- .to("mock:result");
- }
- };
- }
- }
-
- public static class TestProcessor implements Processor {
- static final byte[] MAGIC = { (byte) 0xca, 0x3e, 0x1e };
-
- @Override
- public void process(Exchange exchange) throws Exception {
- // just check the MEP here
- assertEquals(ExchangePattern.InOnly, exchange.getPattern(), "Don't get the right MEP");
- // adding some binary segment
- String msg = exchange.getIn().getBody(String.class);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write(MAGIC);
- bos.write(msg.getBytes());
- exchange.getIn().setBody(bos.toByteArray());
- // add compliation
- exchange.getUnitOfWork().addSynchronization(new Synchronization() {
- @Override
- public void onComplete(Exchange exchange) {
- onCompeletedCalled = true;
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- // do nothing here
- }
- });
- }
- }
-
- public static class TestCxfBinding extends DefaultCxfBinding {
-
- @Override
- public void populateCxfResponseFromExchange(Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange) {
- try {
- super.populateCxfResponseFromExchange(camelExchange, cxfExchange);
- } catch (RuntimeException e) {
- bindingException = e;
- throw e;
- } finally {
- bindingDone = true;
- }
- }
-
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadMessageXmlBindingRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadMessageXmlBindingRouterTest.java
deleted file mode 100644
index 7b716842d80..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadMessageXmlBindingRouterTest.java
+++ /dev/null
@@ -1,177 +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.component.cxf.soap.springboot;
-
-import java.util.List;
-
-import javax.xml.transform.Source;
-
-import org.w3c.dom.Element;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.HelloService;
-import org.apache.camel.component.cxf.HelloServiceImpl;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfPayLoadMessageXmlBindingRouterTest.class,
- CxfPayLoadMessageXmlBindingRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfPayLoadMessageXmlBindingRouterTest {
-
- protected static final String ROUTER_ADDRESS = "/CxfPayLoadMessageXmlBindingRouterTest/router";
- protected static final String SERVICE_ADDRESS = "/CxfPayLoadMessageXmlBindingRouterTest/helloworld";
-
- protected static String getBindingId() {
- return "http://cxf.apache.org/bindings/xformat";
- }
-
- static int port = CXFTestSupport.getPort1();;
-
- @BeforeEach
- public void startService() {
- //start a service
- ServerFactoryBean svrBean = new ServerFactoryBean();
-
- svrBean.setAddress(SERVICE_ADDRESS);
- svrBean.setServiceClass(HelloService.class);
- svrBean.setServiceBean(new HelloServiceImpl());
- svrBean.setBindingId(getBindingId());
- Server server = svrBean.create();
- server.start();
- }
-
-
-
- protected HelloService getCXFClient() throws Exception {
- ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
- ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress("http://localhost:" + port
- + "/services" + ROUTER_ADDRESS);
- clientBean.setServiceClass(HelloService.class);
- clientBean.setBindingId(getBindingId());
-
- HelloService client = (HelloService) proxyFactory.create();
- return client;
- }
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
- HelloService client = getCXFClient();
- String result = client.echo("hello world");
- assertEquals("echo hello world", result, "we should get the right answer from router");
-
- int count = client.getInvocationCount();
- client.ping();
- //oneway ping invoked, so invocationCount ++
- assertEquals(client.getInvocationCount(), ++count, "The ping should be invocated");
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() throws InterruptedException {
- ServletWebServerFactory webServerFactory = new UndertowServletWebServerFactory(port);
- return webServerFactory;
- }
-
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- cxfEndpoint.setAddress(ROUTER_ADDRESS);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setBindingId(getBindingId());
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
-
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- cxfEndpoint.setAddress("http://localhost:"
- + port + "/services" + SERVICE_ADDRESS);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setBindingId(getBindingId());
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("cxf:bean:routerEndpoint").process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
- List<Source> elements = payload.getBodySources();
- assertNotNull(elements, "We should get the elements here");
- assertEquals(1, elements.size(), "Get the wrong elements size");
-
- Element el = new XmlConverter().toDOMElement(elements.get(0));
- assertEquals("http://cxf.component.camel.apache.org/", el.getNamespaceURI(),
- "Get the wrong namespace URI");
- }
-
- })
- .to("cxf:bean:serviceEndpoint");
-
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadSoapHeaderSpringTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadSoapHeaderSpringTest.java
deleted file mode 100644
index 7fa13457755..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfPayLoadSoapHeaderSpringTest.java
+++ /dev/null
@@ -1,213 +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.component.cxf.soap.springboot;
-
-
-
-
-
-import java.net.URL;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Endpoint;
-
-import org.w3c.dom.Element;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.PizzaImpl;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.pizza.Pizza;
-import org.apache.camel.pizza.PizzaService;
-import org.apache.camel.pizza.types.CallerIDHeaderType;
-import org.apache.camel.pizza.types.OrderPizzaResponseType;
-import org.apache.camel.pizza.types.OrderPizzaType;
-import org.apache.camel.pizza.types.ToppingsListType;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.headers.Header;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfPayLoadSoapHeaderSpringTest.class,
- CxfPayLoadSoapHeaderSpringTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfPayLoadSoapHeaderSpringTest {
-
- private final QName serviceName = new QName("http://camel.apache.org/pizza", "PizzaService");
-
- static int port = CXFTestSupport.getPort1();
-
- protected void start(String n) {
- Object implementor = new PizzaImpl();
- String address = "/" + n
- + "/new_pizza_service/services/PizzaService";
- Endpoint.publish(address, implementor);
- }
-
- @BeforeEach
- public void startService() {
- start(getClass().getSimpleName());
- }
-
-
-
- @Test
- public void testPizzaService() {
- Pizza port = getPort();
-
- OrderPizzaType req = new OrderPizzaType();
- ToppingsListType t = new ToppingsListType();
- t.getTopping().add("test");
- req.setToppings(t);
-
- CallerIDHeaderType header = new CallerIDHeaderType();
- header.setName("Willem");
- header.setPhoneNumber("108");
-
- OrderPizzaResponseType res = port.orderPizza(req, header);
-
- assertEquals(208, res.getMinutesUntilReady());
- }
-
- private Pizza getPort() {
- URL wsdl = getClass().getResource("/pizza_service.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- PizzaService service = new PizzaService(wsdl, serviceName);
- assertNotNull(service, "Service is null");
-
- Pizza pizza = service.getPizzaPort();
- ((BindingProvider) pizza).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/" + getClass().getSimpleName()
- + "/pizza_service/services/PizzaService");
- return pizza;
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setWsdlURL("pizza_service.wsdl");
- cxfEndpoint.setAddress("/" + "CxfPayLoadSoapHeaderSpringTest"
- + "/pizza_service/services/PizzaService");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setWsdlURL("pizza_service.wsdl");
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services/" + "CxfPayLoadSoapHeaderSpringTest"
- + "/new_pizza_service/services/PizzaService");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- // START SNIPPET: payload
- from("cxf:bean:routerEndpoint").process(new Processor() {
- @SuppressWarnings("unchecked")
- public void process(Exchange exchange) throws Exception {
- CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
- List<Source> elements = payload.getBodySources();
- assertNotNull(elements, "We should get the elements here");
- assertEquals(1, elements.size(), "Get the wrong elements size");
-
- Element el = new XmlConverter().toDOMElement(elements.get(0));
- elements.set(0, new DOMSource(el));
- assertEquals("http://camel.apache.org/pizza/types",
- el.getNamespaceURI(), "Get the wrong namespace URI");
-
- List<SoapHeader> headers = payload.getHeaders();
- assertNotNull(headers, "We should get the headers here");
- assertEquals(1, headers.size(), "Get the wrong headers size");
- assertEquals("http://camel.apache.org/pizza/types",
- ((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
- // alternatively you can also get the SOAP header via the camel header:
- headers = exchange.getIn().getHeader(Header.HEADER_LIST, List.class);
- assertNotNull(headers, "We should get the headers here");
- assertEquals(1, headers.size(), "Get the wrong headers size");
- assertEquals("http://camel.apache.org/pizza/types",
- ((Element) (headers.get(0).getObject())).getNamespaceURI(), "Get the wrong namespace URI");
-
- }
-
- })
- .to("cxf:bean:serviceEndpoint");
- // END SNIPPET: payload
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringCustomizedExceptionTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringCustomizedExceptionTest.java
deleted file mode 100644
index 7c00b156e9d..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringCustomizedExceptionTest.java
+++ /dev/null
@@ -1,146 +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.component.cxf.soap.springboot;
-
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapFault;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfSpringCustomizedExceptionTest.class,
- CxfSpringCustomizedExceptionTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfSpringCustomizedExceptionTest {
-
- private static final String EXCEPTION_MESSAGE = "This is an exception test message";
- private static final String DETAIL_TEXT = "This is a detail text node";
- private static final SoapFault SOAP_FAULT;
- static int port = CXFTestSupport.getPort1();
-
- static {
- // START SNIPPET: FaultDefine
- SOAP_FAULT = new SoapFault(EXCEPTION_MESSAGE, Fault.FAULT_CODE_CLIENT);
- Element detail = SOAP_FAULT.getOrCreateDetail();
- Document doc = detail.getOwnerDocument();
- Text tn = doc.createTextNode(DETAIL_TEXT);
- detail.appendChild(tn);
- // END SNIPPET: FaultDefine
- }
-
-
-
- @Bean
- private CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services/CxfSpringCustomizedExceptionTest/router");
- return cxfEndpoint;
- }
-
- @Autowired
- ProducerTemplate template;
-
- @Test
- public void testInvokingServiceFromCamel() throws Exception {
- try {
- template.sendBodyAndHeader("direct:start", ExchangePattern.InOut, "hello world", CxfConstants.OPERATION_NAME,
- "echo");
- fail("Should have thrown an exception");
- } catch (Exception ex) {
- Throwable result = ex.getCause();
- assertTrue(result instanceof SoapFault, "Exception is not instance of SoapFault");
- assertEquals(DETAIL_TEXT, ((SoapFault) result).getDetail().getTextContent(), "Expect to get right detail message");
- assertEquals("{http://schemas.xmlsoap.org/soap/envelope/}Client", ((SoapFault) result).getFaultCode().toString(),
- "Expect to get right fault-code");
- }
-
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- cxfEndpoint.setAddress("/CxfSpringCustomizedExceptionTest/router");
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start")
- .to("cxf:bean:serviceEndpoint");
- from("cxf:bean:routerEndpoint").process(new Processor() {
- public void process(final Exchange exchange) {
- exchange.getMessage().setBody(SOAP_FAULT);
- }
- }).to("log:mylog");
-
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringRouterTest.java
deleted file mode 100644
index 3c53764ff9e..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfSpringRouterTest.java
+++ /dev/null
@@ -1,163 +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.component.cxf.soap.springboot;
-
-
-
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.HelloService;
-import org.apache.camel.component.cxf.HelloServiceImpl;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfSpringRouterTest.class,
- CxfSpringRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfSpringRouterTest {
-
- protected Server server;
-
- static int port = CXFTestSupport.getPort1();
-
- @BeforeEach
- public void startService() {
- //start a service
- ServerFactoryBean svrBean = new ServerFactoryBean();
-
- svrBean.setAddress("/CxfSpringRouterTest/helloworld");
- svrBean.setServiceClass(HelloService.class);
- svrBean.setServiceBean(new HelloServiceImpl());
- server = svrBean.create();
- server.start();
- }
-
- @AfterEach
- public void shutdownService() {
- if (server != null) {
- server.stop();
- }
- }
-
-
-
-
- @Bean
- private CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(HelloService.class);
- cxfEndpoint.setAddress("/CxfSpringRouterTest/router");
- return cxfEndpoint;
- }
-
- @Bean
- private CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(HelloService.class);
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services/CxfSpringRouterTest/helloworld");
- return cxfEndpoint;
- }
-
- protected HelloService getCXFClient() throws Exception {
- ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
- ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress("http://localhost:" + port
- + "/services/CxfSpringRouterTest/router");
- clientBean.setServiceClass(HelloService.class);
-
- HelloService client = (HelloService) proxyFactory.create();
- return client;
- }
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
- HelloService client = getCXFClient();
- String result = client.echo("hello world");
- assertEquals("echo hello world", result, "we should get the right answer from router");
-
- }
-
- @Test
- public void testOnwayInvocation() throws Exception {
- HelloService client = getCXFClient();
- int count = client.getInvocationCount();
- client.ping();
- //oneway ping invoked, so invocationCount ++
- assertEquals(client.getInvocationCount(), ++count, "The ping should be invocated");
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint").to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfTimeoutTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfTimeoutTest.java
deleted file mode 100644
index 747cf58b95a..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfTimeoutTest.java
+++ /dev/null
@@ -1,266 +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.component.cxf.soap.springboot;
-
-import java.net.SocketTimeoutException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.GreeterImplWithSleep;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfConfigurer;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.support.jsse.KeyManagersParameters;
-import org.apache.camel.support.jsse.KeyStoreParameters;
-import org.apache.camel.support.jsse.SSLContextParameters;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.transport.http.HTTPConduit;
-import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
-import org.apache.hello_world_soap_http.Greeter;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class, CxfTimeoutTest.class,
- CxfTimeoutTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfTimeoutTest {
-
-
- static int port = CXFTestSupport.getPort1();;
-
- protected static final String GREET_ME_OPERATION = "greetMe";
- protected static final String TEST_MESSAGE = "Hello World!";
- protected static final String SERVER_ADDRESS = "/CxfTimeoutTest/SoapContext/SoapPort";
- protected static final String JAXWS_SERVER_ADDRESS
- = "http://localhost:" + port + "/services/CxfTimeoutTest/SoapContext/SoapPort";
-
- private Endpoint endpoint;
- @BeforeEach
- public void startService() {
- Greeter implementor = new GreeterImplWithSleep();
- endpoint = Endpoint.publish(SERVER_ADDRESS, implementor);
- }
-
- @AfterEach
- public void stopService() {
- endpoint.stop();
- }
-
-
-
- @Test
- public void testInvokingJaxWsServerWithBusUriParams() throws Exception {
- sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + "?serviceClass=org.apache.hello_world_soap_http.Greeter&bus=#cxf&cxfConfigurer=#origConfigurer");
- }
-
- @Test
- public void testInvokingJaxWsServerWithoutBusUriParams() throws Exception {
- sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + "?serviceClass=org.apache.hello_world_soap_http.Greeter&cxfConfigurer=#origConfigurer");
- }
-
- @Test
- public void testInvokingJaxWsServerWithCxfEndpoint() throws Exception {
- sendTimeOutMessage("cxf://bean:springEndpoint");
- }
-
- @Test
- public void testInvokingFromCamelRoute() throws Exception {
- sendTimeOutMessage("direct:start");
- }
-
- @Test
- public void testDoCatchWithTimeOutException() throws Exception {
- sendTimeOutMessage("direct:doCatch");
- }
-
- protected void sendTimeOutMessage(String endpointUri) throws Exception {
- Exchange reply = sendJaxWsMessage(endpointUri);
- Exception e = reply.getException();
- assertNotNull(e, "We should get the exception cause here");
- assertTrue(e instanceof SocketTimeoutException, "We should get the socket time out exception here");
- }
-
- @Autowired
- ProducerTemplate template;
- protected Exchange sendJaxWsMessage(String endpointUri) throws InterruptedException {
- Exchange exchange = template.send(endpointUri, new Processor() {
- public void process(final Exchange exchange) {
- final List<String> params = new ArrayList<>();
- params.add(TEST_MESSAGE);
- exchange.getIn().setBody(params);
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION);
- }
- });
- return exchange;
- }
-
- public static class MyCxfConfigurer implements CxfConfigurer {
-
- @Override
- public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
- // Do nothing here
- }
-
- @Override
- public void configureClient(Client client) {
- // reset the timeout option to override the spring configuration one
- HTTPConduit conduit = (HTTPConduit) client.getConduit();
- HTTPClientPolicy policy = new HTTPClientPolicy();
- policy.setReceiveTimeout(60000);
- conduit.setClient(policy);
-
- }
-
- @Override
- public void configureServer(Server server) {
- // Do nothing here
-
- }
-
- }
-
- public static class OrigCxfConfigurer implements CxfConfigurer {
-
- @Override
- public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
- // Do nothing here
- }
-
- @Override
- public void configureClient(Client client) {
- // reset the timeout option to override the spring configuration one
- HTTPConduit conduit = (HTTPConduit) client.getConduit();
- HTTPClientPolicy policy = new HTTPClientPolicy();
- policy.setReceiveTimeout(100);
- conduit.setClient(policy);
-
- }
-
- @Override
- public void configureServer(Server server) {
- // Do nothing here
-
- }
-
- }
-
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- HostnameVerifier defaultHostnameVerifier() {
- return new org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifier();
- }
-
- @Bean
- MyCxfConfigurer myConfigurer() {
- return new MyCxfConfigurer();
- }
-
- @Bean
- OrigCxfConfigurer origConfigurer() {
- return new OrigCxfConfigurer();
- }
-
- @Bean
- SSLContextParameters mySslContext() {
- SSLContextParameters sslContext = new SSLContextParameters();
- KeyManagersParameters keyManager = new KeyManagersParameters();
- keyManager.setKeyPassword("changeit");
- KeyStoreParameters keyStore = new KeyStoreParameters();
- keyStore.setPassword("changeit");
- keyStore.setResource("/localhost.p12");
- keyManager.setKeyStore(keyStore);
- sslContext.setKeyManagers(keyManager);
- return sslContext;
- }
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() throws InterruptedException {
- ServletWebServerFactory webServerFactory = new UndertowServletWebServerFactory(port);
- return webServerFactory;
- }
-
-
- @Bean
- CxfEndpoint springEndpoint() {
-
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress(JAXWS_SERVER_ADDRESS);
- cxfEndpoint.setCxfConfigurer(new OrigCxfConfigurer());
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("direct:start").
- to("cxf:bean:springEndpoint?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier");
- from("direct:doCatch").
- to("cxf:bean:springEndpoint");
-
-
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/FileToCxfMessageDataFormatTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/FileToCxfMessageDataFormatTest.java
deleted file mode 100644
index 24a6e4e40cd..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/FileToCxfMessageDataFormatTest.java
+++ /dev/null
@@ -1,176 +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.component.cxf.soap.springboot;
-
-
-
-
-import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.HelloService;
-import org.apache.camel.component.cxf.HelloServiceImpl;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- FileToCxfMessageDataFormatTest.class,
- FileToCxfMessageDataFormatTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class FileToCxfMessageDataFormatTest {
-
-
- private static final Logger LOG = LoggerFactory.getLogger(FileToCxfMessageDataFormatTest.class);
-
- private Server server;
-
- static int port = CXFTestSupport.getPort1();
-
- @BeforeEach
- public void setUp() throws Exception {
- deleteDirectory("target/filetocxf");
-
- // set CXF
- ServerFactoryBean factory = new ServerFactoryBean();
-
- factory.setAddress("/FileToCxfMessageDataFormatTest/router");
- factory.setServiceClass(HelloService.class);
- factory.setServiceBean(new HelloServiceImpl());
-
- server = factory.create();
- server.start();
-
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- server.stop();
- server.destroy();
- }
-
-
-
-
- @EndpointInject("mock:result")
- MockEndpoint mock;
-
- @Autowired
- ProducerTemplate template;
-
- @Test
- public void testFileToCxfMessageDataFormat() throws Exception {
-
- mock.expectedMessageCount(1);
-
- template.sendBodyAndHeader("file:target/filetocxf", createBody(), Exchange.FILE_NAME, "payload.xml");
-
- mock.assertIsSatisfied();
-
- String out = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
- assertNotNull(out);
- LOG.info("Reply payload as a String:\n" + out);
- assertTrue(out.contains("echo Camel"), "Should invoke the echo operation");
- }
-
- private String createBody() throws Exception {
- return "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cxf=\"http://cxf.component.camel.apache.org/\">\n"
- + " <soapenv:Header/>\n"
- + " <soapenv:Body>\n"
- + " <cxf:echo>\n"
- + " <cxf:arg0>Camel</cxf:arg0>\n"
- + " </cxf:echo>\n"
- + " </soapenv:Body>\n"
- + "</soapenv:Envelope>";
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services" + "/FileToCxfMessageDataFormatTest/router");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("file:target/filetocxf")
- .to("log:request")
- .to(ExchangePattern.InOut, "routerEndpoint")
- .to("log:reply")
- .to("mock:result");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/JaxwsTestHandler.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/JaxwsTestHandler.java
deleted file mode 100644
index 38e78a882fc..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/JaxwsTestHandler.java
+++ /dev/null
@@ -1,82 +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.component.cxf.soap.springboot;
-
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-public class JaxwsTestHandler implements SOAPHandler<SOAPMessageContext> {
-
- private int faultCount;
- private int messageCount;
- private int getHeadersCount;
-
- public JaxwsTestHandler() {
- }
-
- public int getGetHeadersCount() {
- return getHeadersCount;
- }
-
- @Override
- public Set<QName> getHeaders() {
- getHeadersCount++;
- return null;
- }
-
- @Override
- public void close(MessageContext messagecontext) {
-
- }
-
- @Override
- public boolean handleFault(SOAPMessageContext messagecontext) {
- faultCount++;
- return true;
- }
-
- @Override
- public boolean handleMessage(SOAPMessageContext messagecontext) {
- messageCount++;
- return true;
- }
-
- public void reset() {
- faultCount = 0;
- messageCount = 0;
- getHeadersCount = 0;
- }
-
- public int getFaultCount() {
- return faultCount;
- }
-
- public int getMessageCount() {
- return messageCount;
- }
-
- @Override
- public String toString() {
- return "faultCount=" + faultCount + ", messageCount="
- + messageCount + ", getHeadersCount=" + getHeadersCount;
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/LoggingInterceptorInMessageModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/LoggingInterceptorInMessageModeTest.java
deleted file mode 100644
index 90fbfc7348d..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/LoggingInterceptorInMessageModeTest.java
+++ /dev/null
@@ -1,209 +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.component.cxf.soap.springboot;
-
-
-
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.HelloService;
-import org.apache.camel.component.cxf.HelloServiceImpl;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.interceptor.LoggingOutInterceptor;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- LoggingInterceptorInMessageModeTest.class,
- LoggingInterceptorInMessageModeTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class LoggingInterceptorInMessageModeTest {
-
-
- protected static final String ROUTER_ADDRESS = "/LoggingInterceptorInMessageModeTest/router";
- protected static final String SERVICE_ADDRESS
- = "/LoggingInterceptorInMessageModeTest/helloworld";
-
- static Server server;
-
-
- static int port = CXFTestSupport.getPort1();
-
-
- @BeforeEach
- public void startService() {
- //start a service
- ServerFactoryBean svrBean = new ServerFactoryBean();
-
- svrBean.setAddress(SERVICE_ADDRESS);
- svrBean.setServiceClass(HelloService.class);
- svrBean.setServiceBean(new HelloServiceImpl());
-
- server = svrBean.create();
- }
-
- @AfterEach
- public void stopService() {
- server.stop();
- server.destroy();
- }
-
-
- @Autowired
- protected CamelContext context;
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
-
- LoggingOutInterceptor logInterceptor = null;
-
- for (Interceptor<?> interceptor : context.getEndpoint("cxf:bean:serviceEndpoint", CxfSpringEndpoint.class)
- .getOutInterceptors()) {
- if (interceptor instanceof LoggingOutInterceptor) {
- logInterceptor = LoggingOutInterceptor.class.cast(interceptor);
- break;
- }
- }
-
- assertNotNull(logInterceptor);
- // StringPrintWriter writer = new StringPrintWriter();
- // Unfortunately, LoggingOutInterceptor does not have a setter for writer so
- // we can't capture the output to verify.
- // logInterceptor.setPrintWriter(writer);
-
- ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
- ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress("http://localhost:" + port
- + "/services" + ROUTER_ADDRESS);
- clientBean.setServiceClass(HelloService.class);
-
- HelloService client = (HelloService) proxyFactory.create();
-
- String result = client.echo("hello world");
- assertEquals("echo hello world", result, "we should get the right answer from router");
-
- }
-
- @SuppressWarnings("unused")
- private static final class StringPrintWriter extends PrintWriter {
- private StringPrintWriter() {
- super(new StringWriter());
- }
-
- private StringPrintWriter(int initialSize) {
- super(new StringWriter(initialSize));
- }
-
- private String getString() {
- flush();
- return ((StringWriter) out).toString();
- }
- }
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint").to("cxf:bean:serviceEndpoint");
- }
- };
- }
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress(ROUTER_ADDRESS);
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "RAW");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- public CxfEndpoint serviceEndpoint(LoggingOutInterceptor loggingOutInterceptor) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services" + SERVICE_ADDRESS);
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.HelloService.class);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "RAW");
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.getOutInterceptors().add(loggingOutInterceptor);
- return cxfEndpoint;
- }
-
-
- @Bean
- public LoggingOutInterceptor loggingOutInterceptor() {
- LoggingOutInterceptor logger = new LoggingOutInterceptor("write");
- return logger;
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/MultiPartInvokeImpl.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/MultiPartInvokeImpl.java
new file mode 100644
index 00000000000..d64a58c9c59
--- /dev/null
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/MultiPartInvokeImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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.component.cxf.soap.springboot;
+
+import javax.xml.ws.Holder;
+
+import org.apache.camel.cxf.multipart.MultiPartInvoke;
+import org.apache.camel.cxf.multipart.types.InE;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@javax.jws.WebService(
+ serviceName = "MultiPartInvokeService",
+ portName = "MultiPartInvokePort",
+ targetNamespace = "http://adapter.ti.tongtech.com/ws",
+ endpointInterface = "org.apache.camel.cxf.multipart.MultiPartInvoke")
+
+public class MultiPartInvokeImpl implements MultiPartInvoke {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MultiPartInvokeImpl.class);
+
+ @Override
+ public void foo(InE in, InE in1, Holder<InE> out, Holder<InE> out1) {
+ LOG.info("Executing operation foo");
+ LOG.info("{}", in);
+ LOG.info("{}", in1);
+ try {
+ InE outValue = in;
+ out.value = outValue;
+ InE out1Value = in1;
+ out1.value = out1Value;
+ } catch (Exception ex) {
+ LOG.warn("I/O error: {}", ex.getMessage(), ex);
+ throw new RuntimeException(ex);
+ }
+ }
+
+}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ServiceProvider.java
similarity index 62%
copy from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
copy to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ServiceProvider.java
index 7c0b6f74e1f..897eaaf503c 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ServiceProvider.java
@@ -14,20 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.mtom;
+package org.apache.camel.component.cxf.soap.springboot;
-import java.awt.Image;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.ws.soap.MTOM;
+import javax.xml.transform.Source;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
-@WebService(name = "ImageService", targetNamespace = "http://apache.org/camel/cxf/mtom_feature")
-@MTOM
-public interface ImageService {
+@WebServiceProvider
+@ServiceMode(Mode.PAYLOAD)
+public class ServiceProvider implements Provider<Source> {
- Image downloadImage(@WebParam(name = "name") String name);
+ @Override
+ public Source invoke(Source m) {
+ throw new UnsupportedOperationException("Place holder method");
+ }
-
- String uploadImage(@WebParam(name = "data") Image data, @WebParam(name = "name") String name);
-
-}
\ No newline at end of file
+}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/SpringBusFactoryTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/SpringBusFactoryTest.java
deleted file mode 100644
index 697d8361658..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/SpringBusFactoryTest.java
+++ /dev/null
@@ -1,70 +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.component.cxf.soap.springboot;
-
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.Bus;
-import org.apache.cxf.binding.soap.SoapBindingFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- SpringBusFactoryTest.class,
-
-})
-public class SpringBusFactoryTest {
- @Autowired
- ApplicationContext ctx;
-
- @Bean
- Bus cxfBus() {
- SpringBusFactory bf = new SpringBusFactory();
- return bf.createBus("META-INF/cxf/cxf.xml", false);
- }
-
- @Bean
- Bus myBus() {
- SpringBusFactory bf = new SpringBusFactory();
- return bf.createBus("META-INF/cxf/cxf.xml", true);
- }
-
- @Test
- public void getTheBusInstance() {
- Bus bus = ctx.getBean("cxfBus", Bus.class);
- assertNotNull(bus, "The bus should not be null");
-
- bus = ctx.getBean("myBus", Bus.class);
- assertNotNull(bus, "The bus should not be null");
-
- SoapBindingFactory soapBindingFactory = bus.getExtension(SoapBindingFactory.class);
- assertNotNull(soapBindingFactory, "You should find the factory here");
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenHandler.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenHandler.java
similarity index 97%
rename from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenHandler.java
rename to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenHandler.java
index 9c34b4118f9..e5a1bfa36e7 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenHandler.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenHandler.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.springxml;
+package org.apache.camel.component.cxf.soap.springboot;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenTest.java
similarity index 93%
rename from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenTest.java
rename to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenTest.java
index ac4b823488b..cd7fc129933 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/springxml/WSSUsernameTokenTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WSSUsernameTokenTest.java
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.springxml;
+package org.apache.camel.component.cxf.soap.springboot;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
import org.apache.camel.component.cxf.security.GreetingService;
import org.apache.camel.component.cxf.security.jaas.SimpleLoginModule;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
@@ -61,13 +60,10 @@ public class WSSUsernameTokenTest {
private static final String BAD_PASSWORD = "123";
private static final URL WSDL_URL;
-
- static int port = CXFTestSupport.getPort1();
static {
try {
- WSDL_URL = new URL("http://localhost:" + port
- + "/services/greeting-service?wsdl");
+ WSDL_URL = new URL("http://localhost:8080/services/greeting-service?wsdl");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
@@ -78,7 +74,7 @@ public class WSSUsernameTokenTest {
@Bean
public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
+ return new UndertowServletWebServerFactory();
}
private void addWSSUsernameTokenHandler(Service service, final String username, final String password) {
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WriteXmlDeclarationInterceptor.java
similarity index 52%
rename from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
rename to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WriteXmlDeclarationInterceptor.java
index 7c0b6f74e1f..b166016bb8d 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/ImageService.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/WriteXmlDeclarationInterceptor.java
@@ -14,20 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.cxf.soap.springboot.mtom;
+package org.apache.camel.component.cxf.soap.springboot;
-import java.awt.Image;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.xml.ws.soap.MTOM;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
-@WebService(name = "ImageService", targetNamespace = "http://apache.org/camel/cxf/mtom_feature")
-@MTOM
-public interface ImageService {
+//START SNIPPET: example
+public class WriteXmlDeclarationInterceptor extends AbstractPhaseInterceptor<SoapMessage> {
+ public WriteXmlDeclarationInterceptor() {
+ super(Phase.PRE_STREAM);
+ addBefore(StaxOutInterceptor.class.getName());
+ }
- Image downloadImage(@WebParam(name = "name") String name);
+ @Override
+ public void handleMessage(SoapMessage message) throws Fault {
+ message.put("org.apache.cxf.stax.force-start-document", Boolean.TRUE);
+ }
-
- String uploadImage(@WebParam(name = "data") Image data, @WebParam(name = "name") String name);
-
-}
\ No newline at end of file
+}
+//END SNIPPET: example
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/converter/PayLoadConvertToPOJOTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/converter/PayLoadConvertToPOJOTest.java
deleted file mode 100644
index 8ee6f77d530..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/converter/PayLoadConvertToPOJOTest.java
+++ /dev/null
@@ -1,130 +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.component.cxf.soap.springboot.converter;
-
-
-
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.non_wrapper.Person;
-import org.apache.camel.non_wrapper.types.GetPerson;
-import org.apache.camel.non_wrapper.types.GetPersonResponse;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- PayLoadConvertToPOJOTest.class,
- PayLoadConvertToPOJOTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class PayLoadConvertToPOJOTest {
-
-
- static int port = CXFTestSupport.getPort1();
-
- @Test
- public void testClient() throws Exception {
-
- JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
- factory.setAddress("http://localhost:" + port + "/services/"
- + getClass().getSimpleName() + "/CamelContext/RouterPort");
- factory.setServiceClass(Person.class);
- Person person = factory.create(Person.class);
- GetPerson payload = new GetPerson();
- payload.setPersonId("1234");
-
- GetPersonResponse reply = person.getPerson(payload);
- assertEquals("1234", reply.getPersonId(), "Get the wrong person id.");
-
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/PayLoadConvertToPOJOTest/CamelContext/RouterPort");
- cxfEndpoint.setServiceClass(org.apache.camel.non_wrapper.Person.class);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint").streamCaching().process(new Processor() {
-
- @Override
- public void process(Exchange exchange) throws Exception {
- // just try to turn the payload to the parameter we want
- // to use
- GetPerson request = exchange.getIn().getBody(GetPerson.class);
-
- GetPersonResponse reply = new GetPersonResponse();
- reply.setPersonId(request.getPersonId());
- exchange.getMessage().setBody(reply);
- }
-
- });
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchMessageTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchMessageTest.java
deleted file mode 100644
index 1af7b5e57cd..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchMessageTest.java
+++ /dev/null
@@ -1,159 +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.component.cxf.soap.springboot.dispatch;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.w3c.dom.Document;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfDispatchMessageTest.class,
- CxfDispatchMessageTest.TestConfiguration.class,
- CxfDispatchTestSupport.ServletConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfDispatchMessageTest extends CxfDispatchTestSupport {
-
- @Autowired
- ProducerTemplate template;
-
-
-
-
-
- @Test
- public void testDipatchMessage() throws Exception {
- final String name = "Tila";
- Exchange exchange = sendJaxWsDispatchMessage(name, false);
- assertEquals(false, exchange.isFailed(), "The request should be handled sucessfully");
-
- org.apache.camel.Message response = exchange.getMessage();
- assertNotNull(response, "The response message must not be null");
-
- String value = decodeResponseFromMessage(response.getBody(InputStream.class), exchange);
- assertTrue(value.endsWith(name), "The response body must match the request");
- }
-
- @Test
- public void testDipatchMessageOneway() throws Exception {
- final String name = "Tila";
- Exchange exchange = sendJaxWsDispatchMessage(name, true);
- assertEquals(false, exchange.isFailed(), "The request should be handled sucessfully");
-
- org.apache.camel.Message response = exchange.getOut();
- assertNotNull(response, "The response message must not be null");
-
- assertNull(response.getBody(), "The response body must be null");
- }
-
- protected Exchange sendJaxWsDispatchMessage(final String name, final boolean oneway) {
- Exchange exchange = template.send("direct:producer", new Processor() {
- public void process(final Exchange exchange) {
- InputStream request
- = encodeRequestInMessage(oneway ? MESSAGE_ONEWAY_TEMPLATE : MESSAGE_TEMPLATE, name, exchange);
- exchange.getIn().setBody(request, InputStream.class);
- // set the operation for oneway; otherwise use the default operation
- if (oneway) {
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, INVOKE_ONEWAY_NAME);
- }
- }
- });
- return exchange;
- }
-
- private static InputStream encodeRequestInMessage(String form, String name, Exchange exchange) {
- String payloadstr = String.format(form, name);
- InputStream message = null;
- try {
- message = new ByteArrayInputStream(payloadstr.getBytes("utf-8"));
- } catch (Exception e) {
- // ignore and let it fail
- }
- return message;
- }
-
- private String decodeResponseFromMessage(InputStream message, Exchange exchange) {
- String value = null;
- try {
- Document doc = getDocumentBuilderFactory().newDocumentBuilder().parse(message);
- value = getResponseType(doc.getDocumentElement());
- } catch (Exception e) {
- // ignore and let it fail
- }
- return value;
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
-
- cxfEndpoint.setAddress("http://localhost:" + port + "/services"
- + "/CxfDispatchMessageTest/SoapContext/GreeterPort");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- cxfEndpoint.setSynchronous(true);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:producer")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchPayloadTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchPayloadTest.java
deleted file mode 100644
index 08f2b5fe6e9..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchPayloadTest.java
+++ /dev/null
@@ -1,161 +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.component.cxf.soap.springboot.dispatch;
-
-import java.io.ByteArrayInputStream;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.converter.CxfPayloadConverter;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfDispatchPayloadTest.class,
- CxfDispatchPayloadTest.TestConfiguration.class,
- CxfDispatchTestSupport.ServletConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfDispatchPayloadTest extends CxfDispatchTestSupport {
-
- @Autowired
- ProducerTemplate template;
-
-
- @Test
- public void testDispatchPayload() throws Exception {
- final String name = "Tila";
- Exchange exchange = sendJaxWsDispatchPayload(name, false);
- assertEquals(false, exchange.isFailed(), "The request should be handled sucessfully");
-
- org.apache.camel.Message response = exchange.getMessage();
- assertNotNull(response, "The response must not be null");
-
- String value = decodeResponseFromPayload((CxfPayload<?>) response.getBody(CxfPayload.class), exchange);
- assertTrue(value.endsWith(name), "The response must match the request");
- }
-
- @Test
- public void testDispatchPayloadOneway() throws Exception {
- final String name = "Tila";
- Exchange exchange = sendJaxWsDispatchPayload(name, true);
- assertEquals(false, exchange.isFailed(), "The request should be handled sucessfully");
-
- org.apache.camel.Message response = exchange.getOut();
- assertNotNull(response, "The response must not be null");
-
- assertNull(response.getBody(), "The response must be null");
- }
-
- private Exchange sendJaxWsDispatchPayload(final String name, final boolean oneway) {
- Exchange exchange = template.send("direct:producer", new Processor() {
- public void process(final Exchange exchange) {
- CxfPayload<SoapHeader> request = encodeRequestInPayload(oneway ? PAYLOAD_ONEWAY_TEMPLATE : PAYLOAD_TEMPLATE,
- name, exchange);
- exchange.getIn().setBody(request, CxfPayload.class);
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAMESPACE, DISPATCH_NS);
- // set the operation for oneway; otherwise use the default operation
- if (oneway) {
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, INVOKE_ONEWAY_NAME);
- }
- }
- });
- return exchange;
- }
-
- private static <T> CxfPayload<T> encodeRequestInPayload(String form, String name, Exchange exchange) {
- String payloadstr = String.format(form, name);
- CxfPayload<T> payload = null;
- try {
- Document doc = getDocumentBuilderFactory().newDocumentBuilder()
- .parse(new ByteArrayInputStream(payloadstr.getBytes("utf-8")));
- payload = CxfPayloadConverter.documentToCxfPayload(doc, exchange);
- } catch (Exception e) {
- // ignore and let it fail
- }
- return payload;
- }
-
- private <T> String decodeResponseFromPayload(CxfPayload<T> payload, Exchange exchange) {
- String value = null;
- NodeList nodes = CxfPayloadConverter.cxfPayloadToNodeList(payload, exchange);
- if (nodes != null && nodes.getLength() == 1 && nodes.item(0) instanceof Element) {
- value = getResponseType((Element) nodes.item(0));
- }
- return value;
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
-
- cxfEndpoint.setAddress("http://localhost:" + port + "/services"
- + "/CxfDispatchPayloadTest/SoapContext/GreeterPort");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setSynchronous(true);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:producer")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchTestSupport.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchTestSupport.java
deleted file mode 100644
index 86609b0b78e..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfDispatchTestSupport.java
+++ /dev/null
@@ -1,122 +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.component.cxf.soap.springboot.dispatch;
-
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.ws.Endpoint;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfDispatchTestSupport.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public abstract class CxfDispatchTestSupport {
-
-
-
- protected static final String DISPATCH_NS = "http://camel.apache.org/cxf/jaxws/dispatch";
- protected static final String INVOKE_NAME = "Invoke";
- protected static final String INVOKE_ONEWAY_NAME = "InvokeOneWay";
-
- protected static final String PAYLOAD_TEMPLATE
- = "<ns1:greetMe xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\"><ns1:requestType>%s</ns1:requestType></ns1:greetMe>";
- protected static final String PAYLOAD_ONEWAY_TEMPLATE
- = "<ns1:greetMeOneWay xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\"><ns1:requestType>%s</ns1:requestType></ns1:greetMeOneWay>";
- protected static final String MESSAGE_TEMPLATE
- = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"
- + PAYLOAD_TEMPLATE
- + "</soap:Body></soap:Envelope>";
- protected static final String MESSAGE_ONEWAY_TEMPLATE
- = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"
- + PAYLOAD_ONEWAY_TEMPLATE
- + "</soap:Body></soap:Envelope>";
- private static DocumentBuilderFactory documentBuilderFactory;
-
- static int port = CXFTestSupport.getPort1();
-
- protected Endpoint endpoint;
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- String address = "/"
- + getClass().getSimpleName() + "/SoapContext/GreeterPort";
- endpoint = Endpoint.publish(address, implementor);
- }
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- protected static String getResponseType(Element node) {
- NodeList nodes = node.getElementsByTagNameNS("http://apache.org/hello_world_soap_http/types", "responseType");
- if (nodes != null && nodes.getLength() == 1) {
- Node c = nodes.item(0).getFirstChild();
- if (c != null) {
- return c.getNodeValue();
- }
- }
- return null;
- }
-
- protected static synchronized DocumentBuilderFactory getDocumentBuilderFactory() {
- if (documentBuilderFactory == null) {
- documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- documentBuilderFactory.setIgnoringElementContentWhitespace(true);
- documentBuilderFactory.setIgnoringComments(true);
- }
- return documentBuilderFactory;
- }
-
- @Configuration
- class ServletConfiguration {
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfSoapMessageProviderTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfSoapMessageProviderTest.java
deleted file mode 100644
index cd05b630ac9..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/dispatch/CxfSoapMessageProviderTest.java
+++ /dev/null
@@ -1,188 +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.component.cxf.soap.springboot.dispatch;
-
-
-
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.handler.Handler;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.ParameterProcessor;
-import org.apache.camel.component.cxf.SoapTargetBean;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.wsdl_first.JaxwsTestHandler;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.Greeter;
-import org.apache.hello_world_soap_http.SOAPService;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfSoapMessageProviderTest.class,
- CxfSoapMessageProviderTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfSoapMessageProviderTest {
-
-
-
- static int port = CXFTestSupport.getPort1();
-
-
-
- @Test
- public void testSOAPMessageModeDocLit() throws Exception {
- JaxwsTestHandler fromHandler = getMandatoryBean(JaxwsTestHandler.class, "fromEndpointJaxwsHandler");
- fromHandler.reset();
-
- QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPProviderService");
- QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapProviderPort");
-
- URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
- assertNotNull(wsdl);
-
- SOAPService service = new SOAPService(wsdl, serviceName);
- assertNotNull(service);
-
- String response1 = new String("TestSOAPOutputPMessage");
- String response2 = new String("Bonjour");
- try {
- Greeter greeter = service.getPort(portName, Greeter.class);
- ((BindingProvider) greeter).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
- for (int idx = 0; idx < 2; idx++) {
- String greeting = greeter.greetMe("Milestone-" + idx);
- assertNotNull(greeting, "no response received from service");
- assertEquals(response1, greeting);
-
- String reply = greeter.sayHi();
- assertNotNull(reply, "no response received from service");
- assertEquals(response2, reply);
- }
- } catch (UndeclaredThrowableException ex) {
- throw (Exception) ex.getCause();
- }
-
- assertEquals(8, fromHandler.getMessageCount(), "Can't get the right message count");
- assertEquals(0, fromHandler.getFaultCount(), "Can't get the right fault count");
-
- }
-
- @Autowired
- AbstractApplicationContext applicationContext;
-
- private <T> T getMandatoryBean(Class<T> type, String name) {
- Object value = applicationContext.getBean(name);
- assertNotNull(value, "No spring bean found for name <" + name + ">");
- if (type.isInstance(value)) {
- return type.cast(value);
- } else {
- fail("Spring bean <" + name + "> is not an instanceof " + type.getName() + " but is of type "
- + ObjectHelper.className(value));
- return null;
- }
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public SoapTargetBean targetBean() {
- return new SoapTargetBean();
- }
-
- @Bean
- public ParameterProcessor parameterProcessor() {
- return new ParameterProcessor();
- }
-
- @Bean
- public JaxwsTestHandler fromEndpointJaxwsHandler() {
- return new JaxwsTestHandler();
- }
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint soapMessageEndpoint(JaxwsTestHandler fromEndpointJaxwsHandler) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.SoapMessageProvider.class);
- cxfEndpoint.setAddress("/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort");
- List<Handler> handlers = new ArrayList<Handler>();
- handlers.add(fromEndpointJaxwsHandler);
- cxfEndpoint.setHandlers(handlers);
- return cxfEndpoint;
- }
-
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:soapMessageEndpoint")
- .process("parameterProcessor")
- .to("bean:targetBean?method=invokeSoapMessage");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/AbstractCXFGreeterRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/AbstractCXFGreeterRouterTest.java
deleted file mode 100644
index 85babddb697..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/AbstractCXFGreeterRouterTest.java
+++ /dev/null
@@ -1,132 +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.component.cxf.soap.springboot.greeterroute;
-
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.http.base.HttpOperationFailedException;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.Greeter;
-import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- AbstractCXFGreeterRouterTest.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public abstract class AbstractCXFGreeterRouterTest {
-
-
- private final String testDocLitFaultBody = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
- + "<soap:Body><testDocLitFault xmlns=\"http://apache.org/hello_world_soap_http/types\">"
- + "<faultType>NoSuchCodeLitFault</faultType></testDocLitFault>"
- + "</soap:Body></soap:Envelope>";
-
- protected String routerAddress = "http://localhost:" + port + "/services/"
- + getClass().getSimpleName() + "/CamelContext/RouterPort";
-
- protected final QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPService");
- protected final QName routerPortName = new QName("http://apache.org/hello_world_soap_http", "RouterPort");
- protected final QName endpointName = new QName("http://apache.org/hello_world_soap_http", "SoapPort");
-
- static int port = CXFTestSupport.getPort1();
-
- @Autowired
- ProducerTemplate template;
-
-
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
- Service service = Service.create(serviceName);
- service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/",
- routerAddress);
- Greeter greeter = service.getPort(routerPortName, Greeter.class);
-
- String reply = greeter.greetMe("test");
- assertNotNull(reply, "No response received from service");
- assertEquals("Hello test", reply, "Got the wrong reply");
- reply = greeter.sayHi();
- assertNotNull(reply, "No response received from service");
- assertEquals("Bonjour", reply, "Got the wrong reply");
-
- greeter.greetMeOneWay("call greetMe OneWay !");
-
- // test throw the exception
- try {
- greeter.testDocLitFault("NoSuchCodeLitFault");
- // should get the exception here
- fail("Should get the NoSuchCodeLitFault here.");
- } catch (NoSuchCodeLitFault fault) {
- // expect the fault here
- assertNotNull(fault.getFaultInfo(), "The fault info should not be null");
- }
-
- }
-
- @Test
- public void testRoutingSOAPFault() {
- Exception ex = assertThrows(RuntimeCamelException.class,
- () -> template.sendBody(routerAddress, testDocLitFaultBody));
-
- assertTrue(ex.getCause() instanceof HttpOperationFailedException, "It should get the response error");
- assertEquals(500, ((HttpOperationFailedException) ex.getCause()).getStatusCode(),
- "Get a wrong response code");
- }
-
- @Test
- public void testPublishEndpointUrl() throws Exception {
- String response = template.requestBody(routerAddress
- + "?wsdl",
- null, String.class);
- assertTrue(response.indexOf("http://www.simple.com/services/test") > 0, "Can't find the right service location.");
- }
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterEnrichTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterEnrichTest.java
deleted file mode 100644
index 8e07c18b1c9..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterEnrichTest.java
+++ /dev/null
@@ -1,120 +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.component.cxf.soap.springboot.greeterroute;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.WriteXmlDeclarationInterceptor;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CXFGreeterEnrichTest.class,
- CXFGreeterEnrichTest.TestConfiguration.class,
- CxfAutoConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CXFGreeterEnrichTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CXFGreeterEnrichTest/SoapContext/SoapPort";
- protected Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CXFGreeterEnrichTest/CamelContext/RouterPort");
- cxfEndpoint.setSkipFaultLogging(true);
- //This interceptor will force the CXF server send the XML start document to client
- cxfEndpoint.getOutInterceptors().
- add(new WriteXmlDeclarationInterceptor());
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("publishedEndpointUrl", "http://www.simple.com/services/test");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("cxf:bean:routerEndpoint")
- .enrich().simple("ref:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterRouterTest.java
deleted file mode 100644
index 2b4bbca1988..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CXFGreeterRouterTest.java
+++ /dev/null
@@ -1,120 +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.component.cxf.soap.springboot.greeterroute;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.WriteXmlDeclarationInterceptor;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CXFGreeterRouterTest.class,
- CXFGreeterRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CXFGreeterRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CXFGreeterRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CXFGreeterRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setSkipFaultLogging(true);
- //This interceptor will force the CXF server send the XML start document to client
- cxfEndpoint.getOutInterceptors().
- add(new WriteXmlDeclarationInterceptor());
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("publishedEndpointUrl", "http://www.simple.com/services/test");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageRouterTest.java
deleted file mode 100644
index f032ad1d1be..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageRouterTest.java
+++ /dev/null
@@ -1,113 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterCXFMessageRouterTest.class,
- CxfGreeterCXFMessageRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterCXFMessageRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterCXFMessageRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CxfGreeterCXFMessageRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setLoggingFeatureEnabled(true);
- cxfEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageWithoutSEIRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageWithoutSEIRouterTest.java
deleted file mode 100644
index 685833f86b3..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterCXFMessageWithoutSEIRouterTest.java
+++ /dev/null
@@ -1,118 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterCXFMessageWithoutSEIRouterTest.class,
- CxfGreeterCXFMessageWithoutSEIRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterCXFMessageWithoutSEIRouterTest extends CxfGreeterCXFMessageRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterCXFMessageWithoutSEIRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setAddress("/CxfGreeterCXFMessageWithoutSEIRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setLoggingFeatureEnabled(true);
- cxfEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
-
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
-
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterConverterRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterConverterRouterTest.java
deleted file mode 100644
index ef28b0b29d2..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterConverterRouterTest.java
+++ /dev/null
@@ -1,117 +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.component.cxf.soap.springboot.greeterroute;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterConverterRouterTest.class,
- CxfGreeterConverterRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterConverterRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterConverterRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("/CxfGreeterConverterRouterTest/CamelContext/RouterPort");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("publishedEndpointUrl", "http://www.simple.com/services/test");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageCamelHttpRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageCamelHttpRouterTest.java
deleted file mode 100644
index c6a73377c43..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageCamelHttpRouterTest.java
+++ /dev/null
@@ -1,106 +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.component.cxf.soap.springboot.greeterroute;
-
-
-import javax.xml.ws.Endpoint;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfGreeterMessageCamelHttpRouterTest.class,
- CxfGreeterMessageCamelHttpRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfGreeterMessageCamelHttpRouterTest extends CxfGreeterMessageRouterTest {
-
- protected static Endpoint endpoint;
- protected static String serverAddress = "http://localhost:" + port + "/services"
- + "/CxfGreeterMessageCamelHttpRouterTest/SoapContext/SoapPort";
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- String address = "/CxfGreeterMessageCamelHttpRouterTest/SoapContext/SoapPort";
- endpoint = Endpoint.publish(address, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CxfGreeterMessageCamelHttpRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .removeHeaders("CamelHttp*")
- .to(serverAddress + "?throwExceptionOnFailure=false");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageRouterTest.java
deleted file mode 100644
index 4c1833ab9b5..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterMessageRouterTest.java
+++ /dev/null
@@ -1,113 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterMessageRouterTest.class,
- CxfGreeterMessageRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterMessageRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterMessageRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CxfGreeterMessageRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setLoggingFeatureEnabled(true);
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadRouterTest.java
deleted file mode 100644
index 77888e53eaf..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadRouterTest.java
+++ /dev/null
@@ -1,115 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterPayLoadRouterTest.class,
- CxfGreeterPayLoadRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterPayLoadRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterPayLoadRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CxfGreeterPayLoadRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setLoggingFeatureEnabled(true);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .to("cxf://http://localhost:" + port + "/services" + backServiceAddress
- + "?wsdlURL=testutils/hello_world.wsdl"
- + "&dataFormat=PAYLOAD&serviceClass=org.apache.hello_world_soap_http.Greeter");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadWithFeatureRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadWithFeatureRouterTest.java
deleted file mode 100644
index cd409f5c118..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterPayLoadWithFeatureRouterTest.java
+++ /dev/null
@@ -1,115 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.TestCxfFeature;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterPayLoadWithFeatureRouterTest.class,
- CxfGreeterPayLoadWithFeatureRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterPayLoadWithFeatureRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterPayLoadWithFeatureRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.GreeterImpl.class);
- cxfEndpoint.setAddress("/CxfGreeterPayLoadWithFeatureRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.getFeatures().add(new TestCxfFeature());
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- errorHandler(noErrorHandler());
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterWSDLOnlyRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterWSDLOnlyRouterTest.java
deleted file mode 100644
index f17f3910089..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfGreeterWSDLOnlyRouterTest.java
+++ /dev/null
@@ -1,113 +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.component.cxf.soap.springboot.greeterroute;
-
-import javax.xml.ws.Endpoint;
-
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfGreeterWSDLOnlyRouterTest.class,
- CxfGreeterWSDLOnlyRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfGreeterWSDLOnlyRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfGreeterWSDLOnlyRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
-
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- Object implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/CxfGreeterWSDLOnlyRouterTest/CamelContext/RouterPort");
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setPublishedEndpointUrl("http://www.simple.com/services/test");
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setWsdlURL("testutils/hello_world.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfPayloadProviderRouterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfPayloadProviderRouterTest.java
deleted file mode 100644
index 5cca137bdb3..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/greeterroute/CxfPayloadProviderRouterTest.java
+++ /dev/null
@@ -1,186 +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.component.cxf.soap.springboot.greeterroute;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Service;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.Greeter;
-import org.apache.hello_world_soap_http.GreeterImpl;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfPayloadProviderRouterTest.class,
- CxfPayloadProviderRouterTest.TestConfiguration.class,
- AbstractCXFGreeterRouterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfPayloadProviderRouterTest extends AbstractCXFGreeterRouterTest {
-
- private static String backServiceAddress = "/CxfPayloadProviderRouterTest/SoapContext/SoapPort";
- protected static Endpoint endpoint;
- protected static GreeterImpl implementor;
-
-
- @AfterEach
- public void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @BeforeEach
- public void startService() {
- implementor = new GreeterImpl();
- endpoint = Endpoint.publish(backServiceAddress, implementor);
- }
-
- @Override
- @Test
- public void testPublishEndpointUrl() throws Exception {
- final String path = getClass().getSimpleName() + "/CamelContext/RouterPort/" + getClass().getSimpleName();
- String response = template.requestBody("http://localhost:" + port + "/services/" + path
- + "?wsdl",
- null, String.class);
- assertTrue(response.indexOf(path) > 0, "Can't find the right service location.");
- }
-
- @Test
- public void testInvokeGreetMeOverProvider() throws Exception {
- Service service = Service.create(serviceName);
- service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/",
- "http://localhost:" + port + "/services/"
- + getClass().getSimpleName()
- + "/CamelContext/RouterPort");
- Greeter greeter = service.getPort(routerPortName, Greeter.class);
- org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(greeter);
- VerifyInboundInterceptor icp = new VerifyInboundInterceptor();
- client.getInInterceptors().add(icp);
-
- int ic = implementor.getInvocationCount();
-
- icp.setCalled(false);
- String reply = greeter.greetMe("test");
- assertEquals("Hello test", reply, "Got the wrong reply");
- assertTrue(icp.isCalled(), "No Inbound message received");
- assertEquals(++ic, implementor.getInvocationCount(), "The target service not invoked");
-
- icp.setCalled(false);
- greeter.greetMeOneWay("call greetMe OneWay !");
- assertFalse(icp.isCalled(), "An unnecessary inbound message");
- // wait a few seconds for the async oneway service to be invoked
- Thread.sleep(3000);
- assertEquals(++ic, implementor.getInvocationCount(), "The target service not invoked");
- }
-
- static class VerifyInboundInterceptor extends AbstractPhaseInterceptor<Message> {
- private boolean called;
-
- VerifyInboundInterceptor() {
- super(Phase.USER_PROTOCOL);
- }
-
- @Override
- public void handleMessage(Message message) throws Fault {
- called = true;
- }
-
- public boolean isCalled() {
- return called;
- }
-
- public void setCalled(boolean b) {
- called = b;
- }
-
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/CxfPayloadProviderRouterTest/CamelContext/RouterPort");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("jaxws.provider.interpretNullAsOneway", true);
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setSynchronous(true);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port + "/services" + backServiceAddress);
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- cxfEndpoint.setSynchronous(true);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint")
- .setHeader("operationNamespace", constant("http://camel.apache.org/cxf/jaxws/dispatch"))
- .setHeader("operationName", constant("Invoke"))
- .to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/jms/CxfEndpointJMSConsumerTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/jms/CxfEndpointJMSConsumerTest.java
deleted file mode 100644
index 832e6c1fcd5..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/jms/CxfEndpointJMSConsumerTest.java
+++ /dev/null
@@ -1,127 +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.component.cxf.soap.springboot.jms;
-
-
-
-
-import javax.xml.namespace.QName;
-
-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.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.hello_world_soap_http.Greeter;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfEndpointJMSConsumerTest.class,
- CxfEndpointJMSConsumerTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }
-)
-public class CxfEndpointJMSConsumerTest {
-
- private String namespace = "http://apache.org/hello_world_soap_http";
- private QName serviceName = new QName(namespace, "SOAPService");
- private QName endpointName = new QName(namespace, "SoapPort");
- // Here we just the address with JMS URI
- String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue"
- + "?jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
- + "vm://localhost";
-
-
-
- @Test
- public void testInvocation() {
- // Here we just the address with JMS URI
- String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue"
- + "?jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
- + "vm://localhost";
-
- JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
- factory.setServiceClass(Greeter.class);
- factory.setAddress(address);
- Greeter greeter = factory.create(Greeter.class);
- String response = greeter.greetMe("Camel");
- assertEquals("Hello Camel", response, "Get a wrong response");
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- CxfEndpoint jmsEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setEndpointNameAsQName(endpointName);
- cxfEndpoint.setServiceClass(org.apache.hello_world_soap_http.Greeter.class);
- cxfEndpoint.setAddress(address);
- cxfEndpoint.getInInterceptors().add(new org.apache.cxf.ext.logging.LoggingInInterceptor());
- cxfEndpoint.getOutInterceptors().add(new org.apache.cxf.ext.logging.LoggingOutInterceptor());
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:jmsEndpoint").process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- // just set the response for greetme operation here
- String me = exchange.getIn().getBody(String.class);
- exchange.getMessage().setBody("Hello " + me);
- }
- });
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfJavaMtomProducerPayloadTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfJavaMtomProducerPayloadTest.java
deleted file mode 100644
index e95ec0609dc..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfJavaMtomProducerPayloadTest.java
+++ /dev/null
@@ -1,104 +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.component.cxf.soap.springboot.mtom;
-
-import java.awt.Image;
-import java.util.List;
-
-import javax.xml.ws.Holder;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class, CxfJavaMtomProducerPayloadTest.class,
- CxfAutoConfiguration.class,
- CxfMtomConsumerTest.TestConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfJavaMtomProducerPayloadTest extends CxfMtomConsumerTest {
- protected String MTOM_ENDPOINT_URI_MTOM_ENABLE = "cxf://http://localhost:" + port + "/services"
- + MTOM_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.cxf.mtom_feature.Hello"
- + "&properties.mtom-enabled=true"
- + "&defaultOperationName=Detail";
- private static final Logger LOG = LoggerFactory.getLogger(CxfJavaMtomProducerPayloadTest.class);
-
- @Autowired
- CamelContext context;
-
-
- @Override
- @SuppressWarnings("unchecked")
- @Test
- public void testInvokingService() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- final Holder<byte[]> photo = new Holder<>("RequestFromCXF".getBytes("UTF-8"));
- final Holder<Image> image = new Holder<>(getImage("/java.jpg"));
-
- Exchange exchange = context.createProducerTemplate().send(MTOM_ENDPOINT_URI_MTOM_ENABLE,
- new Processor() {
-
- @Override
- public void process(Exchange exchange)
- throws Exception {
- exchange.getIn()
- .setBody(new Object[] {
- photo,
- image
- });
-
- }
-
- });
-
- AttachmentMessage out = exchange.getMessage(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-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerMutipleParameterTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerMutipleParameterTest.java
deleted file mode 100644
index 601b33881f4..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerMutipleParameterTest.java
+++ /dev/null
@@ -1,152 +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.component.cxf.soap.springboot.mtom;
-
-import java.awt.image.BufferedImage;
-import java.util.List;
-
-import java.awt.Image;
-import javax.imageio.ImageIO;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.soap.SOAPBinding;
-
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.ext.logging.LoggingFeature;
-import org.apache.cxf.frontend.ClientFactoryBean;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomConsumerMutipleParameterTest.class,
- CxfMtomConsumerMutipleParameterTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomConsumerMutipleParameterTest {
-
- protected String MTOM_ENDPOINT_ADDRESS = "/CxfMtomConsumerTest/jaxws-mtom/hello";
- protected String MTOM_ENDPOINT_URI = "cxf://" + MTOM_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.component.cxf.soap.springboot.mtom.ImageService&properties.mtom-enabled=true";
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomConsumerMutipleParameterTest.class);
-
- static int port = CXFTestSupport.getPort1();
-
-
-
-
- private ImageService getPort() {
-
- JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
- ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress("http://localhost:" + port + "/services" + MTOM_ENDPOINT_ADDRESS);
- clientBean.setServiceClass(ImageService.class);
- proxyFactory.getFeatures().add(new LoggingFeature());
- ImageService imageService = (ImageService) proxyFactory.create();
- return imageService;
- }
-
- protected Image getImage(String name) throws Exception {
- return ImageIO.read(getClass().getResource(name));
- }
-
-
- @Test
- public void testInvokingServiceBare() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- Image image = getImage("/java.jpg");
-
- ImageService port = getPort();
-
- SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
- binding.setMTOMEnabled(true);
-
- String ret = port.uploadImage(image, "RequestFromCXF");
-
- assertEquals(ret,
- "RequestFromCXF hello", "Should get the right response");
-
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from(MTOM_ENDPOINT_URI).process(new Processor() {
- public void process(final Exchange exchange) throws Exception {
- AttachmentMessage in = exchange.getIn(AttachmentMessage.class);
- 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
- String name = (String)parameter.get(1);
- assertNotNull(name, "The name should not be null");
- assertEquals(name,
- "RequestFromCXF", "Should get the right request");
- BufferedImage image = (BufferedImage) parameter.get(0);
- assertNotNull(image, "We should get the image here");
- exchange.getMessage().setBody(name + " hello");
-
- }
- });
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerPayloadModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerPayloadModeTest.java
deleted file mode 100644
index 72b053f3edc..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerPayloadModeTest.java
+++ /dev/null
@@ -1,206 +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.component.cxf.soap.springboot.mtom;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.activation.DataHandler;
-import javax.mail.util.ByteArrayDataSource;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.xpath.XPathConstants;
-
-import org.w3c.dom.Element;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.XPathUtils;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomConsumerPayloadModeTest.class,
- CxfMtomConsumerPayloadModeTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomConsumerPayloadModeTest {
-
- private final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- private final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
-
-
-
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomConsumerPayloadModeTest.class);
-
- static int port = CXFTestSupport.getPort1();
-
- @Autowired
- private ProducerTemplate template;
-
- @Test
- public void testConsumer() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- Exchange exchange = template.send("cxf:bean:consumerEndpoint", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- exchange.setPattern(ExchangePattern.InOut);
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(StaxUtils.read(new StringReader(getRequestMessage())).getDocumentElement()));
- CxfPayload<SoapHeader> body = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getIn().setBody(body);
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
- }
- });
- assertEquals(exchange.getIn(AttachmentMessage.class).getAttachments().size(), 2);
- }
-
- protected String getRequestMessage() {
- return MtomTestHelper.REQ_MESSAGE;
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public CxfEndpoint consumerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + getClass().getSimpleName()+ "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", true);
- properties.put("loggingFeatureEnabled", false);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:consumerEndpoint").process(new Processor() {
-
- @SuppressWarnings("unchecked")
- public void process(Exchange exchange) throws Exception {
- CxfPayload<SoapHeader> in = exchange.getIn().getBody(CxfPayload.class);
-
- // verify request
- assertEquals(1, in.getBody().size());
-
- Map<String, String> ns = new HashMap<>();
- ns.put("ns", MtomTestHelper.SERVICE_TYPES_NS);
- ns.put("xop", MtomTestHelper.XOP_NS);
-
- XPathUtils xu = new XPathUtils(ns);
- Element body = new XmlConverter().toDOMElement(in.getBody().get(0));
- Element ele = (Element) xu.getValue("//ns:Detail/ns:photo/xop:Include", body,
- XPathConstants.NODE);
- String photoId = ele.getAttribute("href").substring(4); // skip "cid:"
- assertEquals(MtomTestHelper.REQ_PHOTO_CID, photoId);
-
- ele = (Element) xu.getValue("//ns:Detail/ns:image/xop:Include", body,
- XPathConstants.NODE);
- String imageId = ele.getAttribute("href").substring(4); // skip "cid:"
- assertEquals(MtomTestHelper.REQ_IMAGE_CID, imageId);
-
- DataHandler dr = exchange.getIn(AttachmentMessage.class).getAttachment(photoId);
- assertEquals("application/octet-stream", dr.getContentType());
- assertArrayEquals(MtomTestHelper.REQ_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- dr = exchange.getIn(AttachmentMessage.class).getAttachment(imageId);
- assertEquals("image/jpeg", dr.getContentType());
- assertArrayEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- // create response
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.RESP_MESSAGE)).getDocumentElement()));
- CxfPayload<SoapHeader> sbody = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getIn().setBody(sbody);
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.RESP_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.RESP_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.responseJpeg, "image/jpeg")));
-
- }
- });
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerTest.java
deleted file mode 100644
index 7e9ba5d77ae..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomConsumerTest.java
+++ /dev/null
@@ -1,168 +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.component.cxf.soap.springboot.mtom;
-
-import java.awt.Image;
-import java.net.URL;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Holder;
-import javax.xml.ws.soap.SOAPBinding;
-
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.cxf.mtom_feature.HelloService;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-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.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomConsumerTest.class,
- CxfMtomConsumerTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomConsumerTest {
-
- protected String MTOM_ENDPOINT_ADDRESS = "/CxfMtomConsumerTest/jaxws-mtom/hello";
- protected String MTOM_ENDPOINT_URI = "cxf://" + MTOM_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.cxf.mtom_feature.Hello&properties.mtom-enabled=true";
-
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomConsumerTest.class);
-
- private final QName serviceName = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
-
- static int port = CXFTestSupport.getPort1();
-
-
-
-
- private Hello getPort() {
- URL wsdl = getClass().getResource("/mtom.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- HelloService service = new HelloService(wsdl, serviceName);
- assertNotNull(service, "Service is null");
- Hello hello = service.getHelloPort();
-
- ((BindingProvider) hello).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services" + MTOM_ENDPOINT_ADDRESS);
- Client c = ClientProxy.getClient(hello);
- c.getInInterceptors().add(new LoggingInInterceptor());
- c.getOutInterceptors().add(new LoggingOutInterceptor());
- return hello;
- }
-
- protected Image getImage(String name) throws Exception {
- return ImageIO.read(getClass().getResource(name));
- }
-
- @Test
- public void testInvokingService() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- Holder<byte[]> photo = new Holder<>("RequestFromCXF".getBytes("UTF-8"));
- Holder<Image> image = new Holder<>(getImage("/java.jpg"));
-
- Hello port = getPort();
-
- SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
- binding.setMTOMEnabled(true);
-
- port.detail(photo, image);
-
- assertEquals("ResponseFromCamel", new String(photo.value, "UTF-8"));
- assertNotNull(image.value);
-
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from(MTOM_ENDPOINT_URI).process(new Processor() {
- @SuppressWarnings("unchecked")
- public void process(final Exchange exchange) throws Exception {
- AttachmentMessage in = exchange.getIn(AttachmentMessage.class);
- 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(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");
- // set the holder message back
- exchange.getMessage().setBody(new Object[] { null, photo, image });
-
- }
- });
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledConsumerPayloadModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledConsumerPayloadModeTest.java
deleted file mode 100644
index fd52ce69a74..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledConsumerPayloadModeTest.java
+++ /dev/null
@@ -1,192 +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.component.cxf.soap.springboot.mtom;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.activation.DataHandler;
-import javax.mail.util.ByteArrayDataSource;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.CxfMtomConsumerPayloadModeTest;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Unit test for exercising SOAP with Attachment (SwA) feature of a CxfConsumer in PAYLOAD mode. That is, testing
- * attachment with MTOM optimization off.
- */
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class, CxfMtomDisabledConsumerPayloadModeTest.class,
- CxfMtomDisabledConsumerPayloadModeTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomDisabledConsumerPayloadModeTest {
-
-
- private final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- private final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
-
- static int port = CXFTestSupport.getPort1();
-
-
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomConsumerPayloadModeTest.class);
-
- @Autowired
- private ProducerTemplate template;
-
- @Test
- public void testConsumer() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- template.send("cxf:bean:consumerEndpoint", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- exchange.setPattern(ExchangePattern.InOut);
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(StaxUtils.read(new StringReader(getRequestMessage())).getDocumentElement()));
- CxfPayload<SoapHeader> body = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getIn().setBody(body);
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
- }
- });
- }
-
- protected String getRequestMessage() {
- return MtomTestHelper.MTOM_DISABLED_REQ_MESSAGE;
- }
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- public CxfEndpoint consumerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + getClass().getSimpleName()+ "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", false);
- properties.put("loggingFeatureEnabled", false);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:consumerEndpoint").process(new Processor() {
-
- @SuppressWarnings("unchecked")
- public void process(Exchange exchange) throws Exception {
- CxfPayload<SoapHeader> in = exchange.getIn().getBody(CxfPayload.class);
-
- // verify request
- assertEquals(1, in.getBody().size());
-
- DataHandler dr = exchange.getIn(AttachmentMessage.class).getAttachment(MtomTestHelper.REQ_PHOTO_CID);
- assertEquals("application/octet-stream", dr.getContentType());
- assertArrayEquals(MtomTestHelper.REQ_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- dr = exchange.getIn(AttachmentMessage.class).getAttachment(MtomTestHelper.REQ_IMAGE_CID);
- assertEquals("image/jpeg", dr.getContentType());
- assertArrayEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- // create response
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(
- StaxUtils.read(new StringReader(MtomTestHelper.MTOM_DISABLED_RESP_MESSAGE)).getDocumentElement()));
- CxfPayload<SoapHeader> body = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getMessage().setBody(body);
- exchange.getMessage(AttachmentMessage.class).addAttachment(MtomTestHelper.RESP_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getMessage(AttachmentMessage.class).addAttachment(MtomTestHelper.RESP_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.responseJpeg, "image/jpeg")));
-
- }
- });
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledProducerPayloadModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledProducerPayloadModeTest.java
deleted file mode 100644
index 70e77210e0a..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomDisabledProducerPayloadModeTest.java
+++ /dev/null
@@ -1,287 +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.component.cxf.soap.springboot.mtom;
-
-
-
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.mail.util.ByteArrayDataSource;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Holder;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.soap.SOAPBinding;
-
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.HelloImpl;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.cxf.attachment.AttachmentDataSource;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfMtomDisabledProducerPayloadModeTest.class,
- CxfMtomDisabledProducerPayloadModeTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfMtomDisabledProducerPayloadModeTest {
-
- protected final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- protected final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomDisabledProducerPayloadModeTest.class);
-
- @Autowired
- protected CamelContext context;
- private Endpoint endpoint;
-
- static int port = CXFTestSupport.getPort1();
-
-
-
-
- @BeforeEach
- public void setUp() throws Exception {
- endpoint = Endpoint.publish("/" + getClass().getSimpleName()
- + "/jaxws-mtom/hello",
- getServiceImpl());
- SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
- binding.setMTOMEnabled(isMtomEnabled());
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @Test
- public void testProducer() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- Exchange exchange = context.createProducerTemplate().send("direct:testEndpoint", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- exchange.setPattern(ExchangePattern.InOut);
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(
- StaxUtils.read(new StringReader(MtomTestHelper.MTOM_DISABLED_REQ_MESSAGE)).getDocumentElement()));
- CxfPayload<SoapHeader> body = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getIn().setBody(body);
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
-
- }
-
- });
-
- // process response - verify response attachments
-
- CxfPayload<?> out = exchange.getMessage().getBody(CxfPayload.class);
- assertEquals(1, out.getBody().size());
-
- DataHandler dr = exchange.getMessage(AttachmentMessage.class).getAttachment(MtomTestHelper.RESP_PHOTO_CID);
- assertEquals("application/octet-stream", dr.getContentType());
- assertArrayEquals(MtomTestHelper.RESP_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- dr = exchange.getMessage(AttachmentMessage.class).getAttachment(MtomTestHelper.RESP_IMAGE_CID);
- assertEquals("image/jpeg", dr.getContentType());
-
- BufferedImage image = ImageIO.read(dr.getInputStream());
- assertEquals(560, image.getWidth());
- assertEquals(300, image.getHeight());
-
- }
-
- public static class MyHelloImpl extends HelloImpl implements Hello {
-
- @Resource
- WebServiceContext ctx;
-
- @Override
- public void detail(Holder<byte[]> photo, Holder<Image> image) {
-
- // verify request attachments
- Map<String, DataHandler> map
- = CastUtils.cast((Map<?, ?>) ctx.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
- assertEquals(2, map.size());
-
- DataHandler dh = map.get(MtomTestHelper.REQ_PHOTO_CID);
- assertEquals("application/octet-stream", dh.getContentType());
- byte[] bytes = null;
- try {
- bytes = IOUtils.readBytesFromStream(dh.getInputStream());
- } catch (IOException e) {
- LOG.warn("I/O error reading bytes from stream: {}", e.getMessage(), e);
- }
- assertArrayEquals(MtomTestHelper.REQ_PHOTO_DATA, bytes);
-
- dh = map.get(MtomTestHelper.REQ_IMAGE_CID);
- assertEquals("image/jpeg", dh.getContentType());
-
- BufferedImage bufferedImage = null;
- try {
- bufferedImage = ImageIO.read(dh.getInputStream());
-
- } catch (IOException e) {
- LOG.warn("I/O error reading bytes from stream: {}", e.getMessage(), e);
- }
- assertNotNull(bufferedImage);
- assertEquals(41, bufferedImage.getWidth());
- assertEquals(39, bufferedImage.getHeight());
-
- // add output attachments
- map = CastUtils.cast((Map<?, ?>) ctx.getMessageContext().get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS));
-
- try {
- DataSource ds = new AttachmentDataSource("image/jpeg", getClass().getResourceAsStream("/Splash.jpg"));
- map.put(MtomTestHelper.RESP_IMAGE_CID, new DataHandler(ds));
-
- } catch (Exception e) {
- LOG.warn("I/O error: {}", e.getMessage(), e);
- }
-
- try {
- DataSource ds = new AttachmentDataSource(
- "application/octet-stream",
- new ByteArrayInputStream(MtomTestHelper.RESP_PHOTO_DATA));
- map.put(MtomTestHelper.RESP_PHOTO_CID, new DataHandler(ds));
-
- } catch (Exception e) {
- LOG.warn("I/O error: {}", e.getMessage(), e);
- }
-
- }
- }
-
-
- protected boolean isMtomEnabled() {
- return false;
- }
-
- protected Object getServiceImpl() {
- return new MyHelloImpl();
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
-
- @Bean
- public CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomDisabledProducerPayloadModeTest" + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("loggingFeatureEnabled", false);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:testEndpoint").
- to("cxf:bean:serviceEndpoint?defaultOperationName=Detail");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomPOJOProducerTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomPOJOProducerTest.java
deleted file mode 100644
index cfeaefc6702..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomPOJOProducerTest.java
+++ /dev/null
@@ -1,192 +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.component.cxf.soap.springboot.mtom;
-
-
-
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.imageio.ImageIO;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Holder;
-import javax.xml.ws.soap.SOAPBinding;
-
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.HelloImpl;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfMtomPOJOProducerTest.class,
- CxfMtomPOJOProducerTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfMtomPOJOProducerTest {
-
- protected final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- protected final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomPOJOProducerTest.class);
-
- @Autowired
- protected CamelContext context;
- private Endpoint endpoint;
-
- static int port = CXFTestSupport.getPort1();
-
-
- @BeforeEach
- public void setUp() throws Exception {
- endpoint = Endpoint.publish("/CxfMtomPOJOProducerTest/jaxws-mtom/hello", getImpl());
- SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
- binding.setMTOMEnabled(true);
-
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Test
- public void testInvokingServiceFromCxfProducer() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- final Holder<byte[]> photo = new Holder<>(MtomTestHelper.REQ_PHOTO_DATA);
- final Holder<Image> image = new Holder<>(getImage("/java.jpg"));
-
- Exchange exchange = context.createProducerTemplate().send("direct://testEndpoint", new Processor() {
-
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody(new Object[] { photo, image });
-
- }
-
- });
-
- assertEquals(2, exchange.getMessage(AttachmentMessage.class).getAttachments().size(),
- "The attachement size should be 2");
-
- Object[] result = exchange.getMessage().getBody(Object[].class);
- Holder<byte[]> photo1 = (Holder<byte[]>) result[1];
- assertArrayEquals(MtomTestHelper.RESP_PHOTO_DATA, photo1.value);
- Holder<Image> image1 = (Holder<Image>) result[2];
- assertNotNull(image1.value);
- if (image.value instanceof BufferedImage) {
- assertEquals(560, ((BufferedImage) image1.value).getWidth());
- assertEquals(300, ((BufferedImage) image1.value).getHeight());
- }
-
- }
-
- private Image getImage(String name) throws Exception {
- return ImageIO.read(getClass().getResource(name));
- }
-
- protected Object getImpl() {
- return new HelloImpl();
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
-
- @Bean
- public CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomPOJOProducerTest" + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- cxfEndpoint.setServiceClass(org.apache.camel.cxf.mtom_feature.Hello.class);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("mtom-enabled", true);
- properties.put("loggingFeatureEnabled", false);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:testEndpoint").
- to("cxf:bean:serviceEndpoint?defaultOperationName=Detail");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomProducerPayloadModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomProducerPayloadModeTest.java
deleted file mode 100644
index 48271a55b8f..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomProducerPayloadModeTest.java
+++ /dev/null
@@ -1,241 +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.component.cxf.soap.springboot.mtom;
-
-
-
-
-import java.awt.image.BufferedImage;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.activation.DataHandler;
-import javax.imageio.ImageIO;
-import javax.mail.util.ByteArrayDataSource;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.soap.SOAPBinding;
-import javax.xml.xpath.XPathConstants;
-
-import org.w3c.dom.Element;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.HelloImpl;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.helpers.XPathUtils;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfMtomProducerPayloadModeTest.class,
- CxfMtomProducerPayloadModeTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfMtomProducerPayloadModeTest {
-
- protected final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- protected final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomProducerPayloadModeTest.class);
-
- @Autowired
- protected CamelContext context;
- private Endpoint endpoint;
-
- static int port = CXFTestSupport.getPort1();
-
-
-
- @BeforeEach
- public void setUp() throws Exception {
- endpoint = Endpoint.publish("/" + getClass().getSimpleName()
- + "/jaxws-mtom/hello",
- getServiceImpl());
- SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
- binding.setMTOMEnabled(isMtomEnabled());
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testProducer() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- // START SNIPPET: producer
-
- Exchange exchange = context.createProducerTemplate().send("direct:testEndpoint", new Processor() {
-
- public void process(Exchange exchange) throws Exception {
- exchange.setPattern(ExchangePattern.InOut);
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.REQ_MESSAGE)).getDocumentElement()));
- CxfPayload<SoapHeader> body = new CxfPayload<>(
- new ArrayList<SoapHeader>(),
- elements, null);
- exchange.getIn().setBody(body);
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_PHOTO_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
-
- exchange.getIn(AttachmentMessage.class).addAttachment(MtomTestHelper.REQ_IMAGE_CID,
- new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
-
- }
-
- });
-
- // process response
-
- CxfPayload<SoapHeader> out = exchange.getMessage().getBody(CxfPayload.class);
- assertEquals(1, out.getBody().size());
-
- Map<String, String> ns = new HashMap<>();
- ns.put("ns", MtomTestHelper.SERVICE_TYPES_NS);
- ns.put("xop", MtomTestHelper.XOP_NS);
-
- XPathUtils xu = new XPathUtils(ns);
- Element oute = new XmlConverter().toDOMElement(out.getBody().get(0));
- Element ele = (Element) xu.getValue("//ns:DetailResponse/ns:photo/xop:Include", oute,
- XPathConstants.NODE);
- String photoId = ele.getAttribute("href").substring(4); // skip "cid:"
-
- ele = (Element) xu.getValue("//ns:DetailResponse/ns:image/xop:Include", oute,
- XPathConstants.NODE);
- String imageId = ele.getAttribute("href").substring(4); // skip "cid:"
-
- DataHandler dr = exchange.getMessage(AttachmentMessage.class).getAttachment(decodingReference(photoId));
- assertEquals("application/octet-stream", dr.getContentType());
- assertArrayEquals(MtomTestHelper.RESP_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
-
- dr = exchange.getMessage(AttachmentMessage.class).getAttachment(decodingReference(imageId));
- assertEquals("image/jpeg", dr.getContentType());
-
- BufferedImage image = ImageIO.read(dr.getInputStream());
- assertEquals(560, image.getWidth());
- assertEquals(300, image.getHeight());
-
- // END SNIPPET: producer
-
- }
-
- // CXF encoding the XOP reference since 3.0.1
- private String decodingReference(String reference) throws UnsupportedEncodingException {
- return java.net.URLDecoder.decode(reference, "UTF-8");
- }
-
- protected boolean isMtomEnabled() {
- return true;
- }
-
- protected Object getServiceImpl() {
- return new HelloImpl();
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
-
- @Bean
- public CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomProducerPayloadModeTest" + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", true);
- properties.put("loggingFeatureEnabled", false);
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:testEndpoint").
- to("cxf:bean:serviceEndpoint?defaultOperationName=Detail");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterCxfMessageModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterCxfMessageModeTest.java
deleted file mode 100644
index dc11e8b3385..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterCxfMessageModeTest.java
+++ /dev/null
@@ -1,102 +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.component.cxf.soap.springboot.mtom;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.BindingProvider;
-
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.cxf.mtom_feature.HelloService;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomRouterCxfMessageModeTest.class,
- CxfMtomRouterPayloadModeTest.TestConfiguration.class,
- CxfMtomRouterCxfMessageModeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomRouterCxfMessageModeTest extends CxfMtomRouterPayloadModeTest {
-
-
-
-
- @Override
- protected Hello getPort() {
- URL wsdl = getClass().getResource("/mtom.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- HelloService service = new HelloService(wsdl, HelloService.SERVICE);
- assertNotNull(service, "Service is null");
- Hello hello = service.getHelloPort();
- ((BindingProvider) hello).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services" + "/CxfMtomRouterCxfMessageModeTest/jaxws-mtom/hello");
- return hello;
- }
-
- @Configuration
- class EndpointConfiguration {
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + "CxfMtomRouterCxfMessageModeTest"
- + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "CXF_MESSAGE");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomRouterCxfMessageModeTest" + "/jaxws-mtom/backend");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "CXF_MESSAGE");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadMode12Test.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadMode12Test.java
deleted file mode 100644
index b8d5f015028..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadMode12Test.java
+++ /dev/null
@@ -1,109 +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.component.cxf.soap.springboot.mtom;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.HelloImpl12;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.cxf.mtom_feature.HelloService12;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomRouterPayloadMode12Test.class,
- CxfMtomRouterPayloadModeTest.TestConfiguration.class,
- CxfMtomRouterPayloadMode12Test.EndpointConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomRouterPayloadMode12Test extends CxfMtomRouterPayloadModeTest {
-
- protected final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService12");
-
-
- @Override
- protected Object getImpl() {
- return new HelloImpl12();
- }
-
- @Override
- protected Hello getPort() {
- URL wsdl = getClass().getResource("/mtom.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- HelloService12 service = new HelloService12(wsdl, HelloService12.SERVICE);
- assertNotNull(service, "Service is null");
- Hello hello = service.getHelloPort();
- ((BindingProvider) hello).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services" + "/CxfMtomRouterPayloadMode12Test/jaxws-mtom/hello");
- return hello;
- }
-
- @Configuration
- class EndpointConfiguration {
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + "CxfMtomRouterPayloadMode12Test"
- + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomRouterPayloadMode12Test" + "/jaxws-mtom/backend");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadModeTest.java
deleted file mode 100644
index 7b635447867..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterPayloadModeTest.java
+++ /dev/null
@@ -1,214 +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.component.cxf.soap.springboot.mtom;
-
-
-
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.imageio.ImageIO;
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Holder;
-import javax.xml.ws.soap.SOAPBinding;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.mtom.HelloImpl;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.cxf.mtom_feature.HelloService;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfMtomRouterPayloadModeTest.class,
- CxfMtomRouterPayloadModeTest.TestConfiguration.class,
- CxfMtomRouterPayloadModeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfMtomRouterPayloadModeTest {
-
- protected final QName SERVICE_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloService");
- protected final QName PORT_QNAME = new QName("http://apache.org/camel/cxf/mtom_feature", "HelloPort");
- private static final Logger LOG = LoggerFactory.getLogger(CxfMtomRouterPayloadModeTest.class);
-
- @Autowired
- protected CamelContext context;
- private Endpoint endpoint;
-
- static int port = CXFTestSupport.getPort1();
-
-
-
- @BeforeEach
- public void setUp() throws Exception {
- endpoint = Endpoint.publish("/"
- + getClass().getSimpleName() + "/jaxws-mtom/backend",
- getImpl());
- SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
- binding.setMTOMEnabled(true);
-
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
-
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
- if (MtomTestHelper.isAwtHeadless(null, LOG)) {
- return;
- }
-
- Holder<byte[]> photo = new Holder<>(MtomTestHelper.REQ_PHOTO_DATA);
- Holder<Image> image = new Holder<>(getImage("/java.jpg"));
-
- Hello port = getPort();
-
- SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding();
- binding.setMTOMEnabled(true);
-
- port.detail(photo, image);
-
- assertArrayEquals(MtomTestHelper.RESP_PHOTO_DATA, photo.value);
- assertNotNull(image.value);
- if (image.value instanceof BufferedImage) {
- assertEquals(560, ((BufferedImage) image.value).getWidth());
- assertEquals(300, ((BufferedImage) image.value).getHeight());
- }
-
- }
-
- protected Hello getPort() {
- URL wsdl = getClass().getResource("/mtom.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- HelloService service = new HelloService(wsdl, HelloService.SERVICE);
- assertNotNull(service, "Service is null");
- Hello hello = service.getHelloPort();
- ((BindingProvider) hello).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMtomRouterPayloadModeTest/jaxws-mtom/hello");
- return hello;
- }
-
- private Image getImage(String name) throws Exception {
- return ImageIO.read(getClass().getResource(name));
- }
-
- protected Object getImpl() {
- return new HelloImpl();
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
-
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:routerEndpoint").
- to("cxf:bean:serviceEndpoint");
- }
- };
- }
- }
-
- @Configuration
- class EndpointConfiguration {
- @Bean
- public CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + "CxfMtomRouterPayloadModeTest"
- + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- public CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomRouterPayloadModeTest" + "/jaxws-mtom/backend");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterRawModeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterRawModeTest.java
deleted file mode 100644
index 639d37c39e5..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/CxfMtomRouterRawModeTest.java
+++ /dev/null
@@ -1,102 +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.component.cxf.soap.springboot.mtom;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.ws.BindingProvider;
-
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.cxf.mtom_feature.Hello;
-import org.apache.camel.cxf.mtom_feature.HelloService;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMtomRouterRawModeTest.class,
- CxfMtomRouterRawModeTest.TestConfiguration.class,
- CxfMtomRouterRawModeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMtomRouterRawModeTest extends CxfMtomRouterPayloadModeTest {
-
-
-
-
- @Override
- protected Hello getPort() {
- URL wsdl = getClass().getResource("/mtom.wsdl");
- assertNotNull(wsdl, "WSDL is null");
-
- HelloService service = new HelloService(wsdl, HelloService.SERVICE);
- assertNotNull(service, "Service is null");
- Hello hello = service.getHelloPort();
- ((BindingProvider) hello).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services" + "/CxfMtomRouterRawModeTest/jaxws-mtom/hello");
- return hello;
- }
-
- @Configuration
- class EndpointConfiguration {
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("/" + "CxfMtomRouterRawModeTest"
- + "/jaxws-mtom/hello");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "RAW");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICE_QNAME);
- cxfEndpoint.setEndpointNameAsQName(PORT_QNAME);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/"
- + "CxfMtomRouterRawModeTest" + "/jaxws-mtom/backend");
- cxfEndpoint.setWsdlURL("mtom.wsdl");
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "RAW");
- properties.put("mtom-enabled", "true");
- cxfEndpoint.setProperties(properties);
- return cxfEndpoint;
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/MtomTestHelper.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/MtomTestHelper.java
deleted file mode 100644
index 179c0ecfbc7..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/mtom/MtomTestHelper.java
+++ /dev/null
@@ -1,102 +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.component.cxf.soap.springboot.mtom;
-
-import java.io.IOException;
-
-import org.apache.cxf.helpers.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
-/**
- * Package local test helper
- */
-public final class MtomTestHelper {
- static final String SERVICE_TYPES_NS = "http://apache.org/camel/cxf/mtom_feature/types";
- static final String XOP_NS = "http://www.w3.org/2004/08/xop/include";
- static final byte[] REQ_PHOTO_DATA = { 1, 0, -1, 34, 23, 3, 23, 55, 33 };
- static final byte[] RESP_PHOTO_DATA = { 5, -7, 23, 1, 0, -1, 34, 23, 3, 23, 55, 33, 3 };
-
- static final String REQ_PHOTO_CID = "e33b6792-6666-4837-b0d9-68c88c8cadcb-1@apache.org";
- static final String REQ_IMAGE_CID = "e33b6792-6666-4837-b0d9-68c88c8cadcb-2@apache.org";
-
- static final String REQ_MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- + "<Detail xmlns=\"http://apache.org/camel/cxf/mtom_feature/types\">"
- + "<photo><xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\""
- + " href=\"cid:" + REQ_PHOTO_CID + "\"/>"
- + "</photo><image><xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\""
- + " href=\"cid:" + REQ_IMAGE_CID + "\"/></image></Detail>";
-
- static final String MTOM_DISABLED_REQ_MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- + "<Detail xmlns=\"http://apache.org/camel/cxf/mtom_feature/types\">"
- + "<photo>cid:" + REQ_PHOTO_CID + "</photo>"
- + "<image>cid:" + REQ_IMAGE_CID + "</image></Detail>";
-
- static final String RESP_PHOTO_CID = "4c7b78dc-356a-4fca-8877-068ee2f31824-7@apache.org";
- static final String RESP_IMAGE_CID = "4c7b78dc-356a-4fca-8877-068ee2f31824-8@apache.org";
-
- static final String RESP_MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- + "<DetailResponse xmlns=\"http://apache.org/camel/cxf/mtom_feature/types\">"
- + "<photo><xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\""
- + " href=\"cid:" + RESP_PHOTO_CID + "\"/>"
- + "</photo><image><xop:Include xmlns:xop=\"http://www.w3.org/2004/08/xop/include\""
- + " href=\"cid:" + RESP_IMAGE_CID + "\"/></image></DetailResponse>";
-
- static final String MTOM_DISABLED_RESP_MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- + "<DetailResponse xmlns=\"http://apache.org/camel/cxf/mtom_feature/types\">"
- + "<photo>cid:" + RESP_PHOTO_CID + "</photo>"
- + "<image>cid:" + RESP_IMAGE_CID + "</image></DetailResponse>";
-
- static byte[] requestJpeg;
- static byte[] responseJpeg;
-
- private static final Logger LOG = LoggerFactory.getLogger(MtomTestHelper.class);
-
- static {
- try {
- requestJpeg = IOUtils.readBytesFromStream(MtomTestHelper.class.getResourceAsStream("/java.jpg"));
- responseJpeg = IOUtils.readBytesFromStream(MtomTestHelper.class.getResourceAsStream("/Splash.jpg"));
- } catch (IOException e) {
- LOG.warn("I/O error reading bytes from stream: {}", e.getMessage(), e);
- }
- }
-
- private MtomTestHelper() {
- // utility class
- }
-
- static boolean isAwtHeadless(org.apache.commons.logging.Log log, org.slf4j.Logger logger) {
- assertFalse(log == null && logger == null, "Both loggers are not allowed to be null!");
- boolean headless = Boolean.getBoolean("java.awt.headless");
- if (headless) {
- // having the conversion characters %c{1} inside log4j.properties will reveal us the
- // test class currently running as we make use of it's logger to warn about skipping!
- String warning = "Running headless. Skipping test as Images may not work.";
- if (log != null) {
- log.warn(warning);
- }
-
- if (logger != null) {
- logger.warn("Running headless. Skipping test as Images may not work.");
- }
- }
-
- return headless;
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerDuplicateNamespaceStreamCacheTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerDuplicateNamespaceStreamCacheTest.java
deleted file mode 100644
index 928e7c8b280..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerDuplicateNamespaceStreamCacheTest.java
+++ /dev/null
@@ -1,70 +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.component.cxf.soap.springboot.namespace;
-
-
-
-
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfPayloadConsumerDuplicateNamespaceStreamCacheTest.class,
- CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.TestConfiguration.class,
- CxfAutoConfiguration.class,
- CxfPayloadConsumerNamespaceOnEnvelopeTest.EndpointConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfPayloadConsumerDuplicateNamespaceStreamCacheTest extends CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest {
-
-
- /*
- * The soap namespace prefix is already defined on the root tag of the
- * payload. If this is set another time from the envelope, the result will
- * be an invalid XML.
- */
- protected static final String REQUEST_MESSAGE
- = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
- + "<soap:Body><ns2:getToken xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"http://camel.apache.org/cxf/namespace\">"
- + "<arg0 xsi:type=\"xs:string\">Send</arg0></ns2:getToken></soap:Body></soap:Envelope>";
-
- @Override
- @Test
- public void testInvokeRouter() {
- Object returnValue = template.requestBody("direct:router", REQUEST_MESSAGE);
- assertNotNull(returnValue);
- assertTrue(returnValue instanceof String);
- assertTrue(((String) returnValue).contains("Return Value"));
- assertTrue(((String) returnValue).contains("http://www.w3.org/2001/XMLSchema-instance"));
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.java
deleted file mode 100644
index 54e22556b35..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.java
+++ /dev/null
@@ -1,75 +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.component.cxf.soap.springboot.namespace;
-
-import org.w3c.dom.Document;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.class,
- CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest.TestConfiguration.class,
- CxfAutoConfiguration.class,
- CxfPayloadConsumerNamespaceOnEnvelopeTest.EndpointConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfPayloadConsumerNamespaceOnEnvelopeStreamCacheTest
- extends CxfPayloadConsumerNamespaceOnEnvelopeTest {
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:router")
- // Use message mode to send the raw message
- .to("cxf:bean:serviceEndpoint")
- // Convert to String to make testing the result easier
- .convertBodyTo(String.class);
- // The consumer is running in payload mode
- from("cxf:bean:routerEndpoint")
- // Use stream caching to trigger the issue
- .streamCaching()
- // Parse to DOM to make sure it's still valid XML
- .convertBodyTo(Document.class).setBody().constant(RESPONSE_PAYLOAD);
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeTest.java
deleted file mode 100644
index c143728e37a..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadConsumerNamespaceOnEnvelopeTest.java
+++ /dev/null
@@ -1,150 +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.component.cxf.soap.springboot.namespace;
-
-
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Document;
-
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfPayloadConsumerNamespaceOnEnvelopeTest.class,
- CxfPayloadConsumerNamespaceOnEnvelopeTest.TestConfiguration.class,
- CxfPayloadConsumerNamespaceOnEnvelopeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfPayloadConsumerNamespaceOnEnvelopeTest {
-
- /*
- * The request message is generated directly. The issue here is that the xsi and xs namespaces are defined
- * on the SOAP envelope but are used within the payload. This can cause issues with some type conversions
- * in PAYLOAD mode, as the Camel-CXF endpoint will return some kind of window within the StAX parsing (and
- * the namespace definitions are outside). If some CXF proxy is used to send the message the namespaces
- * will be defined within the payload (and everything works fine).
- */
- protected static final String RESPONSE_PAYLOAD = "<ns2:getTokenResponse xmlns:ns2=\"http://camel.apache.org/cxf/namespace\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
- + "<return xsi:type=\"xs:string\">Return Value</return></ns2:getTokenResponse>";
- protected static final String REQUEST_MESSAGE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
- + "<soap:Body><ns2:getToken xmlns:ns2=\"http://camel.apache.org/cxf/namespace\"><arg0 xsi:type=\"xs:string\">Send</arg0></ns2:getToken></soap:Body></soap:Envelope>";
-
- private QName serviceName = QName.valueOf("{http://camel.apache.org/cxf/namespace}GetTokenService");
-
- @Autowired
- ProducerTemplate template;
-
- static int port = CXFTestSupport.getPort1();
-
-
-
- @Test
- public void testInvokeRouter() {
- Object returnValue = template.requestBody("direct:router", REQUEST_MESSAGE);
- assertNotNull(returnValue);
- assertTrue(returnValue instanceof String);
- assertTrue(((String)returnValue).contains("Return Value"));
- assertTrue(((String)returnValue).contains("http://www.w3.org/2001/XMLSchema-instance"));
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:router")
- // Use message mode to send the raw message
- .to("cxf:bean:serviceEndpoint")
- // Convert to String to make testing the result easier
- .convertBodyTo(String.class);
- // The consumer is running in payload mode
- from("cxf:bean:routerEndpoint")
- // Convert the CxfPayload to a String to trigger the issue
- .convertBodyTo(String.class)
- // Parse to DOM to make sure it's still valid XML
- .convertBodyTo(Document.class).setBody().constant(RESPONSE_PAYLOAD);
- }
- };
- }
-
-
-
-
- }
-
- @Configuration
- public class EndpointConfiguration {
-
- @Bean
- ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/GetToken/SoapContext/SoapPort");
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setWsdlURL("GetToken.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/GetToken/SoapContext/SoapPort");
- cxfEndpoint.setServiceNameAsQName(serviceName);
- cxfEndpoint.setWsdlURL("GetToken.wsdl");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- return cxfEndpoint;
- }
-
- }
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest.java
deleted file mode 100644
index 189dab3e4e8..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest.java
+++ /dev/null
@@ -1,84 +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.component.cxf.soap.springboot.namespace;
-
-
-
-
-import org.w3c.dom.Document;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest.class,
- CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest.TestConfiguration.class,
- CxfPayloadProducerNamespaceOnEnvelopeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfPayloadProducerNamespaceOnEnvelopeStreamCacheTest extends CxfPayloadProducerNamespaceOnEnvelopeTest {
-
-
-
-
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:router") //
- .streamCaching()
- // call an external Web service in payload mode
- .to("cxf:bean:serviceEndpoint?dataFormat=PAYLOAD")
- // Check that the issue doesn't occur if stream caching is enabled
- // Parse to DOM to make sure it's still valid XML
- .convertBodyTo(Document.class)
- // Convert back to String to make testing the result
- // easier
- .convertBodyTo(String.class);
- // This route just returns the test message
- from("cxf:bean:serviceEndpoint?dataFormat=RAW").setBody().constant(RESPONSE_MESSAGE);
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeTest.java
deleted file mode 100644
index d163277480b..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/namespace/CxfPayloadProducerNamespaceOnEnvelopeTest.java
+++ /dev/null
@@ -1,151 +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.component.cxf.soap.springboot.namespace;
-
-
-
-
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Document;
-
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.DataFormat;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CxfPayloadProducerNamespaceOnEnvelopeTest.class,
- CxfPayloadProducerNamespaceOnEnvelopeTest.TestConfiguration.class,
- CxfPayloadProducerNamespaceOnEnvelopeTest.EndpointConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class CxfPayloadProducerNamespaceOnEnvelopeTest {
-
-
- protected static final String RESPONSE_MESSAGE
- = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><soap:Body>"
- + "<ns2:getTokenResponse xmlns:ns2=\"http://camel.apache.org/cxf/namespace\"><return xsi:type=\"xs:string\">Return Value</return></ns2:getTokenResponse></soap:Body></soap:Envelope>";
- protected static final String REQUEST_PAYLOAD = "<ns2:getToken xmlns:ns2=\"http://camel.apache.org/cxf/namespace\"/>";
-
- private static QName SERVICENAME = QName.valueOf("{http://camel.apache.org/cxf/namespace}GetTokenService");
-
- static int port = CXFTestSupport.getPort1();
-
-
-
-
-
-
- @Autowired
- ProducerTemplate template;
-
- @Test
- public void testInvokeRouter() {
- Object returnValue = template.requestBody("direct:router", REQUEST_PAYLOAD);
- assertNotNull(returnValue);
- assertTrue(returnValue instanceof String);
- assertTrue(((String) returnValue).contains("Return Value"));
- assertTrue(((String) returnValue).contains("http://www.w3.org/2001/XMLSchema-instance"));
- }
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:router") //
- // call an external Web service in payload mode
- .to("cxf:bean:serviceEndpoint")
- // Convert the CxfPayload to a String to trigger the
- // issue
- .convertBodyTo(String.class)
- // Parse to DOM to make sure it's still valid XML
- .convertBodyTo(Document.class)
- // Convert back to String to make testing the result
- // easier
- .convertBodyTo(String.class);
- // This route just returns the test message
- from("cxf:bean:routerEndpoint").setBody().constant(RESPONSE_MESSAGE);
- }
- };
- }
- }
-
- @Configuration
- class EndpointConfiguration {
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
- @Bean
- CxfEndpoint routerEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- cxfEndpoint.setAddress("/GetToken/SoapContext/SoapPort");
- cxfEndpoint.setDataFormat(DataFormat.RAW);
- return cxfEndpoint;
- }
-
-
- @Bean
- CxfEndpoint serviceEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- cxfEndpoint.setAddress("http://localhost:" + port
- + "/services/GetToken/SoapContext/SoapPort");
- cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
- return cxfEndpoint;
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/noparam/NoParamTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/noparam/NoParamTest.java
deleted file mode 100644
index cd9d9f46660..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/noparam/NoParamTest.java
+++ /dev/null
@@ -1,125 +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.component.cxf.soap.springboot.noparam;
-
-
-
-import javax.xml.ws.Endpoint;
-
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- NoParamTest.class,
- NoParamTest.TestConfiguration.class,
- CxfAutoConfiguration.class
- }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
-)
-public class NoParamTest {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(NoParamTest.class);
-
- static int port = CXFTestSupport.getPort1();
-
-
- @BeforeEach
- public void setup() {
- Object implementor = new org.apache.camel.component.cxf.noparam.NoParamEndpoint();
- String address = "/cxf-noparam/";
- Endpoint.publish(address, implementor);
- }
-
-
-
-
- @Autowired
- ProducerTemplate template;
-
- @Test
- public void testNullBody() throws Exception {
- Object body = template.sendBody("direct:noParam", ExchangePattern.InOut, null);
- assertNotNull(body);
- LOGGER.error(body.toString());
- }
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() {
- return new UndertowServletWebServerFactory(port);
- }
-
-
- @Bean
- CxfEndpoint noParamEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.noparam.NoParamEndpoint.class);
- cxfEndpoint.setAddress("/camel-noparam/");
- return cxfEndpoint;
- }
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("cxf:bean:noParamEndpoint")
- .transform(constant("OK"))
- .to("mock:end");
-
- from("direct:noParam")
- .to("cxf:bean:noParamEndpoint?address=" + "http://localhost:" + port
- + "/services/camel-noparam/");
- }
- };
- }
- }
-
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/soap/headers/CxfMessageHeadersRelayTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/soap/headers/CxfMessageHeadersRelayTest.java
deleted file mode 100644
index 62d1a642968..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/soap/headers/CxfMessageHeadersRelayTest.java
+++ /dev/null
@@ -1,977 +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.component.cxf.soap.springboot.soap.headers;
-
-import java.io.StringReader;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Endpoint;
-import javax.xml.ws.Holder;
-
-import org.w3c.dom.Node;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.CxfPayload;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
-import org.apache.camel.component.cxf.soap.headers.Constants;
-import org.apache.camel.component.cxf.soap.headers.CustomHeaderFilter;
-import org.apache.camel.component.cxf.soap.headers.HeaderService;
-import org.apache.camel.component.cxf.soap.headers.HeaderTester;
-import org.apache.camel.component.cxf.soap.headers.HeaderTesterImpl;
-import org.apache.camel.component.cxf.soap.headers.HeaderTesterWithInsertionImpl;
-import org.apache.camel.component.cxf.soap.headers.InHeader;
-import org.apache.camel.component.cxf.soap.headers.InHeaderResponse;
-import org.apache.camel.component.cxf.soap.headers.InoutHeader;
-import org.apache.camel.component.cxf.soap.headers.InoutHeaderResponse;
-import org.apache.camel.component.cxf.soap.headers.Me;
-import org.apache.camel.component.cxf.soap.headers.OutHeader;
-import org.apache.camel.component.cxf.soap.headers.OutHeaderResponse;
-import org.apache.camel.component.cxf.soap.headers.SOAPHeaderData;
-import org.apache.camel.component.cxf.spring.jaxws.CxfSpringEndpoint;
-import org.apache.camel.component.cxf.transport.header.CxfHeaderFilterStrategy;
-import org.apache.camel.component.cxf.transport.header.MessageHeaderFilter;
-import org.apache.camel.component.cxf.transport.header.SoapMessageHeaderFilter;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.apache.camel.support.DefaultExchange;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
-import org.apache.cxf.binding.soap.SoapHeader;
-import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.ext.logging.LoggingFeature;
-import org.apache.cxf.headers.Header;
-import org.apache.cxf.headers.Header.Direction;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.message.MessageContentsList;
-import org.apache.cxf.outofband.header.OutofBandHeader;
-import org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@DirtiesContext
-@CamelSpringBootTest
-@SpringBootTest(classes = {
- CamelAutoConfiguration.class,
- CxfMessageHeadersRelayTest.class,
- CxfMessageHeadersRelayTest.TestConfiguration.class,
- CxfAutoConfiguration.class
-}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfMessageHeadersRelayTest {
-
- private static QName SERVICENAME = QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}HeaderService");
-
- static int port = CXFTestSupport.getPort1();
-
-
- private static final Logger LOG = LoggerFactory.getLogger(CxfMessageHeadersRelayTest.class);
-
- @Autowired
- protected CamelContext context;
-
- @Autowired
- protected ProducerTemplate template;
-
- private Endpoint relayEndpoint;
- private Endpoint noRelayEndpoint;
- private Endpoint relayEndpointWithInsertion;
-
- @BeforeEach
- public void setUp() throws Exception {
- relayEndpoint = Endpoint.publish("/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointBackend",
- new HeaderTesterImpl());
- noRelayEndpoint = Endpoint.publish("/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpointBackend",
- new HeaderTesterImpl(false));
- relayEndpointWithInsertion = Endpoint.publish("/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertionBackend",
- new HeaderTesterWithInsertionImpl());
-
- }
-
- @AfterEach
- public void tearDown() throws Exception {
-
- if (relayEndpoint != null) {
- relayEndpoint.stop();
- relayEndpoint = null;
- }
-
- if (noRelayEndpoint != null) {
- noRelayEndpoint.stop();
- noRelayEndpoint = null;
- }
-
- if (relayEndpointWithInsertion != null) {
- relayEndpointWithInsertion.stop();
- relayEndpointWithInsertion = null;
- }
- }
-
- protected static void addOutOfBoundHeader(HeaderTester proxy, boolean invalid) throws JAXBException {
- InvocationHandler handler = Proxy.getInvocationHandler(proxy);
- BindingProvider bp = null;
-
- try {
- if (handler instanceof BindingProvider) {
- bp = (BindingProvider) handler;
- Map<String, Object> requestContext = bp.getRequestContext();
- requestContext.put(Header.HEADER_LIST, buildOutOfBandHeaderList(invalid));
- }
- } catch (JAXBException ex) {
- throw ex;
- }
-
- }
-
- @Test
- public void testInHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- InHeader me = new InHeader();
- me.setRequestType("CXF user");
- InHeaderResponse response = proxy.inHeader(me, Constants.IN_HEADER_DATA);
- assertEquals("pass", response.getResponseType(), "Expected in band header to propagate but it didn't");
- }
-
- @Test
- public void testOutHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
-
- OutHeader me = new OutHeader();
- me.setRequestType("CXF user");
- Holder<OutHeaderResponse> result = new Holder<>(new OutHeaderResponse());
- Holder<SOAPHeaderData> header = new Holder<>(new SOAPHeaderData());
- proxy.outHeader(me, result, header);
- assertEquals("pass", result.value.getResponseType(), "Expected in band header to propagate but it didn't");
- assertTrue(Constants.equals(Constants.OUT_HEADER_DATA, header.value),
- "Expected in band response header to propagate but it either didn't "
- + " or its contents do not match");
- }
-
- @Test
- public void testInOutHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- InoutHeader me = new InoutHeader();
- me.setRequestType("CXF user");
- Holder<SOAPHeaderData> header = new Holder<>(Constants.IN_OUT_REQUEST_HEADER_DATA);
- InoutHeaderResponse result = proxy.inoutHeader(me, header);
- assertEquals("pass", result.getResponseType(), "Expected in band header to propagate but it didn't");
- assertTrue(Constants.equals(Constants.IN_OUT_RESPONSE_HEADER_DATA, header.value),
- "Expected in band response header to propagate but it either didn't "
- + " or its contents do not match");
- }
-
- @Test
- public void testInOutOfBandHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- addOutOfBoundHeader(proxy, false);
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
-
- Me response = proxy.inOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the out of band header to propagate but it didn't");
- }
-
- @Test
- public void testInoutOutOfBandHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- addOutOfBoundHeader(proxy, false);
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Me response = proxy.inoutOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the out of band header to propagate but it didn't");
- validateReturnedOutOfBandHeader(proxy);
- }
-
- @Test
- public void testInoutOutOfBandHeaderCXFClientRelayWithHeaderInsertion() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelayWithInsertion();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertion");
- addOutOfBoundHeader(proxy, false);
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Me response = proxy.inoutOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the out of band header to propagate but it didn't");
-
- InvocationHandler handler = Proxy.getInvocationHandler(proxy);
- BindingProvider bp = null;
- if (!(handler instanceof BindingProvider)) {
- fail("Unable to cast dynamic proxy InocationHandler to BindingProvider type");
- }
-
- bp = (BindingProvider) handler;
- Map<String, Object> responseContext = bp.getResponseContext();
- validateReturnedOutOfBandHeaderWithInsertion(responseContext, true);
- }
-
- @Test
- public void testOutOutOfBandHeaderCXFClientRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Me response = proxy.outOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the out of band header to propagate but it didn't");
- validateReturnedOutOfBandHeader(proxy);
- }
-
- @Test
- public void testInOutOfBandHeaderCXFClientNoRelay() throws Exception {
-
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
-
- addOutOfBoundHeader(proxy, false);
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Me response = proxy.inOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the in out of band header *not* to propagate but it did");
-
- }
-
- @Test
- public void testOutOutOfBandHeaderCXFClientNoRelay() throws Exception {
-
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Thread.sleep(5000);
- Me response = proxy.outOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the out out of band header *not* to propagate but it did");
- validateReturnedOutOfBandHeader(proxy, false);
- }
-
- @Test
- public void testInoutOutOfBandHeaderCXFClientNoRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- addOutOfBoundHeader(proxy, false);
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
- Me response = proxy.inoutOutOfBandHeader(me);
- assertEquals("pass", response.getFirstName(), "Expected the in out of band header to *not* propagate but it did");
- validateReturnedOutOfBandHeader(proxy, false);
- }
-
- @Test
- public void testInHeaderCXFClientNoRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- InHeader me = new InHeader();
- me.setRequestType("CXF user");
- InHeaderResponse response = null;
- try {
- response = proxy.inHeader(me, Constants.IN_HEADER_DATA);
- } catch (Exception e) {
- // do nothing
- }
- assertEquals("pass", response.getResponseType(), "Expected in in band header *not* to propagate but it did");
- }
-
- @Test
- public void testOutHeaderCXFClientNoRelay() throws Exception {
- Thread.sleep(5000);
-
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- OutHeader me = new OutHeader();
- me.setRequestType("CXF user");
- Holder<OutHeaderResponse> result = new Holder<>(new OutHeaderResponse());
- Holder<SOAPHeaderData> header = new Holder<>(new SOAPHeaderData());
- try {
- proxy.outHeader(me, result, header);
- } catch (Exception e) {
- // do nothing
- }
- assertEquals("pass", result.value.getResponseType(),
- "Ultimate remote HeaderTester.outHeader() destination was not reached");
- assertNull(header.value, "Expected in band response header *not* to propagate but it did");
- }
-
- @Test
- public void testInoutHeaderCXFClientNoRelay() throws Exception {
- HeaderService s = new HeaderService(
- getClass().getClassLoader().getResource("soap_header.wsdl"),
- HeaderService.SERVICE);
- HeaderTester proxy = s.getSoapPortNoRelay();
- ((BindingProvider) proxy).getRequestContext()
- .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
- "http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- InoutHeader me = new InoutHeader();
- me.setRequestType("CXF user");
- Holder<SOAPHeaderData> header = new Holder<>(Constants.IN_OUT_REQUEST_HEADER_DATA);
- InoutHeaderResponse result = null;
- try {
- result = proxy.inoutHeader(me, header);
- } catch (Exception e) {
- // do nothing
- }
- assertEquals("pass", result.getResponseType(), "Expected in band out header *not* to propagate but it did");
- assertNull(header.value, "Expected in band response header *not* to propagate but did");
- }
-
- @Test
-
- public void testInoutHeaderCXFClientNoServiceClassNoRelay() throws Exception {
- // TODO: Fix this test later
- QName qname = QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SOAPHeaderInfo");
- String uri = "cxf:bean:routerNoRelayNoServiceClassEndpoint?headerFilterStrategy=#dropAllMessageHeadersStrategy"
- + "&address=http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayNoServiceClassEndpoint";
- String requestHeader = "<ns2:SOAPHeaderInfo xmlns:ns2=\"http://apache.org/camel/"
- + "component/cxf/soap/headers\"><originator>CxfSoapHeaderRoutePropagationTest.testInOutHeader Requestor"
- + "</originator><message>Invoking CxfSoapHeaderRoutePropagationTest.testInOutHeader() Request"
- + "</message></ns2:SOAPHeaderInfo>";
- String requestBody = "<ns2:inoutHeader xmlns:ns2=\"http://apache.org/camel/component/cxf/soap/headers\">"
- + "<requestType>CXF user</requestType></ns2:inoutHeader>";
- List<Source> elements = new ArrayList<>();
- elements.add(new DOMSource(StaxUtils.read(new StringReader(requestBody)).getDocumentElement()));
- final List<SoapHeader> headers = new ArrayList<>();
- headers.add(new SoapHeader(
- qname,
- StaxUtils.read(new StringReader(requestHeader)).getDocumentElement()));
- final CxfPayload<SoapHeader> cxfPayload = new CxfPayload<>(headers, elements, null);
-
- Exchange exchange = template.request(uri, new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody(cxfPayload);
- exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "inoutHeader");
- exchange.getIn().setHeader(Header.HEADER_LIST, headers);
- }
-
- });
-
- CxfPayload<?> out = exchange.getMessage().getBody(CxfPayload.class);
- assertEquals(1, out.getBodySources().size());
-
- assertTrue(out.getBodySources().get(0) instanceof DOMSource);
-
- assertEquals(0, out.getHeaders().size());
-
- String responseExp = "<ns2:inoutHeaderResponse xmlns:ns2=\"http://apache.org/camel/"
- + "component/cxf/soap/headers\"><responseType>pass</responseType>"
- + "</ns2:inoutHeaderResponse>";
- String response = StaxUtils.toString(out.getBody().get(0));
- //REVISIT use a more reliable comparison to tolerate some namespaces being added to the root element
- assertTrue(response.startsWith(responseExp.substring(0, 87))
- && response.endsWith(responseExp.substring(88, responseExp.length())), response);
- }
-
- @Test
- public void testMessageHeadersRelaysSpringContext() throws Exception {
- CxfEndpoint endpoint = context.getEndpoint(
- "cxf:bean:serviceExtraRelays?headerFilterStrategy=#customMessageFilterStrategy", CxfEndpoint.class);
- CxfHeaderFilterStrategy strategy = (CxfHeaderFilterStrategy) endpoint.getHeaderFilterStrategy();
- List<MessageHeaderFilter> filters = strategy.getMessageHeaderFilters();
- assertEquals(2, filters.size(), "Expected number of filters");
- Map<String, MessageHeaderFilter> messageHeaderFilterMap = strategy.getMessageHeaderFiltersMap();
- for (String ns : new CustomHeaderFilter().getActivationNamespaces()) {
- assertEquals(CustomHeaderFilter.class, messageHeaderFilterMap.get(ns).getClass(),
- "Expected a filter class for namespace: " + ns);
- }
- }
-
- @Test
- public void testInOutOfBandHeaderCamelTemplateDirect() throws Exception {
- doTestInOutOfBandHeaderCamelTemplate("direct:directProducer");
- }
-
- @Test
- public void testOutOutOfBandHeaderCamelTemplateDirect() throws Exception {
- doTestOutOutOfBandHeaderCamelTemplate("direct:directProducer");
- }
-
- @Test
- public void testInOutOutOfBandHeaderCamelTemplateDirect() throws Exception {
- doTestInOutOutOfBandHeaderCamelTemplate("direct:directProducer");
- }
-
- @Test
- public void testInOutOfBandHeaderCamelTemplateRelay() throws Exception {
- doTestInOutOfBandHeaderCamelTemplate("direct:relayProducer");
- }
-
- @Test
- public void testOutOutOfBandHeaderCamelTemplateRelay() throws Exception {
- doTestOutOutOfBandHeaderCamelTemplate("direct:relayProducer");
- }
-
- @Test
- public void testInOutOutOfBandHeaderCamelTemplateRelay() throws Exception {
- doTestInOutOutOfBandHeaderCamelTemplate("direct:relayProducer");
- }
-
- protected void doTestInOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
- // START SNIPPET: sending
- Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
- final List<Object> params = new ArrayList<>();
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
-
- params.add(me);
- senderExchange.getIn().setBody(params);
- senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "inOutOfBandHeader");
-
- List<Header> headers = buildOutOfBandHeaderList(false);
- Map<String, Object> requestContext = new HashMap<>();
- requestContext.put(Header.HEADER_LIST, headers);
- senderExchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
-
- Exchange exchange = template.send(producerUri, senderExchange);
-
- org.apache.camel.Message out = exchange.getMessage();
- MessageContentsList result = (MessageContentsList) out.getBody();
- Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>) out.getHeader(Client.RESPONSE_CONTEXT));
- assertNotNull(responseContext);
- assertTrue(result.get(0) != null && ((Me) result.get(0)).getFirstName().equals("pass"),
- "Expected the out of band header to propagate but it didn't");
-
- }
-
- protected void doTestOutOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
- // START SNIPPET: sending
- Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
- final List<Object> params = new ArrayList<>();
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
-
- params.add(me);
- senderExchange.getIn().setBody(params);
- senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "outOutOfBandHeader");
-
- Exchange exchange = template.send(producerUri, senderExchange);
-
- org.apache.camel.Message out = exchange.getMessage();
- MessageContentsList result = (MessageContentsList) out.getBody();
- assertTrue(result.get(0) != null && ((Me) result.get(0)).getFirstName().equals("pass"),
- "Expected the out of band header to propagate but it didn't");
- Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>) out.getHeader(Client.RESPONSE_CONTEXT));
- assertNotNull(responseContext);
- validateReturnedOutOfBandHeader(responseContext);
- }
-
- public void doTestInOutOutOfBandHeaderCamelTemplate(String producerUri) throws Exception {
- // START SNIPPET: sending
- Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
- final List<Object> params = new ArrayList<>();
- Me me = new Me();
- me.setFirstName("john");
- me.setLastName("Doh");
-
- params.add(me);
- senderExchange.getIn().setBody(params);
- senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "inoutOutOfBandHeader");
-
- List<Header> inHeaders = buildOutOfBandHeaderList(false);
- Map<String, Object> requestContext = new HashMap<>();
- requestContext.put(Header.HEADER_LIST, inHeaders);
- senderExchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
-
- Exchange exchange = template.send(producerUri, senderExchange);
-
- org.apache.camel.Message out = exchange.getMessage();
- MessageContentsList result = (MessageContentsList) out.getBody();
- assertTrue(result.get(0) != null && ((Me) result.get(0)).getFirstName().equals("pass"),
- "Expected the out of band header to propagate but it didn't");
- Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>) out.getHeader(Client.RESPONSE_CONTEXT));
- assertNotNull(responseContext);
- validateReturnedOutOfBandHeader(responseContext);
- }
-
- protected static void validateReturnedOutOfBandHeader(HeaderTester proxy) {
- validateReturnedOutOfBandHeader(proxy, true);
- }
-
- protected static void validateReturnedOutOfBandHeader(HeaderTester proxy, boolean expect) {
- InvocationHandler handler = Proxy.getInvocationHandler(proxy);
- BindingProvider bp = null;
- if (!(handler instanceof BindingProvider)) {
- fail("Unable to cast dynamic proxy InocationHandler to BindingProvider type");
- }
-
- bp = (BindingProvider) handler;
- Map<String, Object> responseContext = bp.getResponseContext();
- validateReturnedOutOfBandHeader(responseContext, expect);
- }
-
- protected static void validateReturnedOutOfBandHeader(Map<String, Object> responseContext) {
- validateReturnedOutOfBandHeader(responseContext, true);
- }
-
- protected static void validateReturnedOutOfBandHeader(Map<String, Object> responseContext, boolean expect) {
- OutofBandHeader hdrToTest = null;
- List<Header> oobHdr = CastUtils.cast((List<?>) responseContext.get(Header.HEADER_LIST));
- if (!expect) {
- if (oobHdr == null || oobHdr != null && oobHdr.size() == 0) {
- return;
- }
- fail("Should have got *no* out-of-band headers, but some were found");
- }
- if (oobHdr == null) {
- fail("Should have got List of out-of-band headers");
- }
-
- assertEquals(1, oobHdr.size(), "HeaderHolder list expected to conain 1 object received " + oobHdr.size());
-
- for (Header hdr1 : oobHdr) {
- if (hdr1.getObject() instanceof Node) {
- try {
- JAXBElement<?> job = (JAXBElement<?>) JAXBContext
- .newInstance(org.apache.cxf.outofband.header.ObjectFactory.class)
- .createUnmarshaller().unmarshal((Node) hdr1.getObject());
- hdrToTest = (OutofBandHeader) job.getValue();
- } catch (JAXBException ex) {
- LOG.warn("JAXB error: {}", ex.getMessage(), ex);
- }
- }
- }
-
- assertNotNull(hdrToTest, "out-of-band header should not be null");
- assertEquals("testOobReturnHeaderName", hdrToTest.getName(),
- "Expected out-of-band Header name testOobReturnHeaderName recevied :"
- + hdrToTest.getName());
- assertEquals("testOobReturnHeaderValue", hdrToTest.getValue(),
- "Expected out-of-band Header value testOobReturnHeaderValue recevied :"
- + hdrToTest.getValue());
- assertEquals("testReturnHdrAttribute", hdrToTest.getHdrAttribute(),
- "Expected out-of-band Header attribute testReturnHdrAttribute recevied :" + hdrToTest.getHdrAttribute());
- }
-
- protected static List<Header> buildOutOfBandHeaderList(boolean invalid) throws JAXBException {
- OutofBandHeader ob = new OutofBandHeader();
- ob.setName("testOobHeader");
- ob.setValue("testOobHeaderValue");
- ob.setHdrAttribute(invalid ? "dontProcess" : "testHdrAttribute");
-
- SoapHeader hdr = new SoapHeader(
- new QName(Constants.TEST_HDR_NS, Constants.TEST_HDR_REQUEST_ELEM),
- ob,
- new JAXBDataBinding(ob.getClass()));
-
- hdr.setMustUnderstand(invalid);
-
- List<Header> headers = new ArrayList<>();
- headers.add(hdr);
- return headers;
- }
-
- protected static void validateReturnedOutOfBandHeaderWithInsertion(Map<String, Object> responseContext, boolean expect) {
- List<OutofBandHeader> hdrToTest = new ArrayList<>();
- List<Header> oobHdr = CastUtils.cast((List<?>) responseContext.get(Header.HEADER_LIST));
- if (!expect) {
- if (oobHdr == null || oobHdr != null && oobHdr.size() == 0) {
- return;
- }
- fail("Should have got *no* out-of-band headers, but some were found");
- }
- if (oobHdr == null) {
- fail("Should have got List of out-of-band headers");
- }
-
- assertEquals(2, oobHdr.size(), "HeaderHolder list expected to conain 2 object received " + oobHdr.size());
-
- for (Header hdr1 : oobHdr) {
- if (hdr1.getObject() instanceof Node) {
- try {
- JAXBElement<?> job = (JAXBElement<?>) JAXBContext
- .newInstance(org.apache.cxf.outofband.header.ObjectFactory.class)
- .createUnmarshaller().unmarshal((Node) hdr1.getObject());
- hdrToTest.add((OutofBandHeader) job.getValue());
- } catch (JAXBException ex) {
- LOG.warn("JAXB error: {}", ex.getMessage(), ex);
- }
- }
- }
-
- assertTrue(hdrToTest.size() > 0, "out-of-band header should not be null");
- assertEquals("testOobReturnHeaderName", hdrToTest.get(0).getName(),
- "Expected out-of-band Header name testOobReturnHeaderName recevied :"
- + hdrToTest.get(0).getName());
- assertEquals("testOobReturnHeaderValue", hdrToTest.get(0).getValue(),
- "Expected out-of-band Header value testOobReturnHeaderValue recevied :"
- + hdrToTest.get(0).getValue());
- assertEquals("testReturnHdrAttribute", hdrToTest.get(0).getHdrAttribute(),
- "Expected out-of-band Header attribute testReturnHdrAttribute recevied :"
- + hdrToTest.get(0).getHdrAttribute());
-
- assertEquals("New_testOobHeader", hdrToTest.get(1).getName(),
- "Expected out-of-band Header name New_testOobHeader recevied :"
- + hdrToTest.get(1).getName());
- assertEquals("New_testOobHeaderValue", hdrToTest.get(1).getValue(),
- "Expected out-of-band Header value New_testOobHeaderValue recevied :"
- + hdrToTest.get(1).getValue());
- assertEquals("testHdrAttribute", hdrToTest.get(1).getHdrAttribute(),
- "Expected out-of-band Header attribute testHdrAttribute recevied :"
- + hdrToTest.get(1).getHdrAttribute());
- }
-
- public static class InsertRequestOutHeaderProcessor implements Processor {
-
- @Override
- public void process(Exchange exchange) throws Exception {
- List<SoapHeader> soapHeaders = CastUtils.cast((List<?>) exchange.getIn().getHeader(Header.HEADER_LIST));
-
- // Insert a new header
- String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader "
- + "xmlns=\"http://cxf.apache.org/outofband/Header\" hdrAttribute=\"testHdrAttribute\" "
- + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">"
- + "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
-
- SoapHeader newHeader = new SoapHeader(
- soapHeaders.get(0).getName(),
- StaxUtils.read(new StringReader(xml)).getDocumentElement());
- // make sure direction is IN since it is a request message.
- newHeader.setDirection(Direction.DIRECTION_IN);
- //newHeader.setMustUnderstand(false);
- soapHeaders.add(newHeader);
-
- }
-
- }
-
- // START SNIPPET: InsertResponseOutHeaderProcessor
-
- public static class InsertResponseOutHeaderProcessor implements Processor {
-
- @Override
- public void process(Exchange exchange) throws Exception {
- // You should be able to get the header if exchange is routed from camel-cxf endpoint
- List<SoapHeader> soapHeaders = CastUtils.cast((List<?>) exchange.getIn().getHeader(Header.HEADER_LIST));
- if (soapHeaders == null) {
- // we just create a new soap headers in case the header is null
- soapHeaders = new ArrayList<>();
- }
-
- // Insert a new header
- String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader "
- + "xmlns=\"http://cxf.apache.org/outofband/Header\" hdrAttribute=\"testHdrAttribute\" "
- + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">"
- + "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
- SoapHeader newHeader = new SoapHeader(
- soapHeaders.get(0).getName(),
- StaxUtils.read(new StringReader(xml)).getDocumentElement());
- // make sure direction is OUT since it is a response message.
- newHeader.setDirection(Direction.DIRECTION_OUT);
- //newHeader.setMustUnderstand(false);
- soapHeaders.add(newHeader);
-
- }
-
- }
-
- // END SNIPPET: InsertResponseOutHeaderProcessor
-
-
- // *************************************
- // Config
- // *************************************
-
- @Configuration
- public class TestConfiguration {
-
- @Bean
- public ServletWebServerFactory servletWebServerFactory() throws InterruptedException {
- ServletWebServerFactory webServerFactory = new UndertowServletWebServerFactory(port);
- return webServerFactory;
- }
-
-
- @Bean
- CxfEndpoint routerRelayEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceRelayEndpoint() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointBackend");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint routerRelayEndpointWithInsertion() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertion");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelayWithInsertion"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- cxfEndpoint.getFeatures().add(new LoggingFeature());
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceRelayEndpointWithInsertion() {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertionBackend");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelayWithInsertion"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- cxfEndpoint.getFeatures().add(new LoggingFeature());
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint routerNoRelayEndpoint(HeaderFilterStrategy dropAllMessageHeadersStrategy) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpoint");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortNoRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setHeaderFilterStrategy(dropAllMessageHeadersStrategy);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceNoRelayEndpoint(HeaderFilterStrategy dropAllMessageHeadersStrategy) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpointBackend");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortNoRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setHeaderFilterStrategy(dropAllMessageHeadersStrategy);
- return cxfEndpoint;
- }
-
-
- @Bean
- CxfEndpoint routerNoRelayNoServiceClassEndpoint(HeaderFilterStrategy dropAllMessageHeadersStrategy) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayNoServiceClassEndpoint");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortNoRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- properties.put("allowStreaming", "false");
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setHeaderFilterStrategy(dropAllMessageHeadersStrategy);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceNoRelayNoServiceClassEndpoint(HeaderFilterStrategy dropAllMessageHeadersStrategy) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayEndpointBackend");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortNoRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("dataFormat", "PAYLOAD");
- cxfEndpoint.setProperties(properties);
- cxfEndpoint.setHeaderFilterStrategy(dropAllMessageHeadersStrategy);
- return cxfEndpoint;
- }
-
- @Bean
- CxfEndpoint serviceExtraRelays(HeaderFilterStrategy customMessageFilterStrategy) {
- CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
- cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/serviceExtraRelays");
- cxfEndpoint.setWsdlURL("soap_header.wsdl");
- cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
- cxfEndpoint.setEndpointNameAsQName(
- QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortCustomRelay"));
- cxfEndpoint.setServiceNameAsQName(SERVICENAME);
- cxfEndpoint.setHeaderFilterStrategy(customMessageFilterStrategy);
- return cxfEndpoint;
- }
-
- @Bean
- HeaderFilterStrategy dropAllMessageHeadersStrategy() {
- CxfHeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
- headerFilterStrategy.setRelayHeaders(false);
- return headerFilterStrategy;
- }
-
- @Bean
- HeaderFilterStrategy customMessageFilterStrategy() {
- CxfHeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
- List<MessageHeaderFilter> headerFilterList = new ArrayList<MessageHeaderFilter>();
- headerFilterList.add(new SoapMessageHeaderFilter());
- headerFilterList.add(new CustomHeaderFilter());
- headerFilterStrategy.setMessageHeaderFilters(headerFilterList);
- return headerFilterStrategy;
- }
-
-
- @Bean
- public RouteBuilder routeBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
-
- from("cxf:bean:routerRelayEndpoint")
- .to("cxf:bean:serviceRelayEndpoint");
- from("cxf:bean:routerRelayEndpointWithInsertion")
- .process(new InsertRequestOutHeaderProcessor())
- .to("cxf:bean:serviceRelayEndpointWithInsertion")
- .process(new InsertResponseOutHeaderProcessor());
- from("direct:directProducer")
- .to("cxf:bean:serviceRelayEndpoint");
- from("direct:relayProducer")
- .to("cxf://"
- + "http://localhost:" + port
- + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpoint" +
- "?serviceClass=\"org.apache.camel.component.cxf.soap.headers.HeaderTester\"");
- from("cxf:bean:routerNoRelayEndpoint")
- .to("cxf:bean:serviceNoRelayEndpoint");
- from("cxf:bean:routerNoRelayNoServiceClassEndpoint")
- .to("cxf:bean:serviceNoRelayNoServiceClassEndpoint");
- from("cxf:bean:serviceExtraRelays")
- .to("mock:result");
- }
- };
- }
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslBuilderCustomizer.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslBuilderCustomizer.java
deleted file mode 100644
index dafd4cee995..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslBuilderCustomizer.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package org.apache.camel.component.cxf.soap.springboot.ssl;
-
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509ExtendedKeyManager;
-
-import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
-import org.springframework.boot.web.server.Ssl;
-import org.springframework.boot.web.server.SslConfigurationValidator;
-import org.springframework.boot.web.server.SslStoreProvider;
-import org.springframework.boot.web.server.WebServerException;
-import org.springframework.util.ResourceUtils;
-import org.xnio.Options;
-import org.xnio.Sequence;
-import org.xnio.SslClientAuthMode;
-
-import io.undertow.Undertow;
-
-public class SslBuilderCustomizer implements UndertowBuilderCustomizer {
- private final int port;
-
- private final InetAddress address;
-
- private final Ssl ssl;
-
- private final SslStoreProvider sslStoreProvider;
-
- SslBuilderCustomizer(int port, InetAddress address, Ssl ssl, SslStoreProvider sslStoreProvider) {
- this.port = port;
- this.address = address;
- this.ssl = ssl;
- this.sslStoreProvider = sslStoreProvider;
- }
-
- public void customize(Undertow.Builder builder) {
- try {
- SSLContext sslContext = SSLContext.getInstance(this.ssl.getProtocol());
- sslContext.init(getKeyManagers(this.ssl, this.sslStoreProvider),
- getTrustManagers(this.ssl, this.sslStoreProvider), null);
- builder.addHttpsListener(this.port, getListenAddress(), sslContext);
- builder.setSocketOption(Options.SSL_CLIENT_AUTH_MODE, getSslClientAuthMode(this.ssl));
- if (this.ssl.getEnabledProtocols() != null) {
- builder.setSocketOption(Options.SSL_ENABLED_PROTOCOLS, Sequence.of(this.ssl.getEnabledProtocols()));
- }
- if (this.ssl.getCiphers() != null) {
- builder.setSocketOption(Options.SSL_ENABLED_CIPHER_SUITES, Sequence.of(this.ssl.getCiphers()));
- }
- }
- catch (NoSuchAlgorithmException | KeyManagementException ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- private String getListenAddress() {
- if (this.address == null) {
- return "0.0.0.0";
- }
- return this.address.getHostAddress();
- }
-
- private SslClientAuthMode getSslClientAuthMode(Ssl ssl) {
- if (ssl.getClientAuth() == Ssl.ClientAuth.NEED) {
- return SslClientAuthMode.REQUIRED;
- }
- if (ssl.getClientAuth() == Ssl.ClientAuth.WANT) {
- return SslClientAuthMode.REQUESTED;
- }
- return SslClientAuthMode.NOT_REQUESTED;
- }
-
- private KeyManager[] getKeyManagers(Ssl ssl, SslStoreProvider sslStoreProvider) {
- try {
- KeyStore keyStore = getKeyStore(ssl, sslStoreProvider);
- SslConfigurationValidator.validateKeyAlias(keyStore, ssl.getKeyAlias());
- KeyManagerFactory keyManagerFactory = KeyManagerFactory
- .getInstance(KeyManagerFactory.getDefaultAlgorithm());
- String keyPassword = (sslStoreProvider != null) ? sslStoreProvider.getKeyPassword() : null;
- if (keyPassword == null) {
- keyPassword = (ssl.getKeyPassword() != null) ? ssl.getKeyPassword() : ssl.getKeyStorePassword();
- }
- keyManagerFactory.init(keyStore, (keyPassword != null) ? keyPassword.toCharArray() : null);
- if (ssl.getKeyAlias() != null) {
- return getConfigurableAliasKeyManagers(ssl, keyManagerFactory.getKeyManagers());
- }
- return keyManagerFactory.getKeyManagers();
- }
- catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- private KeyManager[] getConfigurableAliasKeyManagers(Ssl ssl, KeyManager[] keyManagers) {
- for (int i = 0; i < keyManagers.length; i++) {
- if (keyManagers[i] instanceof X509ExtendedKeyManager) {
- keyManagers[i] = new ConfigurableAliasKeyManager((X509ExtendedKeyManager) keyManagers[i],
- ssl.getKeyAlias());
- }
- }
- return keyManagers;
- }
-
- private KeyStore getKeyStore(Ssl ssl, SslStoreProvider sslStoreProvider) throws Exception {
- if (sslStoreProvider != null) {
- return sslStoreProvider.getKeyStore();
- }
- return loadKeyStore(ssl.getKeyStoreType(), ssl.getKeyStoreProvider(), ssl.getKeyStore(),
- ssl.getKeyStorePassword());
- }
-
- private TrustManager[] getTrustManagers(Ssl ssl, SslStoreProvider sslStoreProvider) {
- try {
- KeyStore store = getTrustStore(ssl, sslStoreProvider);
- TrustManagerFactory trustManagerFactory = TrustManagerFactory
- .getInstance(TrustManagerFactory.getDefaultAlgorithm());
- trustManagerFactory.init(store);
- return trustManagerFactory.getTrustManagers();
- }
- catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- private KeyStore getTrustStore(Ssl ssl, SslStoreProvider sslStoreProvider) throws Exception {
- if (sslStoreProvider != null) {
- return sslStoreProvider.getTrustStore();
- }
- return loadTrustStore(ssl.getTrustStoreType(), ssl.getTrustStoreProvider(), ssl.getTrustStore(),
- ssl.getTrustStorePassword());
- }
-
- private KeyStore loadKeyStore(String type, String provider, String resource, String password) throws Exception {
- return loadStore(type, provider, resource, password);
- }
-
- private KeyStore loadTrustStore(String type, String provider, String resource, String password) throws Exception {
- if (resource == null) {
- return null;
- }
- return loadStore(type, provider, resource, password);
- }
-
- private KeyStore loadStore(String type, String provider, String resource, String password) throws Exception {
- type = (type != null) ? type : "JKS";
- KeyStore store = (provider != null) ? KeyStore.getInstance(type, provider) : KeyStore.getInstance(type);
- try {
- URL url = ResourceUtils.getURL(resource);
- try (InputStream stream = url.openStream()) {
- store.load(stream, (password != null) ? password.toCharArray() : null);
- }
- return store;
- }
- catch (Exception ex) {
- throw new WebServerException("Could not load key store '" + resource + "'", ex);
- }
- }
-
- /**
- * {@link X509ExtendedKeyManager} that supports custom alias configuration.
- */
- private static class ConfigurableAliasKeyManager extends X509ExtendedKeyManager {
-
- private final X509ExtendedKeyManager keyManager;
-
- private final String alias;
-
- ConfigurableAliasKeyManager(X509ExtendedKeyManager keyManager, String alias) {
- this.keyManager = keyManager;
- this.alias = alias;
- }
-
- @Override
- public String chooseEngineClientAlias(String[] strings, Principal[] principals, SSLEngine sslEngine) {
- return this.keyManager.chooseEngineClientAlias(strings, principals, sslEngine);
- }
-
- @Override
- public String chooseEngineServerAlias(String s, Principal[] principals, SSLEngine sslEngine) {
- if (this.alias == null) {
- return this.keyManager.chooseEngineServerAlias(s, principals, sslEngine);
- }
- return this.alias;
- }
-
- @Override
- public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
- return this.keyManager.chooseClientAlias(keyType, issuers, socket);
- }
-
- @Override
- public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
- return this.keyManager.chooseServerAlias(keyType, issuers, socket);
- }
-
- @Override
- public X509Certificate[] getCertificateChain(String alias) {
- return this.keyManager.getCertificateChain(alias);
- }
-
- @Override
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return this.keyManager.getClientAliases(keyType, issuers);
- }
-
- @Override
- public PrivateKey getPrivateKey(String alias) {
- return this.keyManager.getPrivateKey(alias);
- }
-
- @Override
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return this.keyManager.getServerAliases(keyType, issuers);
- }
-
- }
-
-}
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslGlobalTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslGlobalTest.java
deleted file mode 100644
index ccf6666c4c5..00000000000
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/ssl/SslGlobalTest.java
+++ /dev/null
@@ -1,250 +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.component.cxf.soap.springboot.ssl;
-
-
-
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.SSLContextParametersAware;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.cxf.GreeterImpl;
-import org.apache.camel.component.cxf.common.CXFTestSupport;
-import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
... 3631 lines suppressed ...