maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r680764 - in /maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src: main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
Date Tue, 29 Jul 2008 16:45:53 GMT
Author: brett
Date: Tue Jul 29 09:45:51 2008
New Revision: 680764

URL: http://svn.apache.org/viewvc?rev=680764&view=rev
Log:
[WAGON-232] Lightweight HTTP wagon doesn't reset proxy settings correctly if they were not
previously set

Modified:
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=680764&r1=680763&r2=680764&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
Tue Jul 29 09:45:51 2008
@@ -223,6 +223,11 @@
                 System.setProperty( "http.nonProxyHosts", proxyInfo.getNonProxyHosts() );
             }
         }
+        else
+        {
+            System.getProperties().remove( "http.proxyHost" );
+            System.getProperties().remove( "http.proxyPort" );
+        }
 
         final boolean hasProxy = ( proxyInfo != null && proxyInfo.getUserName() !=
null );
         final boolean hasAuthentication = ( authenticationInfo != null && authenticationInfo.getUserName()
!= null );
@@ -271,14 +276,26 @@
         {
             System.setProperty( "http.proxyHost", previousHttpProxyHost );
         }
+        else
+        {
+            System.getProperties().remove( "http.proxyHost" );
+        }
         if ( previousHttpProxyPort != null )
         {
             System.setProperty( "http.proxyPort", previousHttpProxyPort );
         }
+        else
+        {
+            System.getProperties().remove( "http.proxyPort" );
+        }
         if ( previousProxyExclusions != null )
         {
             System.setProperty( "http.nonProxyHosts", previousProxyExclusions );
         }
+        else
+        {
+            System.getProperties().remove( "http.nonProxyHosts" );
+        }
     }
 
     public List getFileList( String destinationDirectory )

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java?rev=680764&r1=680763&r2=680764&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
Tue Jul 29 09:45:51 2008
@@ -23,6 +23,8 @@
 
 import org.apache.maven.wagon.FileTestUtils;
 import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
 import org.apache.maven.wagon.resource.Resource;
 import org.codehaus.plexus.jetty.Httpd;
@@ -86,4 +88,92 @@
         File file = getTestFile( "target/test-output/http-repository", resource.getName()
);
         return file.lastModified();
     }
+
+    public void testProxyReset()
+        throws Exception
+    {
+        ProxyInfo proxyInfo = new ProxyInfo();
+        proxyInfo.setType( "http" );
+        proxyInfo.setHost( "proxyhost" );
+        proxyInfo.setPort( 1234 );
+        proxyInfo.setNonProxyHosts( "non" );
+
+        Repository repository = new Repository();
+
+        String proxyHost = System.getProperty( "http.proxyHost" );
+        String proxyPort = System.getProperty( "http.proxyPort" );
+        String nonProxyHosts = System.getProperty( "http.nonProxyHosts" );
+  
+        System.getProperties().remove( "http.proxyHost" );
+        System.getProperties().remove( "http.proxyPort" );
+
+        Wagon wagon = getWagon();
+
+        wagon.connect( repository, proxyInfo );
+
+        assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) );
+        assertEquals( "1234", System.getProperty( "http.proxyPort" ) );
+        assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) );
+        
+        wagon.disconnect();
+
+        assertNull( System.getProperty( "http.proxyHost" ) );
+        assertNull( System.getProperty( "http.proxyPort" ) );
+        
+        System.setProperty( "http.proxyHost", "host" );
+        System.setProperty( "http.proxyPort", "port" );
+        System.setProperty( "http.nonProxyHosts", "hosts" );
+
+        wagon = getWagon();
+
+        wagon.connect( repository, proxyInfo );
+
+        assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) );
+        assertEquals( "1234", System.getProperty( "http.proxyPort" ) );
+        assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) );
+        
+        wagon.disconnect();
+
+        assertEquals( "host", System.getProperty( "http.proxyHost" ) );
+        assertEquals( "port", System.getProperty( "http.proxyPort" ) );
+        assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) );
+        
+        wagon = getWagon();
+
+        wagon.connect( repository );
+
+        assertNull( System.getProperty( "http.proxyHost" ) );
+        assertNull( System.getProperty( "http.proxyPort" ) );
+        
+        wagon.disconnect();
+
+        assertEquals( "host", System.getProperty( "http.proxyHost" ) );
+        assertEquals( "port", System.getProperty( "http.proxyPort" ) );
+        assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) );
+        
+        if ( proxyHost != null )
+        {
+            System.setProperty( "http.proxyHost", proxyHost );
+        }
+        else
+        {
+            System.getProperties().remove( "http.proxyHost" );
+        }
+        if ( proxyPort != null )
+        {
+            System.setProperty( "http.proxyPort", proxyPort );
+        }
+        else
+        {
+            System.getProperties().remove( "http.proxyPort" );
+        }
+        if ( nonProxyHosts != null )
+        {
+            System.setProperty( "http.nonProxyHosts", nonProxyHosts );
+        }
+        else
+        {
+            System.getProperties().remove( "http.nonProxyHosts" );
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message