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/12/08 17:06:27 UTC
[camel-spring-boot] branch main updated: [CAMEL-18783]test scenarios in CSB
This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 8e81bdd187b [CAMEL-18783]test scenarios in CSB
8e81bdd187b is described below
commit 8e81bdd187b6b40b659d763671755c95815e1a68
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Dec 8 12:06:18 2022 -0500
[CAMEL-18783]test scenarios in CSB
---
.../{CxfTimeoutTest.java => CxfBeanScopeTest.java} | 57 ++++++++++++++--------
.../cxf/soap/springboot/CxfTimeoutTest.java | 2 +
.../soap/headers/CxfMessageHeadersRelayTest.java | 3 ++
.../cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java | 2 +
4 files changed, 45 insertions(+), 19 deletions(-)
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/CxfBeanScopeTest.java
similarity index 81%
copy from components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfTimeoutTest.java
copy to components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/CxfBeanScopeTest.java
index 747cf58b95a..6e6b0bd4183 100644
--- 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/CxfBeanScopeTest.java
@@ -27,6 +27,7 @@ import javax.xml.ws.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.GreeterImplWithSleep;
import org.apache.camel.component.cxf.common.CXFTestSupport;
@@ -45,6 +46,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
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;
@@ -52,6 +54,7 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
import org.springframework.test.annotation.DirtiesContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.cxf.endpoint.Client;
@@ -65,11 +68,11 @@ import org.apache.hello_world_soap_http.Greeter;
@DirtiesContext
@CamelSpringBootTest
@SpringBootTest(classes = {
- CamelAutoConfiguration.class, CxfTimeoutTest.class,
- CxfTimeoutTest.TestConfiguration.class,
+ CamelAutoConfiguration.class, CxfBeanScopeTest.class,
+ CxfBeanScopeTest.TestConfiguration.class,
CxfAutoConfiguration.class
}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-public class CxfTimeoutTest {
+public class CxfBeanScopeTest {
static int port = CXFTestSupport.getPort1();;
@@ -94,30 +97,35 @@ public class CxfTimeoutTest {
+
@Test
- public void testInvokingJaxWsServerWithBusUriParams() throws Exception {
- sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + "?serviceClass=org.apache.hello_world_soap_http.Greeter&bus=#cxf&cxfConfigurer=#origConfigurer");
+ public void testSingltonScopeWithConflict() throws Exception {
+ try {
+ sendTimeOutMessage("cxf://bean:springEndpoint");
+ fail("Should get the Exception here.");
+ } catch (ResolveEndpointFailedException ex) {
+ assertTrue(ex.getMessage().contains(
+ "Different URI refer to the same CxfEndpoint Bean instance"));
+ }
}
-
+
@Test
- public void testInvokingJaxWsServerWithoutBusUriParams() throws Exception {
- sendTimeOutMessage("cxf://" + JAXWS_SERVER_ADDRESS + "?serviceClass=org.apache.hello_world_soap_http.Greeter&cxfConfigurer=#origConfigurer");
+ public void testSingltonScopeWithoutConflict() throws Exception {
+ sendTimeOutMessage("cxf://bean:springEndpoint?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier");
}
-
+
@Test
- public void testInvokingJaxWsServerWithCxfEndpoint() throws Exception {
- sendTimeOutMessage("cxf://bean:springEndpoint");
+ public void testSingltonScopeWithoutConflictWithDifferentParaOrder() throws Exception {
+ sendTimeOutMessage("cxf://bean:springEndpoint?hostnameVerifier=#defaultHostnameVerifier&sslContextParameters=#mySslContext");
}
-
+
@Test
- public void testInvokingFromCamelRoute() throws Exception {
- sendTimeOutMessage("direct:start");
+ public void testPrototyeScopeWithoutConflict() throws Exception {
+ //since it's prototype scope, so can't cause conflict even with different parameters
+ sendTimeOutMessage("cxf://bean:springEndpointNoParas?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier");
}
- @Test
- public void testDoCatchWithTimeOutException() throws Exception {
- sendTimeOutMessage("direct:doCatch");
- }
+
protected void sendTimeOutMessage(String endpointUri) throws Exception {
Exchange reply = sendJaxWsMessage(endpointUri);
@@ -246,6 +254,17 @@ public class CxfTimeoutTest {
return cxfEndpoint;
}
+ @Bean
+ @Scope("prototype")
+ CxfEndpoint springEndpointNoParas() {
+
+ 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() {
@@ -255,7 +274,7 @@ public class CxfTimeoutTest {
from("direct:start").
to("cxf:bean:springEndpoint?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier");
from("direct:doCatch").
- to("cxf:bean:springEndpoint");
+ to("cxf:bean:springEndpointNoParas");
}
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
index 747cf58b95a..80663f9ac65 100644
--- 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
@@ -52,6 +52,7 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
import org.springframework.test.annotation.DirtiesContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.cxf.endpoint.Client;
@@ -237,6 +238,7 @@ public class CxfTimeoutTest {
@Bean
+ @Scope("prototype")
CxfEndpoint springEndpoint() {
CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
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
index 62d1a642968..5a9d6a35459 100644
--- 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
@@ -84,6 +84,7 @@ import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFa
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
import org.springframework.test.annotation.DirtiesContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.cxf.binding.soap.SoapHeader;
@@ -883,6 +884,7 @@ public class CxfMessageHeadersRelayTest {
@Bean
+ @Scope("prototype")
CxfEndpoint routerNoRelayNoServiceClassEndpoint(HeaderFilterStrategy dropAllMessageHeadersStrategy) {
CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerNoRelayNoServiceClassEndpoint");
@@ -914,6 +916,7 @@ public class CxfMessageHeadersRelayTest {
}
@Bean
+ @Scope("prototype")
CxfEndpoint serviceExtraRelays(HeaderFilterStrategy customMessageFilterStrategy) {
CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/serviceExtraRelays");
diff --git a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java
index d6983feb7f5..f9f958a1430 100644
--- a/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java
+++ b/components-starter/camel-cxf-soap-starter/src/test/java/org/apache/camel/component/cxf/soap/springboot/wsdl/CxfWsdlFirstTest.java
@@ -37,6 +37,7 @@ 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.context.annotation.Scope;
import org.springframework.test.annotation.DirtiesContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.camel.wsdl_first.PersonImpl;
@@ -98,6 +99,7 @@ public class CxfWsdlFirstTest extends AbstractCxfWsdlFirstTest {
}
@Bean
+ @Scope("prototype")
CxfEndpoint serviceEndpoint() {
CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
cxfEndpoint.setServiceNameAsQName(serviceName);