camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1230571 - in /camel/trunk/components/camel-solr/src/test: java/org/apache/camel/component/solr/ resources/
Date Thu, 12 Jan 2012 14:51:49 GMT
Author: hadrian
Date: Thu Jan 12 14:51:48 2012
New Revision: 1230571

URL: http://svn.apache.org/viewvc?rev=1230571&view=rev
Log:
CAMEL-4890. Dynamic ports for camel-solr. Thanks Babak for patch

Modified:
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
    camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
    camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml

Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java?rev=1230571&r1=1230570&r2=1230571&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
(original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrComponentTestSupport.java
Thu Jan 12 14:51:48 2012
@@ -18,6 +18,7 @@ package org.apache.camel.component.solr;
 
 import java.util.HashMap;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -29,6 +30,8 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 
 public class SolrComponentTestSupport extends CamelTestSupport {
+    public static final int PORT = AvailablePortFinder.getNextAvailable(8899);
+    public static final String SOLR_ROUTE_URI = "solr://localhost:" + PORT + "/solr";
 
     protected static final String TEST_ID = "1234";
     protected static JettySolrRunner solrRunner;
@@ -61,10 +64,10 @@ public class SolrComponentTestSupport ex
         System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
 
         // Start a Solr instance.
-        solrRunner = new JettySolrRunner("/solr", 8999);
+        solrRunner = new JettySolrRunner("/solr", PORT);
         solrRunner.start();
 
-        solrServer = new CommonsHttpSolrServer("http://localhost:8999/solr");
+        solrServer = new CommonsHttpSolrServer("http://localhost:" + PORT + "/solr");
     }
 
     @AfterClass
@@ -77,7 +80,7 @@ public class SolrComponentTestSupport ex
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("solr://localhost:8999/solr");
+                from("direct:start").to(SOLR_ROUTE_URI);
             }
         };
     }

Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java?rev=1230571&r1=1230570&r2=1230571&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
(original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
Thu Jan 12 14:51:48 2012
@@ -38,6 +38,10 @@ import org.springframework.test.context.
 @ContextConfiguration (locations = {"/SolrSpringTest-context.xml"})
 public class SolrSpringTest extends AbstractJUnit4SpringContextTests {
 
+    static {
+        System.setProperty("SolrServer.Port", Integer.toString(SolrComponentTestSupport.PORT));
+    }
+
     private static JettySolrRunner solrRunner;
     private static CommonsHttpSolrServer solrServer;
 
@@ -92,10 +96,10 @@ public class SolrSpringTest extends Abst
         System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
 
         // Start a Solr instance.
-        solrRunner = new JettySolrRunner("/solr", 8899);
+        solrRunner = new JettySolrRunner("/solr", SolrComponentTestSupport.PORT);
         solrRunner.start();
 
-        solrServer = new CommonsHttpSolrServer("http://localhost:8899/solr");
+        solrServer = new CommonsHttpSolrServer("http://localhost:" + SolrComponentTestSupport.PORT
+ "/solr");
     }
 
     @AfterClass

Modified: camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java?rev=1230571&r1=1230570&r2=1230571&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
(original)
+++ camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrUpdateTest.java
Thu Jan 12 14:51:48 2012
@@ -24,13 +24,20 @@ import org.apache.camel.Exchange;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
 import org.apache.solr.common.SolrException;
+import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
 public class SolrUpdateTest extends SolrComponentTestSupport {
 
-    @EndpointInject(uri = "solr://localhost:8999/solr")
-    protected SolrEndpoint solrEndpoint;
+    private SolrEndpoint solrEndpoint;
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        solrEndpoint = getMandatoryEndpoint(SOLR_ROUTE_URI, SolrEndpoint.class);
+    }
 
     @Test
     public void indexSingleDocumentOnlyWithId() throws Exception {

Modified: camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml?rev=1230571&r1=1230570&r2=1230571&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml (original)
+++ camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml Thu Jan
12 14:51:48 2012
@@ -4,6 +4,8 @@
             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">
 
+    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"/>
+
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route id="XMLRoute">
             <from uri="direct:xml-start" />
@@ -25,12 +27,12 @@
                         book.cat.collect{ it.text() } as String[]
                     </groovy>
                 </setHeader>
-                <to uri="solr://localhost:8899/solr"/>
+                <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
             </split>
             <setHeader headerName="SolrOperation">
                 <constant>COMMIT</constant>
             </setHeader>
-            <to uri="solr://localhost:8899/solr"/>
+            <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
         </route>
 
         <route id="PDFRoute">
@@ -41,11 +43,11 @@
             <setHeader headerName="SolrParam.literal.id">
                 <simple>${body.name}</simple>
             </setHeader>
-            <to uri="solr://localhost:8899/solr?requestHandler=/update/extract" />
+            <to uri="solr://localhost:{{SolrServer.Port}}/solr?requestHandler=/update/extract"
/>
             <setHeader headerName="SolrOperation">
                 <constant>COMMIT</constant>
             </setHeader>
-            <to uri="solr://localhost:8899/solr"/>
+            <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
         </route>
     </camelContext>
 



Mime
View raw message