You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/12/26 12:28:26 UTC

svn commit: r1224715 - in /camel/trunk/examples: camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ camel-example-cxf-blueprint/src/test/...

Author: davsclaus
Date: Mon Dec 26 11:28:25 2011
New Revision: 1224715

URL: http://svn.apache.org/viewvc?rev=1224715&view=rev
Log:
CAMEL-4814: Use dynamic port numbers for testing examples.

Added:
    camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/incident.properties
Removed:
    camel/trunk/examples/camel-example-cxf-osgi/src/profiles/
Modified:
    camel/trunk/examples/camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/resources/camel-context.xml
    camel/trunk/examples/camel-example-cxf-osgi/pom.xml
    camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
    camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java
    camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml
    camel/trunk/examples/camel-example-cxf-proxy/pom.xml
    camel/trunk/examples/camel-example-cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/RealWebServiceBean.java
    camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/META-INF/spring/camel-config.xml
    camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java

Modified: camel/trunk/examples/camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original)
+++ camel/trunk/examples/camel-example-cxf-blueprint/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Mon Dec 26 11:28:25 2011
@@ -27,9 +27,10 @@ import org.apache.camel.builder.RouteBui
 public class ReportIncidentRoutes extends RouteBuilder {
     
     public void configure() throws Exception {
-        // webservice response for OK
+        // webservice responses
         OutputReportIncident ok = new OutputReportIncident();
         ok.setCode("OK");
+
         OutputReportIncident accepted = new OutputReportIncident();
         accepted.setCode("Accepted");
 
@@ -37,7 +38,9 @@ public class ReportIncidentRoutes extend
             .convertBodyTo(InputReportIncident.class)
             .setHeader(Exchange.FILE_NAME, constant("request-${date:now:yyyy-MM-dd-HHmmssSSS}"))
             .wireTap("file://target/inbox/")
-            .choice().when(simple("${body.givenName} == 'Claus'")).transform(constant(ok))
-            .otherwise().transform(constant(accepted));
+            .choice().when(simple("${body.givenName} == 'Claus'"))
+                .transform(constant(ok))
+            .otherwise()
+                .transform(constant(accepted));
     }
 }
\ No newline at end of file

Modified: camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java (original)
+++ camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java Mon Dec 26 11:28:25 2011
@@ -16,8 +16,13 @@
  */
 package org.apache.camel.example.reportincident;
 
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -28,22 +33,30 @@ import org.springframework.context.suppo
 public class ReportIncidentRoutesClientTest extends CamelSpringTestSupport {
 
     // should be the same address as we have in our route
-    private static final String URL = "http://localhost:8181/cxf/camel-example-cxf-blueprint/webservices/incident";
-   
-    protected static ReportIncidentEndpoint createCXFClient() {
+    private static final String URL = "http://localhost:{{port}}/cxf/camel-example-cxf-blueprint/webservices/incident";
+
+    @BeforeClass
+    public static void setupFreePort() throws Exception {
+        // find a free port number from 9100 onwards, and write that in the custom.properties file
+        // which we will use for the unit tests, to avoid port number in use problems
+        int port = AvailablePortFinder.getNextAvailable(9100);
+        String s = "port=" + port;
+        File custom = new File("target/custom.properties");
+        FileOutputStream fos = new FileOutputStream(custom);
+        fos.write(s.getBytes());
+        fos.close();
+    }
+
+    protected static ReportIncidentEndpoint createCXFClient(String url) {
         // we use CXF to create a client for us as its easier than JAXWS and works
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
         factory.setServiceClass(ReportIncidentEndpoint.class);
-        factory.setAddress(URL);
+        factory.setAddress(url);
         return (ReportIncidentEndpoint) factory.create();
     }
 
     @Test
-    public void testRendportIncident() throws Exception {
-        runTest();
-    }
-    
-    protected void runTest() throws Exception {
+    public void testReportIncident() throws Exception {
         // create input parameter
         InputReportIncident input = new InputReportIncident();
         input.setIncidentId("123");
@@ -56,7 +69,8 @@ public class ReportIncidentRoutesClientT
         input.setPhone("0045 2962 7576");
 
         // create the webservice client and send the request
-        ReportIncidentEndpoint client = createCXFClient();
+        String url = context.resolvePropertyPlaceholders(URL);
+        ReportIncidentEndpoint client = createCXFClient(url);
         OutputReportIncident out = client.reportIncident(input);
 
         // assert we got a OK back
@@ -68,7 +82,6 @@ public class ReportIncidentRoutesClientT
         
         // assert we got a Accept back
         assertEquals("Accepted", out.getCode());
-
     }
 
     @Override

Modified: camel/trunk/examples/camel-example-cxf-blueprint/src/test/resources/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-blueprint/src/test/resources/camel-context.xml?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-blueprint/src/test/resources/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-cxf-blueprint/src/test/resources/camel-context.xml Mon Dec 26 11:28:25 2011
@@ -26,7 +26,7 @@
            http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
     
     <cxf:cxfEndpoint id="reportIncident"
-                     address="http://localhost:8181/cxf/camel-example-cxf-blueprint/webservices/incident"
+                     address="http://localhost:{{port}}/cxf/camel-example-cxf-blueprint/webservices/incident"
                      wsdlURL="META-INF/wsdl/report_incident.wsdl"
                      serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint">
     </cxf:cxfEndpoint>
@@ -34,6 +34,10 @@
     <bean id="reportIncidentRoutes" class="org.apache.camel.example.reportincident.ReportIncidentRoutes" />
 
     <camel:camelContext id="camel">
+
+      <!-- property which contains port number -->
+      <camel:propertyPlaceholder id="properties" location="file:target/custom.properties"/>
+
     	<camel:routeBuilder ref="reportIncidentRoutes"/>
     </camel:camelContext>
 </beans>

Modified: camel/trunk/examples/camel-example-cxf-osgi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/pom.xml?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-osgi/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf-osgi/pom.xml Mon Dec 26 11:28:25 2011
@@ -22,8 +22,8 @@
 	<parent>
 		<groupId>org.apache.camel</groupId>
 		<artifactId>examples</artifactId>
-        <version>2.9-SNAPSHOT</version>
-        <relativePath>..</relativePath>
+    <version>2.9-SNAPSHOT</version>
+    <relativePath>..</relativePath>
 	</parent>
 
 	<artifactId>camel-example-cxf-osgi</artifactId>

Modified: camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original)
+++ camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Mon Dec 26 11:28:25 2011
@@ -27,9 +27,10 @@ import org.apache.camel.builder.RouteBui
 public class ReportIncidentRoutes extends RouteBuilder {
     
     public void configure() throws Exception {
-        // webservice response for OK
+        // webservice responses
         OutputReportIncident ok = new OutputReportIncident();
         ok.setCode("OK");
+
         OutputReportIncident accepted = new OutputReportIncident();
         accepted.setCode("Accepted");
 
@@ -37,8 +38,10 @@ public class ReportIncidentRoutes extend
             .convertBodyTo(InputReportIncident.class)
             .setHeader(Exchange.FILE_NAME, constant("request-${date:now:yyyy-MM-dd-HHmmssSSS}"))
             .wireTap("file://target/inbox/")
-            .choice().when(simple("${body.givenName} == 'Claus'")).transform(constant(ok))
-            .otherwise().transform(constant(accepted));
+            .choice().when(simple("${body.givenName} == 'Claus'"))
+                .transform(constant(ok))
+            .otherwise()
+                .transform(constant(accepted));
             
     }
 }
\ No newline at end of file

Modified: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java (original)
+++ camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java Mon Dec 26 11:28:25 2011
@@ -16,8 +16,13 @@
  */
 package org.apache.camel.example.reportincident;
 
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -28,22 +33,30 @@ import org.springframework.context.suppo
 public class ReportIncidentRoutesClientTest extends CamelSpringTestSupport {
 
     // should be the same address as we have in our route
-    private static final String URL = "http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident";
-   
-    protected static ReportIncidentEndpoint createCXFClient() {
+    private static final String URL = "http://localhost:{{port}}/cxf/camel-example-cxf-osgi/webservices/incident";
+
+    @BeforeClass
+    public static void setupFreePort() throws Exception {
+        // find a free port number from 9100 onwards, and write that in the custom.properties file
+        // which we will use for the unit tests, to avoid port number in use problems
+        int port = AvailablePortFinder.getNextAvailable(9100);
+        String s = "port=" + port;
+        File custom = new File("target/custom.properties");
+        FileOutputStream fos = new FileOutputStream(custom);
+        fos.write(s.getBytes());
+        fos.close();
+    }
+
+    protected static ReportIncidentEndpoint createCXFClient(String url) {
         // we use CXF to create a client for us as its easier than JAXWS and works
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
         factory.setServiceClass(ReportIncidentEndpoint.class);
-        factory.setAddress(URL);
+        factory.setAddress(url);
         return (ReportIncidentEndpoint) factory.create();
     }
 
     @Test
-    public void testRendportIncident() throws Exception {
-        runTest();
-    }
-    
-    protected void runTest() throws Exception {
+    public void testReportIncident() throws Exception {
         // create input parameter
         InputReportIncident input = new InputReportIncident();
         input.setIncidentId("123");
@@ -56,7 +69,8 @@ public class ReportIncidentRoutesClientT
         input.setPhone("0045 2962 7576");
 
         // create the webservice client and send the request
-        ReportIncidentEndpoint client = createCXFClient();
+        String url = context.resolvePropertyPlaceholders(URL);
+        ReportIncidentEndpoint client = createCXFClient(url);
         OutputReportIncident out = client.reportIncident(input);
 
         // assert we got a OK back
@@ -68,11 +82,11 @@ public class ReportIncidentRoutesClientT
         
         // assert we got a Accept back
         assertEquals("Accepted", out.getCode());
-
     }
 
     @Override
     protected AbstractApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext(new String[] {"camel-context.xml"});
     }
+
 }

Modified: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml Mon Dec 26 11:28:25 2011
@@ -26,7 +26,7 @@
            http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
     
     <cxf:cxfEndpoint id="reportIncident"
-                     address="http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident"
+                     address="http://localhost:{{port}}/cxf/camel-example-cxf-osgi/webservices/incident"
                      wsdlURL="META-INF/wsdl/report_incident.wsdl"
                      serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint">
     </cxf:cxfEndpoint>
@@ -34,6 +34,8 @@
     <bean id="reportIncidentRoutes" class="org.apache.camel.example.reportincident.ReportIncidentRoutes" />
 
     <camel:camelContext id="camel">
+      <!-- property which contains port number -->
+      <camel:propertyPlaceholder id="properties" location="file:target/custom.properties"/>
     	<camel:routeBuilder ref="reportIncidentRoutes"/>
     </camel:camelContext>
 </beans>

Modified: camel/trunk/examples/camel-example-cxf-proxy/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/pom.xml?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-proxy/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf-proxy/pom.xml Mon Dec 26 11:28:25 2011
@@ -15,128 +15,135 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
-    <modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 
-    <parent>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>examples</artifactId>
+    <version>2.9-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <artifactId>camel-example-cxf-proxy</artifactId>
+  <name>Camel :: Example :: CXF :: Proxy</name>
+  <description>An example which uses Camel to proxy a web service</description>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <camel.osgi.export.pkg>
+      org.apache.camel.example.*
+    </camel.osgi.export.pkg>
+    <camel.osgi.import.additional>
+      META-INF.cxf
+    </camel.osgi.import.additional>
+    <camel.osgi.private.pkg>
+      org.apache.camel.example.reportincident
+    </camel.osgi.private.pkg>
+    <!-- to avoid us import bunch of cxf package -->
+    <camel.osgi.dynamic>*</camel.osgi.dynamic>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-cxf</artifactId>
+    </dependency>
+
+    <!-- cxf -->
+    <!-- used by the real web service -->
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-frontend-jaxws</artifactId>
+      <version>${cxf-version}</version>
+    </dependency>
+    <!-- regular http transport -->
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-transports-http</artifactId>
+      <version>${cxf-version}</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <!-- cxf web container for unit testing -->
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-transports-http-jetty</artifactId>
+      <version>${cxf-version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- CXF wsdl2java generator, will plugin to the compile goal -->
+      <plugin>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-codegen-plugin</artifactId>
+        <version>${cxf-version}</version>
+        <executions>
+          <execution>
+            <id>generate-sources</id>
+            <phase>generate-sources</phase>
+            <configuration>
+              <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
+              <wsdlOptions>
+                <wsdlOption>
+                  <wsdl>${basedir}/src/main/resources/etc/report_incident.wsdl</wsdl>
+                </wsdlOption>
+              </wsdlOptions>
+            </configuration>
+            <goals>
+              <goal>wsdl2java</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
         <groupId>org.apache.camel</groupId>
-        <artifactId>examples</artifactId>
-        <version>2.9-SNAPSHOT</version>
-        <relativePath>..</relativePath>
-    </parent>
-
-    <artifactId>camel-example-cxf-proxy</artifactId>
-    <name>Camel :: Example :: CXF :: Proxy</name>
-    <description>An example which uses Camel to proxy a web service</description>
-    <packaging>bundle</packaging>
-    
-    <properties>
-		<camel.osgi.export.pkg>
-			org.apache.camel.example.*
-     </camel.osgi.export.pkg>
-		<camel.osgi.import.additional>
-			META-INF.cxf
-     </camel.osgi.import.additional>
-	 <camel.osgi.private.pkg>
-			org.apache.camel.example.reportincident
-     </camel.osgi.private.pkg>
-		<!-- to avoid us import bunch of cxf package -->
-		<camel.osgi.dynamic>*</camel.osgi.dynamic>
-	</properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-http</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-cxf</artifactId>
-        </dependency>
-
-        <!-- cxf -->
-        <!-- used by the real web service -->
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-frontend-jaxws</artifactId>
-            <version>${cxf-version}</version>
-        </dependency>
-        <!-- regular http transport -->
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-transports-http</artifactId>
-            <version>${cxf-version}</version>
-        </dependency>
-
-        <!-- logging -->
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-        </dependency>
-
-        <!-- cxf web container for unit testing -->
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-transports-http-jetty</artifactId>
-            <version>${cxf-version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-    </dependencies>
-
-    <build>
-        <plugins>
-            <!-- CXF wsdl2java generator, will plugin to the compile goal -->
-            <plugin>
-                <groupId>org.apache.cxf</groupId>
-                <artifactId>cxf-codegen-plugin</artifactId>
-                <version>${cxf-version}</version>
-                <executions>
-                    <execution>
-                        <id>generate-sources</id>
-                        <phase>generate-sources</phase>
-                        <configuration>
-                            <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
-                            <wsdlOptions>
-                                <wsdlOption>
-                                    <wsdl>${basedir}/src/main/resources/etc/report_incident.wsdl</wsdl>
-                                </wsdlOption>
-                            </wsdlOptions>
-                        </configuration>
-                        <goals>
-                            <goal>wsdl2java</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-				<groupId>org.apache.camel</groupId>
-				<artifactId>camel-maven-plugin</artifactId>
-				<version>${project.version}</version>
-			</plugin>
-			
-        </plugins>
-    </build>
+        <artifactId>camel-maven-plugin</artifactId>
+        <version>${project.version}</version>
+      </plugin>
+
+    </plugins>
+  </build>
+
 </project>

Modified: camel/trunk/examples/camel-example-cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/RealWebServiceBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/RealWebServiceBean.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/RealWebServiceBean.java (original)
+++ camel/trunk/examples/camel-example-cxf-proxy/src/main/java/org/apache/camel/example/cxf/proxy/RealWebServiceBean.java Mon Dec 26 11:28:25 2011
@@ -28,7 +28,7 @@ import javax.xml.ws.Endpoint;
 public class RealWebServiceBean {
 
     // should be the same address as we have in our route
-    private String url = "http://localhost:9081/real-webservice";
+    private String url;
 
     private ReportIncidentEndpointService service = new ReportIncidentEndpointService();
     private Endpoint endpoint;

Modified: camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/META-INF/spring/camel-config.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/META-INF/spring/camel-config.xml?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/META-INF/spring/camel-config.xml (original)
+++ camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/META-INF/spring/camel-config.xml Mon Dec 26 11:28:25 2011
@@ -21,20 +21,26 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:camel="http://camel.apache.org/schema/spring"
        xmlns:cxf="http://camel.apache.org/schema/cxf"
+       xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
 
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
-  
+
+  <!-- spring property placeholder, ignore resource not found as the file resource is for unit testing -->
+  <context:property-placeholder location="classpath:incident.properties,file:target/custom.properties"
+                                ignore-resource-not-found="true"/>
+
   <!-- Use a bean to start and stop the real web service (is not Camel specific) -->
   <!-- In a real use-case the real web service would be probably located on another server
        but we simulate this in the same JVM -->
   <bean id="realWebService" class="org.apache.camel.example.cxf.proxy.RealWebServiceBean"
         init-method="start" destroy-method="stop">
     <!-- url of the real web service we have proxied -->
-    <property name="url" value="http://localhost:9081/real-webservice"/>
+    <property name="url" value="http://localhost:${real.port}/real-webservice"/>
   </bean>
 
   <!-- bean that enriches the SOAP request -->
@@ -42,7 +48,7 @@
 
   <!-- this is the CXF web service we use as the front end -->
   <cxf:cxfEndpoint id="reportIncident"
-                   address="http://localhost:9080/camel-example-cxf-proxy/webservices/incident"
+                   address="http://localhost:${proxy.port}/camel-example-cxf-proxy/webservices/incident"
                    endpointName="s:ReportIncidentEndpoint"
                    serviceName="s:ReportIncidentEndpointService"
                    wsdlURL="etc/report_incident.wsdl"
@@ -51,6 +57,11 @@
   <!-- this is the Camel route which proxies the real web service and forwards SOAP requests to it -->
   <camelContext xmlns="http://camel.apache.org/schema/spring">
 
+    <!-- property which contains port number -->
+    <propertyPlaceholder id="properties" location="classpath:incident.properties,file:target/custom.properties"/>
+
+    <endpoint id="callRealWebService" uri="http://localhost:${real.port}/real-webservice?throwExceptionOnFailure=false"/>
+
     <route>
       <!-- CXF consumer using MESSAGE format -->
       <from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/>
@@ -59,7 +70,7 @@
       <!-- enrich the input by ensure the incidentId parameter is set -->
       <to uri="bean:enrichBean"/>
       <!-- send proxied request to real web service -->
-      <to uri="http://localhost:9081/real-webservice?throwExceptionOnFailure=false"/>
+      <to ref="callRealWebService"/>
       <!-- log answer from real web service -->
       <to uri="log:output"/>
     </route>

Added: camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/incident.properties
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/incident.properties?rev=1224715&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/incident.properties (added)
+++ camel/trunk/examples/camel-example-cxf-proxy/src/main/resources/incident.properties Mon Dec 26 11:28:25 2011
@@ -0,0 +1,20 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+# properties for the application
+proxy.port=9080
+real.port=9081
\ No newline at end of file

Modified: camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java?rev=1224715&r1=1224714&r2=1224715&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java (original)
+++ camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java Mon Dec 26 11:28:25 2011
@@ -16,12 +16,16 @@
  */
 package org.apache.camel.example.reportincident;
 
+import java.io.File;
+import java.io.FileOutputStream;
 
 import org.apache.camel.spring.Main;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
+import static junit.framework.Assert.assertEquals;
 
 /**
  * Unit test of our routes
@@ -29,10 +33,29 @@ import static org.junit.Assert.assertEqu
 public class ReportIncidentRoutesTest {
 
     // should be the same address as we have in our route
-    private static final String URL = "http://localhost:9080/camel-example-cxf-proxy/webservices/incident";
+    private static String URL;
 
     protected Main main;
 
+    @BeforeClass
+    public static void setupFreePort() throws Exception {
+        // find a free port number from 9100 onwards, and write that in the custom.properties file
+        // which we will use for the unit tests, to avoid port number in use problems
+        int port = AvailablePortFinder.getNextAvailable(9100);
+        String s = "proxy.port=" + port;
+        int port2 = AvailablePortFinder.getNextAvailable(port + 1);
+        String s2 = "real.port=" + port2;
+
+        File custom = new File("target/custom.properties");
+        FileOutputStream fos = new FileOutputStream(custom);
+        fos.write(s.getBytes());
+        fos.write("\n".getBytes());
+        fos.write(s2.getBytes());
+        fos.close();
+
+        URL = "http://localhost:" + port + "/camel-example-cxf-proxy/webservices/incident";
+    }
+
     protected void startCamel() throws Exception {
         if (!"true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"))) {
             main = new Main();
@@ -58,7 +81,7 @@ public class ReportIncidentRoutesTest {
     }
 
     @Test
-    public void testRendportIncident() throws Exception {
+    public void testReportIncident() throws Exception {
         // start camel
         startCamel();
 
@@ -82,13 +105,11 @@ public class ReportIncidentRoutesTest {
         input.setPhone("0045 2962 7576");
 
         // create the webservice client and send the request
+        
         ReportIncidentEndpoint client = createCXFClient();
         OutputReportIncident out = client.reportIncident(input);
 
         // assert we got a OK back
         assertEquals("OK;456", out.getCode());
-
-        // let some time pass to allow Camel to pickup the file and send it as an email
-        Thread.sleep(3000);
     }
 }