You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dk...@apache.org on 2011/06/29 15:25:00 UTC
svn commit: r1141094 [1/2] - in /camel/trunk/components/camel-cxf: ./
src/test/java/org/apache/camel/component/cxf/
src/test/java/org/apache/camel/component/cxf/jaxrs/
src/test/java/org/apache/camel/component/cxf/spring/
src/test/java/org/apache/camel/...
Author: dkulp
Date: Wed Jun 29 13:24:58 2011
New Revision: 1141094
URL: http://svn.apache.org/viewvc?rev=1141094&view=rev
Log:
[CAMEL-4095] Start of using dynamic ports in CXF unit tests. About 1/2
done, but commit was getting too large. :-)
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java
- copied, changed from r1141062, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCxfWsdlFirstTest.java
- copied, changed from r1141062, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfSpringRouterBeans.xml
- copied, changed from r1141062, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfEndpointBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointPayloadBeans.xml
- copied, changed from r1141062, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml
Modified:
camel/trunk/components/camel-cxf/pom.xml
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerFaultTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerMessageTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadMarshalFaultTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomerStartStopTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadWithFeatureRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyPayloadModeTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageCustomizedExceptionTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadCustomizedExceptionTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSpringRouterTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstPayloadModeTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstProcessorTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/LoggingInterceptorInMessageModeTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsa/WSAddressingTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CamelCxfConsumerContext.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfEndpointBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithFeatureBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsForProducer.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/LoggingInterceptorInMessageModeTest-context.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeansPayloadMode.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstProcessor.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlOnlyBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringProducer.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringProducerAddressOverride.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/FileToCxfMessageDataFormatTest.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsa/WSAddressingTest-context.xml
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsa/client.xml
Modified: camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Wed Jun 29 13:24:58 2011
@@ -211,9 +211,12 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <forkMode>pertest</forkMode>
<childDelegation>false</childDelegation>
- <useFile>true</useFile>
+ <forkMode>pertest</forkMode>
+ <!--forkMode>once</forkMode>
+ <reportFormat>brief</reportFormat>
+ <useFile>false</useFile-->
+ <runOrder>alphabetical</runOrder>
<systemPropertyVariables>
<java.util.logging.config.file>${basedir}/target/test-classes/logging.properties</java.util.logging.config.file>
</systemPropertyVariables>
Copied: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java (from r1141062, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java?p2=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java&p1=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java&r1=1141062&r2=1141094&rev=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java Wed Jun 29 13:24:58 2011
@@ -36,7 +36,7 @@ import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class CXFGreeterRouterTest extends CamelTestSupport {
+public abstract class AbstractCXFGreeterRouterTest extends CamelTestSupport {
protected static Endpoint endpoint;
protected AbstractXmlApplicationContext applicationContext;
@@ -51,6 +51,13 @@ public class CXFGreeterRouterTest extend
+ "<faultType>NoSuchCodeLitFault</faultType></testDocLitFault>"
+ "</soap:Body></soap:Envelope>";
+ public abstract String getPort1();
+
+ public abstract String getPort2();
+
+
+ protected abstract ClassPathXmlApplicationContext createApplicationContext();
+
@Before
public void setUp() throws Exception {
applicationContext = createApplicationContext();
@@ -67,12 +74,6 @@ public class CXFGreeterRouterTest extend
super.tearDown();
}
- @BeforeClass
- public static void startService() {
- Object implementor = new GreeterImpl();
- String address = "http://localhost:9000/SoapContext/SoapPort";
- endpoint = Endpoint.publish(address, implementor);
- }
@AfterClass
public static void stopService() {
@@ -85,7 +86,7 @@ public class CXFGreeterRouterTest extend
public void testInvokingServiceFromCXFClient() throws Exception {
Service service = Service.create(serviceName);
service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/",
- "http://localhost:9003/CamelContext/RouterPort");
+ "http://localhost:" + getPort2() + "/CamelContext/RouterPort");
Greeter greeter = service.getPort(routerPortName, Greeter.class);
String reply = greeter.greetMe("test");
@@ -112,7 +113,7 @@ public class CXFGreeterRouterTest extend
@Test
public void testRoutingSOAPFault() throws Exception {
try {
- template.sendBody("http://localhost:9003/CamelContext/RouterPort", testDocLitFaultBody);
+ template.sendBody("http://localhost:" + getPort2() + "/CamelContext/RouterPort", testDocLitFaultBody);
fail("Should get an exception here.");
} catch (RuntimeCamelException exception) {
assertTrue("It should get the response error", exception.getCause() instanceof HttpOperationFailedException);
@@ -122,7 +123,7 @@ public class CXFGreeterRouterTest extend
@Test
public void testPublishEndpointUrl() throws Exception {
- String response = template.requestBody("http://localhost:9003/CamelContext/RouterPort?wsdl", null, String.class);
+ String response = template.requestBody("http://localhost:" + getPort2() + "/CamelContext/RouterPort?wsdl", null, String.class);
assertTrue("Can't find the right service location.", response.indexOf("http://www.simple.com/services/test") > 0);
}
@@ -131,10 +132,6 @@ public class CXFGreeterRouterTest extend
return SpringCamelContext.springCamelContext(applicationContext);
}
-
- protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml");
- }
}
Copied: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCxfWsdlFirstTest.java (from r1141062, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCxfWsdlFirstTest.java?p2=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCxfWsdlFirstTest.java&p1=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java&r1=1141062&r2=1141094&rev=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCxfWsdlFirstTest.java Wed Jun 29 13:24:58 2011
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;
import javax.xml.ws.WebServiceException;
@@ -28,6 +29,7 @@ import javax.xml.ws.WebServiceException;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.apache.camel.wsdl_first.JaxwsTestHandler;
import org.apache.camel.wsdl_first.Person;
@@ -38,19 +40,9 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class CxfWsdlFirstTest extends CamelSpringTestSupport {
-
- protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/WsdlFirstBeans.xml");
- }
-
- @BeforeClass
- public static void startService() {
- Object implementor = new PersonImpl();
- String address = "http://localhost:9000/PersonService/";
- Endpoint.publish(address, implementor);
- }
-
+public abstract class AbstractCxfWsdlFirstTest extends CamelSpringTestSupport {
+ public abstract String getPort();
+
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
@@ -63,6 +55,10 @@ public class CxfWsdlFirstTest extends Ca
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first", "PersonService"));
Person client = ss.getSoap();
+ ((BindingProvider)client).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + getPort() + "/PersonService/");
+
Holder<String> personId = new Holder<String>();
personId.value = "hello";
Holder<String> ssn = new Holder<String>();
@@ -84,7 +80,9 @@ public class CxfWsdlFirstTest extends Ca
fail("We expect to get the WebSerivceException here");
} catch (WebServiceException ex) {
// Caught expected WebServiceException here
- assertTrue("Should get the xml vaildate error!", ex.getMessage().indexOf("MyStringType") > 0);
+ assertTrue("Should get the xml vaildate error! " + ex.getMessage(),
+ ex.getMessage().indexOf("MyStringType") > 0
+ || ex.getMessage().indexOf("Could not parse the XML stream") != -1);
}
verifyJaxwsHandlers(fromHandler, toHandler);
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java Wed Jun 29 13:24:58 2011
@@ -24,6 +24,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.http.HttpOperationFailedException;
import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.GreeterImpl;
@@ -36,105 +37,36 @@ import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class CXFGreeterRouterTest extends CamelTestSupport {
- protected static Endpoint endpoint;
- protected AbstractXmlApplicationContext applicationContext;
-
- private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
- "SOAPService");
- private final QName routerPortName = new QName("http://apache.org/hello_world_soap_http",
- "RouterPort");
-
- 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>";
-
- @Before
- public void setUp() throws Exception {
- applicationContext = createApplicationContext();
- super.setUp();
- assertNotNull("Should have created a valid spring context", applicationContext);
+public class CXFGreeterRouterTest extends AbstractCXFGreeterRouterTest {
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ static {
+ System.setProperty("CXFGreeterRouterTest.port1", Integer.toString(port1));
+ System.setProperty("CXFGreeterRouterTest.port2", Integer.toString(port2));
+ }
+ public String getPort1() {
+ return Integer.toString(port1);
}
- @After
- public void tearDown() throws Exception {
-
- if (applicationContext != null) {
- applicationContext.destroy();
- }
- super.tearDown();
+ public String getPort2() {
+ return Integer.toString(port2);
}
-
+
@BeforeClass
public static void startService() {
Object implementor = new GreeterImpl();
- String address = "http://localhost:9000/SoapContext/SoapPort";
+ String address = "http://localhost:" + port1 + "/SoapContext/SoapPort";
endpoint = Endpoint.publish(address, implementor);
}
-
- @AfterClass
- public static void stopService() {
- if (endpoint != null) {
- endpoint.stop();
- }
- }
- @Test
- public void testInvokingServiceFromCXFClient() throws Exception {
- Service service = Service.create(serviceName);
- service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/",
- "http://localhost:9003/CamelContext/RouterPort");
- Greeter greeter = service.getPort(routerPortName, Greeter.class);
-
- String reply = greeter.greetMe("test");
- assertNotNull("No response received from service", reply);
- assertEquals("Got the wrong reply ", "Hello test", reply);
- reply = greeter.sayHi();
- assertNotNull("No response received from service", reply);
- assertEquals("Got the wrong reply ", "Bonjour", 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("The fault info should not be null", fault.getFaultInfo());
- }
-
- }
-
- @Test
- public void testRoutingSOAPFault() throws Exception {
- try {
- template.sendBody("http://localhost:9003/CamelContext/RouterPort", testDocLitFaultBody);
- fail("Should get an exception here.");
- } catch (RuntimeCamelException exception) {
- assertTrue("It should get the response error", exception.getCause() instanceof HttpOperationFailedException);
- assertEquals("Get a wrong response code", ((HttpOperationFailedException)exception.getCause()).getStatusCode(), 500);
- }
- }
-
- @Test
- public void testPublishEndpointUrl() throws Exception {
- String response = template.requestBody("http://localhost:9003/CamelContext/RouterPort?wsdl", null, String.class);
- assertTrue("Can't find the right service location.", response.indexOf("http://www.simple.com/services/test") > 0);
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- return SpringCamelContext.springCamelContext(applicationContext);
- }
protected ClassPathXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointsRouterContext.xml");
}
+
+
+
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java Wed Jun 29 13:24:58 2011
@@ -20,14 +20,15 @@ import javax.xml.ws.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.wsdl_first.PersonImpl12;
+import org.junit.Before;
import org.junit.BeforeClass;
public class CXFWsdlOnlyPayloadModeNoSpringSoap12Test extends CXFWsdlOnlyPayloadModeNoSpringTest {
- @BeforeClass
- public static void startService() {
- endpoint = Endpoint.publish("http://localhost:8093/PersonService", new PersonImpl12());
+ @Before
+ public void startService() {
+ endpoint = Endpoint.publish("http://localhost:" + port1 + "/PersonService", new PersonImpl12());
}
@Override
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java Wed Jun 29 13:24:58 2011
@@ -19,12 +19,14 @@ package org.apache.camel.component.cxf;
import java.net.URL;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.wsdl_first.Person;
import org.apache.camel.wsdl_first.PersonImpl;
@@ -34,7 +36,9 @@ import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -44,14 +48,17 @@ public class CXFWsdlOnlyPayloadModeNoSpr
protected static final String PORT_NAME_PROP = "portName={http://camel.apache.org/wsdl-first}soap";
protected static final String WSDL_URL_PROP = "wsdlURL=classpath:person.wsdl";
protected static Endpoint endpoint;
+
+ protected int port1 = AvailablePortFinder.getNextAvailable();
+ protected int port2 = AvailablePortFinder.getNextAvailable();
- @BeforeClass
- public static void startService() {
- endpoint = Endpoint.publish("http://localhost:8093/PersonService", new PersonImpl());
+ @Before
+ public void startService() {
+ endpoint = Endpoint.publish("http://localhost:" + port1 + "/PersonService", new PersonImpl());
}
- @AfterClass
- public static void stopService() {
+ @After
+ public void stopService() {
if (endpoint != null) {
endpoint.stop();
}
@@ -68,7 +75,7 @@ public class CXFWsdlOnlyPayloadModeNoSpr
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("cxf://http://localhost:8092/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat())
+ from("cxf://http://localhost:" + port2 + "/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat())
.process(new Processor() {
@Override
@@ -77,7 +84,7 @@ public class CXFWsdlOnlyPayloadModeNoSpr
}
})
- .to("cxf://http://localhost:8093/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat());
+ .to("cxf://http://localhost:" + port1 + "/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat());
}
};
}
@@ -94,6 +101,10 @@ public class CXFWsdlOnlyPayloadModeNoSpr
Person client = ss.getSoap();
Client c = ClientProxy.getClient(client);
+
+ ((BindingProvider)client).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + port1 + "/PersonService");
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
@@ -112,7 +123,10 @@ public class CXFWsdlOnlyPayloadModeNoSpr
PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
Person client = ss.getSoap();
-
+ ((BindingProvider)client).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + port1 + "/PersonService");
+
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyTest.java Wed Jun 29 13:24:58 2011
@@ -19,10 +19,12 @@ package org.apache.camel.component.cxf;
import java.net.URL;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Endpoint;
import javax.xml.ws.Holder;
import org.apache.camel.CamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.apache.camel.wsdl_first.Person;
import org.apache.camel.wsdl_first.PersonImpl;
@@ -34,11 +36,22 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class CXFWsdlOnlyTest extends CamelSpringTestSupport {
-
+
private static Endpoint endpoint1;
private static Endpoint endpoint2;
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ private static int port3 = AvailablePortFinder.getNextAvailable();
+ private static int port4 = AvailablePortFinder.getNextAvailable();
+
+
protected ClassPathXmlApplicationContext createApplicationContext() {
+ System.setProperty("CXFWsdlOnlyTest.port1", Integer.toString(port1));
+ System.setProperty("CXFWsdlOnlyTest.port2", Integer.toString(port2));
+ System.setProperty("CXFWsdlOnlyTest.port3", Integer.toString(port3));
+ System.setProperty("CXFWsdlOnlyTest.port4", Integer.toString(port4));
+
// When the Application is closed, the camel-cxf endpoint will be shutdown,
// this will cause the issue of the new http server doesn't send the response back.
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/WsdlOnlyBeans.xml");
@@ -51,10 +64,10 @@ public class CXFWsdlOnlyTest extends Cam
@BeforeClass
public static void startServices() {
Object implementor = new PersonImpl();
- String address = "http://localhost:9000/PersonService/";
+ String address = "http://localhost:" + port1 + "/PersonService/";
endpoint1 = Endpoint.publish(address, implementor);
- address = "http://localhost:9001/PersonService/";
+ address = "http://localhost:" + port2 + "/PersonService/";
endpoint2 = Endpoint.publish(address, implementor);
}
@@ -75,6 +88,10 @@ public class CXFWsdlOnlyTest extends Cam
PersonService ss = new PersonService(wsdlURL, new QName("http://camel.apache.org/wsdl-first",
"PersonService"));
Person client = ss.getSoap();
+
+ ((BindingProvider)client).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + port3 + "/PersonService/");
Holder<String> personId = new Holder<String>();
personId.value = "hello";
Holder<String> ssn = new Holder<String>();
@@ -95,6 +112,9 @@ public class CXFWsdlOnlyTest extends Cam
assertTrue(t instanceof UnknownPersonFault);
Person client2 = ss.getSoap2();
+ ((BindingProvider)client2).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + port4 + "/PersonService/");
Holder<String> personId2 = new Holder<String>();
personId2.value = "hello";
Holder<String> ssn2 = new Holder<String>();
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerFaultTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerFaultTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerFaultTest.java Wed Jun 29 13:24:58 2011
@@ -24,15 +24,16 @@ import org.apache.camel.wsdl_first.Unkno
// SET the fault message directly on the out message
public class CxfConsumerFaultTest extends CxfConsumerPayloadFaultTest {
- private static final String SERVICE_URI = "cxf://" + SERVICE_ADDRESS + "?"
- + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP
- + "&serviceClass=org.apache.camel.wsdl_first.Person";
-
+
@Override
protected RouteBuilder createRouteBuilder() {
+ final String serviceURI = "cxf://" + serviceAddress + "?"
+ + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP
+ + "&serviceClass=org.apache.camel.wsdl_first.Person";
+
return new RouteBuilder() {
public void configure() {
- from(SERVICE_URI).process(new Processor() {
+ from(serviceURI).process(new Processor() {
public void process(final Exchange exchange) throws Exception {
// set the fault message here
org.apache.camel.wsdl_first.types.UnknownPersonFault faultDetail = new org.apache.camel.wsdl_first.types.UnknownPersonFault();
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerMessageTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerMessageTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerMessageTest.java Wed Jun 29 13:24:58 2011
@@ -21,6 +21,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.cxf.BusFactory;
import org.apache.cxf.frontend.ClientFactoryBean;
@@ -28,10 +29,6 @@ import org.apache.cxf.frontend.ClientPro
import org.junit.Test;
public class CxfConsumerMessageTest extends CamelTestSupport {
- protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
- protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.component.cxf.HelloService";
-
private static final String TEST_MESSAGE = "Hello World!";
private static final String ECHO_METHOD = "ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\"";
@@ -45,10 +42,15 @@ public class CxfConsumerMessageTest exte
+ "<return xmlns=\"http://cxf.component.camel.apache.org/\">true</return>"
+ "</ns1:echoBooleanResponse></soap:Body></soap:Envelope>";
+ protected final String simpleEndpointAddress = "http://localhost:"
+ + AvailablePortFinder.getNextAvailable() + "/test";
+ protected final String simpleEndpointURI = "cxf://" + simpleEndpointAddress
+ + "?serviceClass=org.apache.camel.component.cxf.HelloService";
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(SIMPLE_ENDPOINT_URI + "&dataFormat=MESSAGE").process(new Processor() {
+ from(simpleEndpointURI + "&dataFormat=MESSAGE").process(new Processor() {
public void process(final Exchange exchange) {
Message in = exchange.getIn();
// check the content-length header is filtered
@@ -73,7 +75,7 @@ public class CxfConsumerMessageTest exte
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
+ clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java Wed Jun 29 13:24:58 2011
@@ -39,7 +39,7 @@ public class CxfConsumerPayLoadFaultMess
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(FROM_URI).process(new Processor() {
+ from(fromURI).process(new Processor() {
public void process(final Exchange exchange) throws Exception {
Element details = DOMUtils.readXml(new StringReader(FAULTS)).getDocumentElement();
List<Element> outElements = new ArrayList<Element>();
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadMarshalFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadMarshalFaultTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadMarshalFaultTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadMarshalFaultTest.java Wed Jun 29 13:24:58 2011
@@ -40,7 +40,7 @@ public class CxfConsumerPayLoadMarshalFa
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(FROM_URI).process(new Processor() {
+ from(fromURI).process(new Processor() {
public void process(final Exchange exchange) throws Exception {
JAXBContext context = JAXBContext.newInstance("org.apache.camel.wsdl_first.types");
QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server");
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadFaultTest.java Wed Jun 29 13:24:58 2011
@@ -21,6 +21,7 @@ import java.io.StringReader;
import java.net.URL;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
import org.w3c.dom.Element;
@@ -28,6 +29,7 @@ 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.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.wsdl_first.Person;
import org.apache.camel.wsdl_first.PersonService;
@@ -51,18 +53,23 @@ public class CxfConsumerPayloadFaultTest
protected static final String SERVICE_NAME = "{http://camel.apache.org/wsdl-first}PersonService";
protected static final String SERVICE_NAME_PROP = "serviceName=" + SERVICE_NAME;
protected static final String WSDL_URL_PROP = "wsdlURL=classpath:person.wsdl";
- protected static final String SERVICE_ADDRESS = "http://localhost:8092/PersonService";
- protected static final String FROM_URI = "cxf://" + SERVICE_ADDRESS + "?"
- + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&dataFormat=" + DataFormat.PAYLOAD;
protected static final String DETAILS = "<detail><UnknownPersonFault xmlns=\"http://camel.apache.org/wsdl-first/types\">"
+ "<personId></personId></UnknownPersonFault></detail>";
+
+
+
+ protected final int port = AvailablePortFinder.getNextAvailable();
+ protected final String serviceAddress = "http://localhost:" + port + "/PersonService";
+ protected final String fromURI = "cxf://" + serviceAddress + "?"
+ + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&dataFormat=" + DataFormat.PAYLOAD;
+
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(FROM_URI).process(new Processor() {
+ from(fromURI).process(new Processor() {
public void process(final Exchange exchange) throws Exception {
QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server");
SoapFault fault = new SoapFault("Get the null value of person name", faultCode);
@@ -75,7 +82,7 @@ public class CxfConsumerPayloadFaultTest
}
};
}
-
+
@Test
public void testInvokingFromCxfClient() throws Exception {
URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
@@ -86,6 +93,8 @@ public class CxfConsumerPayloadFaultTest
Client c = ClientProxy.getClient(client);
c.getInInterceptors().add(new LoggingInInterceptor());
c.getOutInterceptors().add(new LoggingOutInterceptor());
+ ((BindingProvider)client).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serviceAddress);
Holder<String> personId = new Holder<String>();
personId.value = "";
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java Wed Jun 29 13:24:58 2011
@@ -44,7 +44,7 @@ public class CxfConsumerPayloadTest exte
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(SIMPLE_ENDPOINT_URI + "&dataFormat=PAYLOAD").to("log:info").process(new Processor() {
+ from(simpleEndpointURI + "&dataFormat=PAYLOAD").to("log:info").process(new Processor() {
@SuppressWarnings("unchecked")
public void process(final Exchange exchange) throws Exception {
CxfPayload<SoapHeader> requestPayload = exchange.getIn().getBody(CxfPayload.class);
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerProviderTest.java Wed Jun 29 13:24:58 2011
@@ -24,15 +24,13 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
public class CxfConsumerProviderTest extends CamelTestSupport {
- protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
- protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.component.cxf.ServiceProvider";
protected static final String REQUEST_MESSAGE = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"test/service\">"
+ "<soapenv:Header/><soapenv:Body><ser:ping/></soapenv:Body></soapenv:Envelope>";
@@ -44,6 +42,13 @@ public class CxfConsumerProviderTest ext
protected static final String RESPONSE = "<pong xmlns=\"test/service\"/>";
+
+ protected final String simpleEndpointAddress = "http://localhost:"
+ + AvailablePortFinder.getNextAvailable() + "/test";
+ protected final String simpleEndpointURI = "cxf://" + simpleEndpointAddress
+ + "?serviceClass=org.apache.camel.component.cxf.ServiceProvider";
+
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
@@ -68,24 +73,24 @@ public class CxfConsumerProviderTest ext
public void testInvokingServiceFromHttpCompnent() throws Exception {
// call the service with right post message
- String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, REQUEST_MESSAGE, String.class);
+ String response = template.requestBody(simpleEndpointAddress, REQUEST_MESSAGE, String.class);
assertTrue("Get a wrong response ", response.startsWith(RESPONSE_MESSAGE_BEGINE));
assertTrue("Get a wrong response ", response.endsWith(RESPONSE_MESSAGE_END));
try {
- response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, null, String.class);
+ response = template.requestBody(simpleEndpointAddress, null, String.class);
fail("Excpetion to get exception here");
} catch (Exception ex) {
// do nothing here
}
- response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, REQUEST_MESSAGE, String.class);
+ response = template.requestBody(simpleEndpointAddress, REQUEST_MESSAGE, String.class);
assertTrue("Get a wrong response ", response.startsWith(RESPONSE_MESSAGE_BEGINE));
assertTrue("Get a wrong response ", response.endsWith(RESPONSE_MESSAGE_END));
}
protected String getFromEndpointUri() {
- return SIMPLE_ENDPOINT_URI;
+ return simpleEndpointURI;
}
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerResponseTest.java Wed Jun 29 13:24:58 2011
@@ -28,6 +28,7 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
@@ -37,10 +38,6 @@ import org.junit.Test;
public class CxfConsumerResponseTest extends CamelTestSupport {
- protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
- protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
- + "?serviceClass=org.apache.camel.component.cxf.HelloService"
- + "&publishedEndpointUrl=http://www.simple.com/services/test";
private static final String ECHO_OPERATION = "echo";
private static final String ECHO_BOOLEAN_OPERATION = "echoBoolean";
@@ -48,11 +45,19 @@ public class CxfConsumerResponseTest ext
private static final String TEST_MESSAGE = "Hello World!";
private static int pingCounter;
+
+ protected final String simpleEndpointAddress = "http://localhost:"
+ + AvailablePortFinder.getNextAvailable() + "/test";
+ protected final String simpleEndpointURI = "cxf://" + simpleEndpointAddress
+ + "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ + "&publishedEndpointUrl=http://www.simple.com/services/test";
+
+
// START SNIPPET: example
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from(SIMPLE_ENDPOINT_URI).inOnly("log:test").choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
+ from(simpleEndpointURI).inOnly("log:test").choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
public void process(final Exchange exchange) {
assertEquals(DataFormat.POJO, exchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class));
Message in = exchange.getIn();
@@ -100,7 +105,7 @@ public class CxfConsumerResponseTest ext
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
+ clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java Wed Jun 29 13:24:58 2011
@@ -19,10 +19,13 @@ package org.apache.camel.component.cxf;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.junit.Assert;
import org.junit.Test;
public class CxfConsumerStartTwiceTest extends Assert {
+ static final int PORT = AvailablePortFinder.getNextAvailable();
+
@Test
public void startServiceTwice() throws Exception {
@@ -31,7 +34,7 @@ public class CxfConsumerStartTwiceTest e
//add the same route twice...
context.addRoutes(new RouteBuilder() {
public void configure() {
- from("cxf:http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService")
+ from("cxf:http://localhost:" + PORT + "/test?serviceClass=org.apache.camel.component.cxf.HelloService")
.to("log:POJO");
}
});
@@ -39,7 +42,7 @@ public class CxfConsumerStartTwiceTest e
context.addRoutes(new RouteBuilder() {
public void configure() {
- from("cxf:http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService")
+ from("cxf:http://localhost:" + PORT + "/test?serviceClass=org.apache.camel.component.cxf.HelloService")
.to("log:POJO");
}
});
@@ -49,7 +52,7 @@ public class CxfConsumerStartTwiceTest e
fail("Expect to catch an exception here");
} catch (Exception ex) {
assertTrue(ex.getMessage().endsWith(
- "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf://http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
+ "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf://http://localhost:" + PORT + "/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
}
context.stop();
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java Wed Jun 29 13:24:58 2011
@@ -28,6 +28,7 @@ import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
@@ -37,7 +38,8 @@ import org.junit.Test;
public class CxfConsumerTest extends CamelTestSupport {
- protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
+ protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:"
+ + AvailablePortFinder.getNextAvailable() + "/test";
protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
+ "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ "&publishedEndpointUrl=http://www.simple.com/services/test";
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomerStartStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomerStartStopTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomerStartStopTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomerStartStopTest.java Wed Jun 29 13:24:58 2011
@@ -31,14 +31,15 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class CxfCustomerStartStopTest extends Assert {
-
+ static final int PORT1 = AvailablePortFinder.getNextAvailable();
+ static final int PORT2 = AvailablePortFinder.getNextAvailable();
@Test
public void startAndStopService() throws Exception {
CamelContext context = new DefaultCamelContext();
// start a server
context.addRoutes(new RouteBuilder() {
public void configure() {
- from("cxf:http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService")
+ from("cxf:http://localhost:" + PORT1 + "/test?serviceClass=org.apache.camel.component.cxf.HelloService")
.to("log:endpoint");
}
});
@@ -48,16 +49,18 @@ public class CxfCustomerStartStopTest ex
context.stop();
Bus bus = BusFactory.getDefaultBus();
JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
- JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(7070);
+ JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT1);
assertNotNull("Jetty engine should be found there", engine);
// Need to call the bus shutdown ourselves.
bus.shutdown(true);
- engine = factory.retrieveJettyHTTPServerEngine(7070);
+ engine = factory.retrieveJettyHTTPServerEngine(PORT1);
assertNull("Jetty engine should be removed", engine);
}
@Test
public void startAndStopServiceFromSpring() throws Exception {
+ System.setProperty("CamelCxfConsumerContext.port2", Integer.toString(PORT2));
+
ClassPathXmlApplicationContext applicationContext =
new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CamelCxfConsumerContext.xml");
Bus bus = (Bus)applicationContext.getBean("cxf");
@@ -65,7 +68,7 @@ public class CxfCustomerStartStopTest ex
applicationContext.close();
JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
// test if the port is still used
- JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(9003);
+ JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT2);
assertNull("Jetty engine should be removed", engine);
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java Wed Jun 29 13:24:58 2011
@@ -33,6 +33,7 @@ import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.IOHelper;
import org.apache.cxf.Bus;
@@ -46,16 +47,11 @@ import org.junit.Test;
public class CxfCustomizedExceptionTest extends CamelTestSupport {
- protected static final String ROUTER_ADDRESS = "http://localhost:9002/router";
protected static final String SERVICE_CLASS = "serviceClass=org.apache.camel.component.cxf.HelloService";
- protected static String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS;
- protected static final String SERVICE_URI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS;
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;
- private Bus bus;
-
static {
// START SNIPPET: FaultDefine
SOAP_FAULT = new SoapFault(EXCEPTION_MESSAGE, SoapFault.FAULT_CODE_CLIENT);
@@ -65,6 +61,14 @@ public class CxfCustomizedExceptionTest
detail.appendChild(tn);
// END SNIPPET: FaultDefine
}
+
+ protected String routerAddress = "http://localhost:" + AvailablePortFinder.getNextAvailable()
+ + "/router";
+ protected String routerEndpointURI = "cxf://" + routerAddress + "?" + SERVICE_CLASS;
+ protected String serviceURI = "cxf://" + routerAddress + "?" + SERVICE_CLASS;
+
+ private Bus bus;
+
@Override
@Before
@@ -99,7 +103,7 @@ public class CxfCustomizedExceptionTest
})
.end()
- .to(SERVICE_URI);
+ .to(serviceURI);
// END SNIPPET: onException
// START SNIPPET: ThrowFault
from(routerEndpointURI).setFaultBody(constant(SOAP_FAULT));
@@ -125,7 +129,7 @@ public class CxfCustomizedExceptionTest
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
- clientBean.setAddress(ROUTER_ADDRESS);
+ clientBean.setAddress(routerAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(bus);
@@ -146,7 +150,7 @@ public class CxfCustomizedExceptionTest
@Test
public void testInvokingServiceFromHTTPURL() throws Exception {
- URL url = new URL(ROUTER_ADDRESS);
+ URL url = new URL(routerAddress);
URLConnection urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java Wed Jun 29 13:24:58 2011
@@ -23,6 +23,7 @@ import org.w3c.dom.Document;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.AvailablePortFinder;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -37,6 +38,7 @@ public class CxfDispatchMessageTest exte
@Override
protected AbstractApplicationContext createApplicationContext() {
+ System.setProperty("CxfDispatchMessageTest.port", Integer.toString(port));
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml");
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java Wed Jun 29 13:24:58 2011
@@ -38,6 +38,7 @@ public class CxfDispatchPayloadTest exte
@Override
protected AbstractApplicationContext createApplicationContext() {
+ System.setProperty("CxfDispatchPayloadTest.port", Integer.toString(port));
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml");
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java Wed Jun 29 13:24:58 2011
@@ -23,9 +23,12 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
@@ -33,7 +36,6 @@ import org.junit.BeforeClass;
* Base class for testing arbitrary payload
*/
public abstract class CxfDispatchTestSupport extends CamelSpringTestSupport {
- protected static Endpoint endpoint;
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";
@@ -48,15 +50,18 @@ public abstract class CxfDispatchTestSup
+ "</soap:Body></soap:Envelope>";
private static DocumentBuilderFactory documentBuilderFactory;
- @BeforeClass
- public static void startService() {
+ protected Endpoint endpoint;
+ protected int port = AvailablePortFinder.getNextAvailable();
+
+ @Before
+ public void startService() {
Object implementor = new GreeterImpl();
- String address = "http://localhost:9000/SoapContext/GreeterPort";
+ String address = "http://localhost:" + port + "/SoapContext/GreeterPort";
endpoint = Endpoint.publish(address, implementor);
}
- @AfterClass
- public static void stopService() {
+ @After
+ public void stopService() {
if (endpoint != null) {
endpoint.stop();
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java Wed Jun 29 13:24:58 2011
@@ -20,6 +20,7 @@ package org.apache.camel.component.cxf;
import org.apache.camel.component.cxf.CxfEndpoint.CamelCxfClientImpl;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.CXFBusImpl;
import org.apache.cxf.frontend.ServerFactoryBean;
@@ -33,11 +34,13 @@ import org.springframework.context.suppo
* @version
*/
public class CxfEndpointTest extends Assert {
-
- private String routerEndpointURI = "cxf://http://localhost:9000/router"
+ private int port1 = AvailablePortFinder.getNextAvailable();
+ private int port2 = AvailablePortFinder.getNextAvailable();
+
+ private String routerEndpointURI = "cxf://http://localhost:" + port1 + "/router"
+ "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ "&dataFormat=POJO";
- private String wsdlEndpointURI = "cxf://http://localhost:9002/helloworld"
+ private String wsdlEndpointURI = "cxf://http://localhost:" + port2 + "/helloworld"
+ "?wsdlURL=classpath:person.wsdl"
+ "&serviceName={http://camel.apache.org/wsdl-first}PersonService"
+ "&portName={http://camel.apache.org/wsdl-first}soap"
@@ -45,14 +48,17 @@ public class CxfEndpointTest extends Ass
@Test
public void testSpringCxfEndpoint() throws Exception {
+ System.setProperty("CxfEndpointTest.port1", Integer.toString(port1));
+ System.setProperty("CxfEndpointTest.port2", Integer.toString(port2));
+
ClassPathXmlApplicationContext ctx =
- new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/component/cxf/spring/CxfEndpointBeans.xml"});
+ new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/component/cxf/CxfEndpointBeans.xml"});
CxfComponent cxfComponent = new CxfComponent(new SpringCamelContext(ctx));
CxfSpringEndpoint endpoint = (CxfSpringEndpoint)cxfComponent.createEndpoint("cxf://bean:serviceEndpoint");
ServerFactoryBean svf = new ServerFactoryBean();
endpoint.configure(svf);
- assertEquals("Got the wrong endpoint address", svf.getAddress(), "http://localhost:9002/helloworld");
+ assertEquals("Got the wrong endpoint address", svf.getAddress(), "http://localhost:" + port2 + "/helloworld");
assertEquals("Got the wrong endpont service class",
svf.getServiceClass().getCanonicalName(),
"org.apache.camel.component.cxf.HelloService");
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterConverterRouterTest.java Wed Jun 29 13:24:58 2011
@@ -17,11 +17,36 @@
package org.apache.camel.component.cxf;
+import javax.xml.ws.Endpoint;
+
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.BeforeClass;
import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class CxfGreeterConverterRouterTest extends CXFGreeterRouterTest {
-
+public class CxfGreeterConverterRouterTest extends AbstractCXFGreeterRouterTest {
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ static {
+ System.setProperty("CxfGreeterConverterRouterTest.port1", Integer.toString(port1));
+ System.setProperty("CxfGreeterConverterRouterTest.port2", Integer.toString(port2));
+ }
+ public String getPort1() {
+ return Integer.toString(port1);
+ }
+
+ public String getPort2() {
+ return Integer.toString(port2);
+ }
+
+ @BeforeClass
+ public static void startService() {
+ Object implementor = new GreeterImpl();
+ String address = "http://localhost:" + port1 + "/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+ }
+
protected ClassPathXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterConverterEndpointsRouterContext.xml");
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageRouterTest.java Wed Jun 29 13:24:58 2011
@@ -17,13 +17,40 @@
package org.apache.camel.component.cxf;
+import javax.xml.ws.Endpoint;
+
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.BeforeClass;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* The Greeter test with the MESSAGE date format
*/
-public class CxfGreeterMessageRouterTest extends CXFGreeterRouterTest {
+public class CxfGreeterMessageRouterTest extends AbstractCXFGreeterRouterTest {
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ static {
+ System.setProperty("CxfGreeterMessageRouterTest.port1", Integer.toString(port1));
+ System.setProperty("CxfGreeterMessageRouterTest.port2", Integer.toString(port2));
+ }
+ public String getPort1() {
+ return Integer.toString(port1);
+ }
+
+ public String getPort2() {
+ return Integer.toString(port2);
+ }
+
+ @BeforeClass
+ public static void startService() {
+ Object implementor = new GreeterImpl();
+ String address = "http://localhost:" + port1 + "/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+ }
+
+
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadRouterTest.java Wed Jun 29 13:24:58 2011
@@ -16,13 +16,38 @@
*/
package org.apache.camel.component.cxf;
+import javax.xml.ws.Endpoint;
+
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.BeforeClass;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* The Greeter test with the PAYLOAD date format
*/
-public class CxfGreeterPayLoadRouterTest extends CXFGreeterRouterTest {
+public class CxfGreeterPayLoadRouterTest extends AbstractCXFGreeterRouterTest {
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ static {
+ System.setProperty("CxfGreeterPayloadRouterTest.port1", Integer.toString(port1));
+ System.setProperty("CxfGreeterPayloadRouterTest.port2", Integer.toString(port2));
+ }
+ public String getPort1() {
+ return Integer.toString(port1);
+ }
+
+ public String getPort2() {
+ return Integer.toString(port2);
+ }
+
+ @BeforeClass
+ public static void startService() {
+ Object implementor = new GreeterImpl();
+ String address = "http://localhost:" + port1 + "/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+ }
@Override
protected RouteBuilder createRouteBuilder() {
@@ -37,7 +62,7 @@ public class CxfGreeterPayLoadRouterTest
@Override
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointBeans.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointPayloadBeans.xml");
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadWithFeatureRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadWithFeatureRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadWithFeatureRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterPayLoadWithFeatureRouterTest.java Wed Jun 29 13:24:58 2011
@@ -16,7 +16,12 @@
*/
package org.apache.camel.component.cxf;
+import javax.xml.ws.Endpoint;
+
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.hello_world_soap_http.GreeterImpl;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -25,8 +30,28 @@ import org.springframework.context.suppo
*
* @version
*/
-public class CxfGreeterPayLoadWithFeatureRouterTest extends CXFGreeterRouterTest {
-
+public class CxfGreeterPayLoadWithFeatureRouterTest extends AbstractCXFGreeterRouterTest {
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+ private static int port2 = AvailablePortFinder.getNextAvailable();
+ static {
+ System.setProperty("CxfGreeterPayLoadWithFeatureRouterTest.port1", Integer.toString(port1));
+ System.setProperty("CxfGreeterPayLoadWithFeatureRouterTest.port2", Integer.toString(port2));
+ }
+ public String getPort1() {
+ return Integer.toString(port1);
+ }
+
+ public String getPort2() {
+ return Integer.toString(port2);
+ }
+
+ @BeforeClass
+ public static void startService() {
+ Object implementor = new GreeterImpl();
+ String address = "http://localhost:" + port1 + "/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+ }
+
@Before
@Override
public void setUp() throws Exception {
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyPayloadModeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyPayloadModeTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyPayloadModeTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyPayloadModeTest.java Wed Jun 29 13:24:58 2011
@@ -20,6 +20,7 @@ import org.w3c.dom.Document;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -30,8 +31,9 @@ import org.junit.Test;
* @version
*/
public class CxfJavaOnlyPayloadModeTest extends CamelTestSupport {
-
- private String url = "cxf://http://localhost:9002/helloworld"
+ private static int port1 = AvailablePortFinder.getNextAvailable();
+
+ private String url = "cxf://http://localhost:" + port1 + "/helloworld"
+ "?wsdlURL=classpath:person.wsdl"
+ "&serviceName={http://camel.apache.org/wsdl-first}PersonService"
+ "&portName={http://camel.apache.org/wsdl-first}soap"
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageCustomizedExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageCustomizedExceptionTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageCustomizedExceptionTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageCustomizedExceptionTest.java Wed Jun 29 13:24:58 2011
@@ -27,7 +27,7 @@ public class CxfMessageCustomizedExcepti
@Before
@Override
public void setUp() throws Exception {
- routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&DataFormat=MESSAGE";
+ routerEndpointURI = "cxf://" + routerAddress + "?" + SERVICE_CLASS + "&DataFormat=MESSAGE";
super.setUp();
}
}
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java Wed Jun 29 13:24:58 2011
@@ -37,7 +37,7 @@ public class CxfMessageStreamExceptionTe
exchange.getOut().setBody(fault);
}
- }).end().to(SERVICE_URI);
+ }).end().to(serviceURI);
// END SNIPPET: onException
// START SNIPPET: MessageStreamFault
from(routerEndpointURI).process(new Processor() {
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java Wed Jun 29 13:24:58 2011
@@ -28,6 +28,7 @@ import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.cxf.binding.soap.SoapHeader;
import org.apache.cxf.endpoint.Server;
@@ -40,10 +41,13 @@ import org.junit.BeforeClass;
import org.junit.Test;
-public class CxfMixedModeRouterTest extends CamelTestSupport {
+public class CxfMixedModeRouterTest extends CamelTestSupport {
+ protected static int port1 = AvailablePortFinder.getNextAvailable();
+ protected static int port2 = AvailablePortFinder.getNextAvailable();
+
protected static Server server;
- protected static final String ROUTER_ADDRESS = "http://localhost:9000/router";
- protected static final String SERVICE_ADDRESS = "http://localhost:9002/helloworld";
+ protected static final String ROUTER_ADDRESS = "http://localhost:" + port1 + "/router";
+ protected static final String SERVICE_ADDRESS = "http://localhost:" + port2 + "/helloworld";
protected static final String SERVICE_CLASS = "serviceClass=org.apache.camel.component.cxf.HelloService";
private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS + "&dataFormat=PAYLOAD";
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java?rev=1141094&r1=1141093&r2=1141094&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMultipleConsumersSupportTest.java Wed Jun 29 13:24:58 2011
@@ -18,6 +18,7 @@ package org.apache.camel.component.cxf;
import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
@@ -25,12 +26,15 @@ import org.junit.Test;
* @version
*/
public class CxfMultipleConsumersSupportTest extends CamelTestSupport {
+ protected static int port1 = AvailablePortFinder.getNextAvailable();
+ protected static int port2 = AvailablePortFinder.getNextAvailable();
+
- protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:28080/test";
+ protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:" + port1 + "/test";
protected static final String SIMPLE_ENDPOINT_URI = "cxf://" + SIMPLE_ENDPOINT_ADDRESS
+ "?serviceClass=org.apache.camel.component.cxf.HelloService";
- protected static final String SIMPLE_OTHER_ADDRESS = "http://localhost:28081/test";
+ protected static final String SIMPLE_OTHER_ADDRESS = "http://localhost:" + port2 + "/test";
protected static final String SIMPLE_OTHER_URI = "cxf://" + SIMPLE_OTHER_ADDRESS
+ "?serviceClass=org.apache.camel.component.cxf.HelloService";
@@ -51,7 +55,7 @@ public class CxfMultipleConsumersSupport
fail("Should have thrown an exception");
} catch (FailedToStartRouteException e) {
assertTrue(e.getMessage().endsWith(
- "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf://http://localhost:28080/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
+ "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf://http://localhost:" + port1 + "/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
}
}