Improve the CXF extension and its tests:
* Target release is 2.12.0
* Added native tests
* Fixed some issues in native mode
* Make one of the service tests to use the Java service client rather
than rest-assured
diff --git a/docs/modules/ROOT/examples/components/cxf.yml b/docs/modules/ROOT/examples/components/cxf.yml
index a98b6ae..a746378 100644
--- a/docs/modules/ROOT/examples/components/cxf.yml
+++ b/docs/modules/ROOT/examples/components/cxf.yml
@@ -5,8 +5,8 @@
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
-cqJvmSince: 2.11.0
-cqNativeSince: 2.11.0
+cqJvmSince: 2.12.0
+cqNativeSince: 2.12.0
cqCamelPartName: cxf
cqCamelPartTitle: CXF
cqCamelPartDescription: Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.
diff --git a/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc b/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc
index 559d993..4e1f45a 100644
--- a/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/cxf-soap.adoc
@@ -8,11 +8,11 @@
:cq-status-deprecation: Stable
:cq-description: Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.
:cq-deprecated: false
-:cq-jvm-since: 2.11.0
-:cq-native-since: 2.11.0
+:cq-jvm-since: 2.12.0
+:cq-native-since: 2.12.0
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##2.11.0## [.badge-key]##Native since##[.badge-supported]##2.11.0##
+[.badge-key]##JVM since##[.badge-supported]##2.12.0## [.badge-key]##Native since##[.badge-supported]##2.12.0##
Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.
diff --git a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java
index e312cec..5b89395 100644
--- a/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java
+++ b/extensions/cxf-soap/deployment/src/main/java/org/apache/camel/quarkus/component/cxf/soap/deployment/CxfSoapProcessor.java
@@ -22,6 +22,7 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import org.jboss.jandex.DotName;
@@ -45,15 +46,28 @@
}
@BuildStep
+ void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexDependencies) {
+ Stream.of(
+ "jakarta.xml.ws:jakarta.xml.ws-api",
+ "org.apache.cxf:cxf-core",
+ "org.apache.cxf:cxf-rt-frontend-jaxws",
+ "org.apache.cxf:cxf-rt-transports-http",
+ "org.apache.cxf:cxf-rt-features-logging",
+ "org.apache.cxf:cxf-rt-bindings-soap")
+ .forEach(ga -> {
+ String[] coords = ga.split(":");
+ indexDependencies.produce(new IndexDependencyBuildItem(coords[0], coords[1]));
+ });
+ }
+
+ @BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) {
+
IndexView index = combinedIndex.getIndex();
Stream.of(
- "org.apache.cxf.feature.AbstractFeature",
- "org.apache.wss4j.dom.handler.WSHandler",
- "org.apache.cxf.phase.AbstractPhaseInterceptor",
- "org.apache.cxf.binding.soap.interceptor.AbstractSOAPInterceptor",
- "org.apache.cxf.phase.PhaseInterceptor")
+ org.apache.cxf.ext.logging.LoggingFeature.class.getName(),
+ "org.apache.wss4j.dom.handler.WSHandler")
.map(DotName::createSimple)
.flatMap(dotName -> index.getAllKnownSubclasses(dotName).stream())
.map(classInfo -> classInfo.name().toString())
@@ -61,7 +75,6 @@
.forEach(reflectiveClass::produce);
Stream.of(
- "org.apache.cxf.feature.Feature",
"org.apache.cxf.interceptor.Interceptor",
"org.apache.cxf.binding.soap.interceptor.SoapInterceptor",
"org.apache.cxf.phase.PhaseInterceptor")
@@ -70,5 +83,14 @@
.map(classInfo -> classInfo.name().toString())
.map(className -> new ReflectiveClassBuildItem(false, false, className))
.forEach(reflectiveClass::produce);
+
+ Stream.of(
+ "org.apache.cxf.feature.Feature")
+ .map(DotName::createSimple)
+ .flatMap(dotName -> index.getAllKnownImplementors(dotName).stream())
+ .map(classInfo -> classInfo.name().toString())
+ .map(className -> new ReflectiveClassBuildItem(true, false, className))
+ .forEach(reflectiveClass::produce);
+
}
}
diff --git a/extensions/cxf-soap/runtime/pom.xml b/extensions/cxf-soap/runtime/pom.xml
index ccfe239..d557799 100644
--- a/extensions/cxf-soap/runtime/pom.xml
+++ b/extensions/cxf-soap/runtime/pom.xml
@@ -33,8 +33,8 @@
<description>Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.</description>
<properties>
- <camel.quarkus.jvmSince>2.11.0</camel.quarkus.jvmSince>
- <camel.quarkus.nativeSince>2.11.0</camel.quarkus.nativeSince>
+ <camel.quarkus.jvmSince>2.12.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>2.12.0</camel.quarkus.nativeSince>
</properties>
<dependencies>
@@ -60,6 +60,11 @@
<artifactId>quarkus-cxf</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.graalvm.nativeimage</groupId>
+ <artifactId>svm</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/CxfSoapSubstitutions.java b/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/CxfSoapSubstitutions.java
new file mode 100644
index 0000000..4a21431
--- /dev/null
+++ b/extensions/cxf-soap/runtime/src/main/java/org/apache/camel/quarkus/component/cxf/soap/graal/CxfSoapSubstitutions.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cxf.soap.graal;
+
+import com.oracle.svm.core.annotate.Substitute;
+import com.oracle.svm.core.annotate.TargetClass;
+
+final class CxfSoapSubstitutions {
+
+}
+
+@TargetClass(className = "javax.xml.soap.FactoryFinder")
+final class SubstituteUnaryExpression {
+
+ /**
+ * The target method wants to read a properties file under {@code java.home} which does not work on GraalVM (there is no
+ * JRE distro at native runtime).
+ *
+ * @param factoryId
+ * @param deprecatedFactoryId
+ * @return
+ */
+ @Substitute
+ private static String fromJDKProperties(String factoryId, String deprecatedFactoryId) {
+ return null;
+ }
+}
diff --git a/integration-tests/cxf-soap/pom.xml b/integration-tests/cxf-soap/pom.xml
index 9f1a274..3c1626b 100644
--- a/integration-tests/cxf-soap/pom.xml
+++ b/integration-tests/cxf-soap/pom.xml
@@ -81,10 +81,6 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-xml-io-dsl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
@@ -96,17 +92,9 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
- <dependency>
- <groupId>jakarta.servlet</groupId>
- <artifactId>jakarta.servlet-api</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
- <artifactId>quarkus-cxf</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-ws-security</artifactId>
</dependency>
diff --git a/integration-tests/cxf-soap/src/test/java/com/helloworld/service/CodeFirstService.java b/integration-tests/cxf-soap/src/main/java/com/helloworld/service/CodeFirstService.java
similarity index 100%
rename from integration-tests/cxf-soap/src/test/java/com/helloworld/service/CodeFirstService.java
rename to integration-tests/cxf-soap/src/main/java/com/helloworld/service/CodeFirstService.java
diff --git a/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapResource.java b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapResource.java
index 1e8fb13..5a01690 100644
--- a/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapResource.java
+++ b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapResource.java
@@ -21,9 +21,11 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -46,75 +48,38 @@
@Inject
ProducerTemplate producerTemplate;
- @Path("/load/component/cxf")
- @GET
+ @Path("/simple/{endpoint}")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentCxf() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_CXF) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_CXF);
- return Response.status(500, COMPONENT_CXF + " could not be loaded from the Camel context").build();
- }
-
- @Path("/sendSimpleSoapRequest")
- @GET
- @Consumes(MediaType.WILDCARD)
- @Produces(MediaType.WILDCARD)
- public Response sendSimpleRequest() throws Exception {
- LOG.infof("Sending to cxf: %s", "CamelQuarkusCXF");
- final String response = producerTemplate.requestBody("direct:sendSimpleSoapRequest", "CamelQuarkusCXF", String.class);
- LOG.infof("Got response from cxf: %s", response);
+ public Response sendSimpleRequest(@PathParam("endpoint") String endpoint, String body) throws Exception {
+ //LOG.infof("Sending to cxf: %s", "CamelQuarkusCXF");
+ final String response = producerTemplate.requestBody("direct:" + endpoint, body, String.class);
+ //LOG.infof("Got response from cxf: %s", response);
return Response
.created(new URI("https://camel.apache.org/"))
.entity(response)
.build();
}
- @Path("/wsSecurity")
- @GET
+ @Path("/person/{endpoint}")
+ @POST
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.WILDCARD)
- public Response wsSecurity() throws Exception {
- LOG.infof("Sending to cxf: %s", "CamelQuarkusCXF");
- final String response = producerTemplate.requestBody("direct:wsSecurity", "CamelQuarkusCXF", String.class);
- LOG.infof("Got response from cxf: %s", response);
- return Response
- .created(new URI("https://camel.apache.org/"))
- .entity(response)
- .build();
- }
-
- @Path("/sendComplexSoapRequest")
- @GET
- @Consumes(MediaType.WILDCARD)
- @Produces(MediaType.WILDCARD)
- public Response sendComplexSoapRequest() throws Exception {
+ public Response person(@PathParam("endpoint") String endpoint, @QueryParam("lastName") String lastName,
+ @QueryParam("firstName") String firstName)
+ throws Exception {
PersonRequestType personRequestType = new PersonRequestType();
- personRequestType.setFirstName("Camel Quarkus");
- personRequestType.setLastName("CXF");
- LOG.infof("Sending to cxf: %s", personRequestType);
- final PersonResponseType response = producerTemplate.requestBody("direct:sendComplexSoapRequest", personRequestType,
+ personRequestType.setFirstName(firstName);
+ personRequestType.setLastName(lastName);
+ //LOG.infof("Sending to cxf: %s", personRequestType);
+ final PersonResponseType response = producerTemplate.requestBody("direct:" + endpoint, personRequestType,
PersonResponseType.class);
- LOG.infof("Got response from cxf: %s", response);
+ //LOG.infof("Got response from cxf: %s", response);
return Response
.created(new URI("https://camel.apache.org/"))
.entity(response.toString())
.build();
}
- @Path("/soapService")
- @GET
- @Consumes(MediaType.WILDCARD)
- @Produces(MediaType.WILDCARD)
- public Response soapService() throws Exception {
- LOG.infof("Sending to cxf: %s", "CamelQuarkusCXF");
- final String response = producerTemplate.requestBody("direct:helloService", "CamelQuarkusCXF", String.class);
- LOG.infof("Got response from cxf: %s", response);
- return Response
- .created(new URI("https://camel.apache.org/"))
- .entity(response)
- .build();
- }
}
diff --git a/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapRoutes.java b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapRoutes.java
new file mode 100644
index 0000000..40f25f2
--- /dev/null
+++ b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapRoutes.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cxf.soap.it;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+
+public class CxfSoapRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+
+ /* Client */
+ from("direct:simpleSoapClient")
+ .to("cxf:bean:soapClientEndpoint?dataFormat=POJO");
+
+ from("direct:wsSecurityClient")
+ .to("cxf:bean:secureEndpoint?dataFormat=POJO");
+
+ from("direct:complexSoapClient")
+ .setHeader(CxfConstants.OPERATION_NAME).constant("Person")
+ .to("cxf:bean:soapClientEndpoint?dataFormat=POJO");
+
+ /* Service */
+ from("cxf:bean:soapServiceEndpoint")
+ .setBody().simple("Hello ${body} from CXF service");
+
+ from("cxf:bean:codeFirstServiceEndpoint")
+ .setBody().constant("Hello CamelQuarkusCXF");
+ }
+}
diff --git a/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/PasswordCallback.java b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/PasswordCallback.java
index 55d5f56..2527932 100644
--- a/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/PasswordCallback.java
+++ b/integration-tests/cxf-soap/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/PasswordCallback.java
@@ -25,6 +25,7 @@
import javax.security.auth.callback.UnsupportedCallbackException;
import io.quarkus.runtime.annotations.RegisterForReflection;
+import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@RegisterForReflection
@@ -42,17 +43,8 @@
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
- try {
- String id = (String) callback.getClass().getMethod("getIdentifier").invoke(callback);
- String pass = getPassword();
- if (pass != null) {
- callback.getClass().getMethod("setPassword", String.class).invoke(callback, pass);
- return;
- }
- } catch (Exception ex) {
- UnsupportedCallbackException e = new UnsupportedCallbackException(callback);
- e.initCause(ex);
- throw e;
+ if (callback instanceof WSPasswordCallback) {
+ ((WSPasswordCallback) callback).setPassword(password);
}
}
}
diff --git a/integration-tests/cxf-soap/src/main/resources/application.properties b/integration-tests/cxf-soap/src/main/resources/application.properties
index f5b73f7..fb91160 100644
--- a/integration-tests/cxf-soap/src/main/resources/application.properties
+++ b/integration-tests/cxf-soap/src/main/resources/application.properties
@@ -14,14 +14,6 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-camel.context.name = camel-quarkus-integration-tests-cxf-soap
-
-#
-# Main
-#
-camel.main.routes-include-pattern=classpath:routes/cxf-client-routes.xml,classpath:routes/cxf-service-routes.xml
-
-camel.main.startup-summary-level = verbose
password-callback.username=camel
password-callback.password=quarkus
@@ -64,5 +56,4 @@
camel.beans.codeFirstServiceEndpoint.features[0]=#bean:loggingFeature
quarkus.cxf.path=/soapservice
-quarkus.native.resources.includes = wsdl/*.wsdl,*.xml
-quarkus.log.level=INFO
+quarkus.native.resources.includes = wsdl/*.wsdl
diff --git a/integration-tests/cxf-soap/src/main/resources/routes/cxf-client-routes.xml b/integration-tests/cxf-soap/src/main/resources/routes/cxf-client-routes.xml
deleted file mode 100644
index 6855633..0000000
--- a/integration-tests/cxf-soap/src/main/resources/routes/cxf-client-routes.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<routes id="cxf"
- xmlns="http://camel.apache.org/schema/spring"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <route id="cxfClient1">
- <from uri="direct:sendSimpleSoapRequest"/>
- <to uri="cxf:bean:soapClientEndpoint?dataFormat=POJO" pattern="InOut"/>
- </route>
-
- <route id="cxfClient2">
- <from uri="direct:wsSecurity"/>
- <to uri="cxf:bean:secureEndpoint?dataFormat=POJO" pattern="InOut"/>
- </route>
-
- <route id="cxfClient3">
- <from uri="direct:sendComplexSoapRequest"/>
- <setHeader name="operationName">
- <constant>Person</constant>
- </setHeader>
- <to uri="cxf:bean:soapClientEndpoint?dataFormat=POJO" pattern="InOut"/>
- </route>
-
-</routes>
\ No newline at end of file
diff --git a/integration-tests/cxf-soap/src/main/resources/routes/cxf-service-routes.xml b/integration-tests/cxf-soap/src/main/resources/routes/cxf-service-routes.xml
deleted file mode 100644
index 1ad41d2..0000000
--- a/integration-tests/cxf-soap/src/main/resources/routes/cxf-service-routes.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<routes id="cxf"
- xmlns="http://camel.apache.org/schema/spring"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
- <route id="cxfService1">
- <from uri="cxf:bean:soapServiceEndpoint"/>
- <setBody>
- <constant>Hello CamelQuarkusCXF</constant>
- </setBody>
- </route>
-
- <route id="cxfService2">
- <from uri="cxf:bean:codeFirstServiceEndpoint"/>
- <setBody>
- <constant>Hello CamelQuarkusCXF</constant>
- </setBody>
- </route>
-
-</routes>
\ No newline at end of file
diff --git a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientIT.java b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientIT.java
new file mode 100644
index 0000000..da87d1e
--- /dev/null
+++ b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cxf.soap.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class CxfSoapClientIT extends CxfSoapClientTest {
+}
diff --git a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientTest.java b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientTest.java
index 155e9d6..6234c6d 100644
--- a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientTest.java
+++ b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapClientTest.java
@@ -17,52 +17,48 @@
package org.apache.camel.quarkus.component.cxf.soap.it;
import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.DisabledOnIntegrationTest;
+import io.quarkus.test.junit.DisabledOnIntegrationTest.ArtifactType;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
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.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
@QuarkusTest
@QuarkusTestResource(CxfSoapClientTestResource.class)
class CxfSoapClientTest {
@Test
- public void loadComponentCxf() {
- /* A simple autogenerated test */
- RestAssured.get("/cxf-soap/load/component/cxf")
+ public void simpleSoapClient() {
+ RestAssured.given()
+ .body("CamelQuarkusCXF")
+ .post("/cxf-soap/simple/simpleSoapClient")
.then()
- .statusCode(200);
+ .statusCode(201)
+ .body(is("Hello CamelQuarkusCXF"));
}
@Test
- public void testSimpleSoapClient() {
- final String response = RestAssured.get("/cxf-soap/sendSimpleSoapRequest")
+ @DisabledOnIntegrationTest(forArtifactTypes = ArtifactType.NATIVE_BINARY, value = "https://github.com/apache/camel-quarkus/issues/3966")
+ public void wsSecurityClient() {
+ RestAssured.given()
+ .body("CamelQuarkusCXF")
+ .post("/cxf-soap/simple/wsSecurityClient")
.then()
.statusCode(201)
- .assertThat()
- .extract().asString();
- assertEquals("Hello CamelQuarkusCXF", response);
+ .body(is("Hello WSSecurity CamelQuarkusCXF"));
}
@Test
- public void testWSSecurity() {
- final String response = RestAssured.get("/cxf-soap/wsSecurity")
+ public void complexSoapClient() {
+ RestAssured.given()
+ .queryParam("firstName", "Camel Quarkus")
+ .queryParam("lastName", "CXF")
+ .post("/cxf-soap/person/complexSoapClient")
.then()
.statusCode(201)
- .assertThat()
- .extract().asString();
- assertEquals("Hello WSSecurity CamelQuarkusCXF", response);
- }
-
- @Test
- public void testComplexSoapClient() {
- final String response = RestAssured.get("/cxf-soap/sendComplexSoapRequest")
- .then()
- .statusCode(201)
- .assertThat()
- .extract().asString();
- assertTrue(response.contains("greeting=Hello"));
+ .body(containsString("greeting=Hello,firstName=Camel Quarkus,lastName=CXF"));
}
}
diff --git a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceIT.java b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceIT.java
new file mode 100644
index 0000000..82aedb4
--- /dev/null
+++ b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.cxf.soap.it;
+
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+
+@QuarkusIntegrationTest
+class CxfSoapServiceIT extends CxfSoapServiceTest {
+}
diff --git a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceTest.java b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceTest.java
index 8b08e62..b886be3 100644
--- a/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceTest.java
+++ b/integration-tests/cxf-soap/src/test/java/org/apache/camel/quarkus/component/cxf/soap/it/CxfSoapServiceTest.java
@@ -16,38 +16,41 @@
*/
package org.apache.camel.quarkus.component.cxf.soap.it;
+import javax.xml.ws.BindingProvider;
+
+import com.helloworld.service.HelloPortType;
+import com.helloworld.service.HelloService;
+import io.quarkus.runtime.LaunchMode;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
+import org.assertj.core.api.Assertions;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
@QuarkusTest
class CxfSoapServiceTest {
@Test
- public void testSimpleSoapService() {
- final String response = RestAssured.given()
- .contentType(ContentType.XML)
- .body("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://www.helloworld.com/Service/\">\n"
- +
- " <soapenv:Header/>\n" +
- " <soapenv:Body>\n" +
- " <ser:HelloRequest>HelloWorld</ser:HelloRequest>\n" +
- " </soapenv:Body>\n" +
- "</soapenv:Envelope>")
- .post("/soapservice/hello")
- .then()
- .statusCode(200)
- .assertThat()
- .extract().asString();
+ public void simpleSoapService() {
+ final HelloService service = new HelloService();
+ final HelloPortType helloPort = service.getHelloPort();
+ String endpointURL = getServerUrl() + "/soapservice/hello";
+ ((BindingProvider) helloPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
+ Assertions.assertThat(helloPort.hello("World")).isEqualTo("Hello World from CXF service");
+ }
- assertTrue(response.contains("Hello CamelQuarkusCXF"));
+ private static String getServerUrl() {
+ Config config = ConfigProvider.getConfig();
+ final int port = LaunchMode.current().equals(LaunchMode.TEST) ? config.getValue("quarkus.http.test-port", Integer.class)
+ : config.getValue("quarkus.http.port", Integer.class);
+ return String.format("http://localhost:%d", port);
}
@Test
public void testCodeFirstSoapService() {
+
final String response = RestAssured.given()
.contentType(ContentType.XML)
.body("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://www.helloworld.com/CodeFirstService/\">\n"
@@ -63,7 +66,7 @@
.assertThat()
.extract().asString();
- assertTrue(response.contains("Hello CamelQuarkusCXF"));
+ org.junit.jupiter.api.Assertions.assertTrue(response.contains("Hello CamelQuarkusCXF"));
}
}