You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2012/01/08 00:07:00 UTC

svn commit: r1228756 - in /camel/trunk/examples/camel-example-cxf-osgi/src/test: java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java resources/camel-context.xml

Author: cmueller
Date: Sat Jan  7 23:07:00 2012
New Revision: 1228756

URL: http://svn.apache.org/viewvc?rev=1228756&view=rev
Log:
fixed failed unit test

Modified:
    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

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=1228756&r1=1228755&r2=1228756&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 Sat Jan  7 23:07:00 2012
@@ -16,12 +16,10 @@
  */
 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.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
@@ -34,17 +32,15 @@ public class ReportIncidentRoutesClientT
 
     // should be the same address as we have in our route
     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();
+    public static void setUpBeforeClass() {
+        System.setProperty("port", String.valueOf(AvailablePortFinder.getNextAvailable(9100)));
+    }
+    
+    @AfterClass
+    public static void tearDownBeforeClass() {
+        System.clearProperty("port");
     }
 
     protected static ReportIncidentEndpoint createCXFClient(String url) {
@@ -83,10 +79,9 @@ 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"});
     }
-
-}
+}
\ No newline at end of file

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=1228756&r1=1228755&r2=1228756&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 Sat Jan  7 23:07:00 2012
@@ -24,6 +24,9 @@
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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">
+
+    <!-- resolve dynamicly the port number from a system property -->
+    <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
     
     <cxf:cxfEndpoint id="reportIncident"
                      address="http://localhost:{{port}}/cxf/camel-example-cxf-osgi/webservices/incident"