camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1426207 - in /camel/trunk/components/camel-urlrewrite/src: main/java/org/apache/camel/component/urlrewrite/ test/java/org/apache/camel/component/urlrewrite/ test/java/org/apache/camel/component/urlrewrite/http/ test/java/org/apache/camel/c...
Date Thu, 27 Dec 2012 13:54:38 GMT
Author: davsclaus
Date: Thu Dec 27 13:54:38 2012
New Revision: 1426207

URL: http://svn.apache.org/viewvc?rev=1426207&view=rev
Log:
CAMEL-5912: More work on camel-urlrewrite

Added:
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
  (with props)
Modified:
    camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
    camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
    camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties

Modified: camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/UrlRewriteFilter.java
Thu Dec 27 13:54:38 2012
@@ -41,7 +41,7 @@ public abstract class UrlRewriteFilter e
     private static final Logger LOG = LoggerFactory.getLogger(UrlRewriteFilter.class);
 
     // TODO: Find a better way of starting/stopping this without adding as service to CamelContext
-    // TODO: Dynamic ports of testing
+    // TODO: Add support in camel-http4 and camel-ahc
 
     protected CamelContext camelContext;
     protected Conf conf;
@@ -50,6 +50,9 @@ public abstract class UrlRewriteFilter e
     protected String modRewriteConfFile;
     protected String modRewriteConfText;
     protected boolean useQueryString;
+    protected boolean useContext;
+    protected String defaultMatchType;
+    protected String decodeUsing;
 
     public String rewrite(String url, HttpServletRequest request) throws Exception {
         RewrittenUrl response = urlRewriter.processRequest(request, null);
@@ -119,6 +122,30 @@ public abstract class UrlRewriteFilter e
         this.useQueryString = useQueryString;
     }
 
+    public boolean isUseContext() {
+        return useContext;
+    }
+
+    public void setUseContext(boolean useContext) {
+        this.useContext = useContext;
+    }
+
+    public String getDefaultMatchType() {
+        return defaultMatchType;
+    }
+
+    public void setDefaultMatchType(String defaultMatchType) {
+        this.defaultMatchType = defaultMatchType;
+    }
+
+    public String getDecodeUsing() {
+        return decodeUsing;
+    }
+
+    public void setDecodeUsing(String decodeUsing) {
+        this.decodeUsing = decodeUsing;
+    }
+
     @Override
     protected void doStart() throws Exception {
         ObjectHelper.notNull(camelContext, "camelContext");
@@ -158,6 +185,13 @@ public abstract class UrlRewriteFilter e
             if (conf != null) {
                 // set options before initializing
                 conf.setUseQueryString(isUseQueryString());
+                conf.setUseContext(isUseContext());
+                if (getDefaultMatchType() != null) {
+                    conf.setDefaultMatchType(getDefaultMatchType());
+                }
+                if (getDecodeUsing() != null) {
+                    conf.setDecodeUsing(getDecodeUsing());
+                }
                 conf.initialise();
             }
             if (conf == null || !conf.isOk()) {

Added: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java?rev=1426207&view=auto
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
(added)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
Thu Dec 27 13:54:38 2012
@@ -0,0 +1,83 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.urlrewrite;
+
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.BeforeClass;
+
+/**
+ *
+ */
+public abstract class BaseUrlRewriteTest extends CamelTestSupport {
+
+    private static volatile int port;
+
+    private static volatile int port2;
+
+    private final AtomicInteger counter = new AtomicInteger(1);
+
+    @BeforeClass
+    public static void initPort() throws Exception {
+        // start from somewhere in the 23xxx range
+        port = AvailablePortFinder.getNextAvailable(23000);
+        // find another ports for proxy route test
+        port2 = AvailablePortFinder.getNextAvailable(24000);
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        context.addComponent("properties", new PropertiesComponent("ref:prop"));
+        return context;
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+
+        Properties prop = new Properties();
+        prop.setProperty("port", "" + getPort());
+        prop.setProperty("port2", "" + getPort2());
+        jndi.bind("prop", prop);
+        return jndi;
+    }
+
+    protected int getNextPort() {
+        return AvailablePortFinder.getNextAvailable(port + counter.getAndIncrement());
+    }
+
+    protected int getNextPort(int startWithPort) {
+        return AvailablePortFinder.getNextAvailable(startWithPort);
+    }
+
+    protected static int getPort() {
+        return port;
+    }
+
+    protected static int getPort2() {
+        return port2;
+    }
+
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/BaseUrlRewriteTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteModFileTest extends CamelTestSupport {
+public class HttpUrlRewriteModFileTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -41,8 +41,8 @@ public class HttpUrlRewriteModFileTest e
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:8080/myapp/page/software/", null,
String.class);
-        assertEquals("http://localhost:8081/myapp2/index.php?page=software", out);
+        String out = template.requestBody("http://localhost:{{port}}/myapp/page/software/",
null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/myapp2/index.php?page=software",
out);
     }
 
     @Override
@@ -50,10 +50,10 @@ public class HttpUrlRewriteModFileTest e
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:8081/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
+                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/myapp2?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteModTest extends CamelTestSupport {
+public class HttpUrlRewriteModTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -41,8 +41,8 @@ public class HttpUrlRewriteModTest exten
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:8080/myapp/page/software/", null,
String.class);
-        assertEquals("http://localhost:8081/myapp2/index.php?page=software", out);
+        String out = template.requestBody("http://localhost:{{port}}/myapp/page/software/",
null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/myapp2/index.php?page=software",
out);
     }
 
     @Override
@@ -50,10 +50,10 @@ public class HttpUrlRewriteModTest exten
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:8081/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
+                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/myapp2?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewritePingQueryTest extends CamelTestSupport {
+public class HttpUrlRewritePingQueryTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -42,8 +42,8 @@ public class HttpUrlRewritePingQueryTest
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:8080/ping?foo=bar", null, String.class);
-        assertEquals("http://localhost:8081/proxy/ping?foo=bar", out);
+        String out = template.requestBody("http://localhost:{{port}}/ping?foo=bar", null,
String.class);
+        assertEquals("http://localhost:" + getPort2() + "/proxy/ping?foo=bar", out);
     }
 
     @Override
@@ -51,10 +51,10 @@ public class HttpUrlRewritePingQueryTest
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/?matchOnUriPrefix=true")
-                    .to("http://localhost:8081/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/?matchOnUriPrefix=true")
+                    .to("http://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/proxy/?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/proxy/?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewritePingTest extends CamelTestSupport {
+public class HttpUrlRewritePingTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -42,8 +42,8 @@ public class HttpUrlRewritePingTest exte
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:8080/ping", null, String.class);
-        assertEquals("http://localhost:8081/proxy/ping", out);
+        String out = template.requestBody("http://localhost:{{port}}/ping", null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/proxy/ping", out);
     }
 
     @Override
@@ -51,10 +51,10 @@ public class HttpUrlRewritePingTest exte
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/?matchOnUriPrefix=true")
-                    .to("http://localhost:8081/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/?matchOnUriPrefix=true")
+                    .to("http://localhost:{{port2}}/?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/proxy/?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/proxy/?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
Thu Dec 27 13:54:38 2012
@@ -16,21 +16,16 @@
  */
 package org.apache.camel.component.urlrewrite.http;
 
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class HttpUrlRewriteTest extends CamelTestSupport {
+public class HttpUrlRewriteTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -46,8 +41,8 @@ public class HttpUrlRewriteTest extends 
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("http://localhost:8080/myapp/products/1234", null,
String.class);
-        assertEquals("http://localhost:8081/myapp2/products/index.jsp?product_id=1234", out);
+        String out = template.requestBody("http://localhost:{{port}}/myapp/products/1234",
null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/myapp2/products/index.jsp?product_id=1234",
out);
     }
 
     @Override
@@ -55,10 +50,10 @@ public class HttpUrlRewriteTest extends 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp?matchOnUriPrefix=true")
-                    .to("http://localhost:8081/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
+                    .to("http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/myapp2?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class JettyUrlRewriteModTest extends CamelTestSupport {
+public class JettyUrlRewriteModTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -41,8 +41,8 @@ public class JettyUrlRewriteModTest exte
 
     @Test
     public void testHttpUriRewrite() throws Exception {
-        String out = template.requestBody("jetty:http://localhost:8080/myapp/page/software/",
null, String.class);
-        assertEquals("http://localhost:8081/myapp2/index.php?page=software", out);
+        String out = template.requestBody("jetty:http://localhost:{{port}}/myapp/page/software/",
null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/myapp2/index.php?page=software",
out);
     }
 
     @Override
@@ -50,10 +50,10 @@ public class JettyUrlRewriteModTest exte
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp?matchOnUriPrefix=true")
-                    .to("jetty:http://localhost:8081/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
+                    .to("jetty:http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/myapp2?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
(original)
+++ camel/trunk/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
Thu Dec 27 13:54:38 2012
@@ -17,15 +17,15 @@
 package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
 import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 /**
  *
  */
-public class JettyUrlRewriteTest extends CamelTestSupport {
+public class JettyUrlRewriteTest extends BaseUrlRewriteTest {
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
@@ -41,8 +41,8 @@ public class JettyUrlRewriteTest extends
 
     @Test
     public void testJettyUriRewrite() throws Exception {
-        String out = template.requestBody("jetty:http://localhost:8080/myapp/products/1234",
null, String.class);
-        assertEquals("http://localhost:8081/myapp2/products/index.jsp?product_id=1234", out);
+        String out = template.requestBody("jetty:http://localhost:{{port}}/myapp/products/1234",
null, String.class);
+        assertEquals("http://localhost:" + getPort2() + "/myapp2/products/index.jsp?product_id=1234",
out);
     }
 
     @Override
@@ -50,10 +50,10 @@ public class JettyUrlRewriteTest extends
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp?matchOnUriPrefix=true")
-                    .to("jetty:http://localhost:8081/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
+                from("jetty:http://localhost:{{port}}/myapp?matchOnUriPrefix=true")
+                    .to("jetty:http://localhost:{{port2}}/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite");
 
-                from("jetty:http://localhost:8081/myapp2?matchOnUriPrefix=true")
+                from("jetty:http://localhost:{{port2}}/myapp2?matchOnUriPrefix=true")
                     .transform().simple("${header.CamelHttpUrl}?${header.CamelHttpQuery}");
             }
         };

Modified: camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties?rev=1426207&r1=1426206&r2=1426207&view=diff
==============================================================================
--- camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties (original)
+++ camel/trunk/components/camel-urlrewrite/src/test/resources/log4j.properties Thu Dec 27
13:54:38 2012
@@ -18,9 +18,6 @@
 #
 # The logging properties used during tests..
 #
-#
-# The logging properties used for eclipse testing, We want to see debug output on the console.
-#
 log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging



Mime
View raw message