camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r891163 - in /camel/trunk/components/camel-http/src: main/java/org/apache/camel/component/http/HttpEndpoint.java test/java/org/apache/camel/component/http/HttpProxyTest.java
Date Wed, 16 Dec 2009 09:12:01 GMT
Author: ningjiang
Date: Wed Dec 16 09:12:01 2009
New Revision: 891163

URL: http://svn.apache.org/viewvc?rev=891163&view=rev
Log:
CAMEL-2293 Using the CamelContext properties instead of System properties to set the proxy

Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java?rev=891163&r1=891162&r2=891163&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
Wed Dec 16 09:12:01 2009
@@ -87,13 +87,12 @@
 
         HttpClient answer = new HttpClient(getClientParams());
 
-        // configure http proxy if defined as system property
-        // http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
-        if (System.getProperty("http.proxyHost") != null && System.getProperty("http.proxyPort")
!= null) {
-            String host = System.getProperty("http.proxyHost");
-            int port = Integer.parseInt(System.getProperty("http.proxyPort"));
+        // configure http proxy from camelContext
+        if (getCamelContext().getProperties().get("http.proxyHost") != null && getCamelContext().getProperties().get("http.proxyPort")
!= null) {
+            String host = getCamelContext().getProperties().get("http.proxyHost");
+            int port = Integer.parseInt(getCamelContext().getProperties().get("http.proxyPort"));
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Java System Property http.proxyHost and http.proxyPort detected.
Using http proxy host: "
+                LOG.debug("CamelContext properties http.proxyHost and http.proxyPort detected.
Using http proxy host: "
                         + host + " port: " + port);
             }
             answer.getHostConfiguration().setProxy(host, port);

Modified: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java?rev=891163&r1=891162&r2=891163&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
(original)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
Wed Dec 16 09:12:01 2009
@@ -38,16 +38,16 @@
     public void testHttpProxyConfigured() throws Exception {
         HttpEndpoint http = context.getEndpoint("http://www.google.com", HttpEndpoint.class);
 
-        System.setProperty("http.proxyHost", "myproxy");
-        System.setProperty("http.proxyPort", "1234");
+        context.getProperties().put("http.proxyHost", "myproxy");
+        context.getProperties().put("http.proxyPort", "1234");
 
         try {
             HttpClient client = http.createHttpClient();
             assertEquals("myproxy", client.getHostConfiguration().getProxyHost());
             assertEquals(1234, client.getHostConfiguration().getProxyPort());
         } finally {
-            System.clearProperty("http.proxyHost");
-            System.clearProperty("http.proxyPort");
+            context.getProperties().remove("http.proxyHost");
+            context.getProperties().remove("http.proxyPort");
         }
     }
 
@@ -55,16 +55,16 @@
     public void testHttpProxyEndpointConfigured() throws Exception {
         HttpEndpoint http = context.getEndpoint("http://www.google.com?proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
 
-        System.setProperty("http.proxyHost", "myproxy");
-        System.setProperty("http.proxyPort", "1234");
+        context.getProperties().put("http.proxyHost", "myproxy");
+        context.getProperties().put("http.proxyPort", "1234");
 
         try {
             HttpClient client = http.createHttpClient();
             assertEquals("myotherproxy", client.getHostConfiguration().getProxyHost());
             assertEquals(2345, client.getHostConfiguration().getProxyPort());
         } finally {
-            System.clearProperty("http.proxyHost");
-            System.clearProperty("http.proxyPort");
+            context.getProperties().remove("http.proxyHost");
+            context.getProperties().remove("http.proxyPort");
         }
     }
 



Mime
View raw message