DefaultProxySelector implements ProxySelector { static boolean isNonProxyHosts( String host, String nonProxyHosts ) { if ( host != null && nonProxyHosts != null && nonProxyHosts.length() > 0 ) { for ( StringTokenizer tokenizer = new StringTokenizer( nonProxyHosts, "|" ); tokenizer.hasMoreTokens(); ) { String pattern = tokenizer.nextToken(); pattern = pattern.replace( ".", "\\." ).replace( "*", ".*" ); if ( host.matches( pattern ) ) { return true; } } } return false; }  DefaultProxySelector add( Proxy proxy, String nonProxyHosts ); Proxy getProxy( RemoteRepository repository );  }
@Test public void testIsNonProxyHosts() { assertFalse( isNonProxyHosts( "www.sonatype.org", null ) ); assertFalse( isNonProxyHosts( "www.sonatype.org", "" ) ); assertTrue( isNonProxyHosts( "www.sonatype.org", "*" ) ); assertTrue( isNonProxyHosts( "www.sonatype.org", "*.org" ) ); assertTrue( isNonProxyHosts( "www.sonatype.org", "www.*" ) ); assertTrue( isNonProxyHosts( "www.sonatype.org", "www.*.org" ) ); assertFalse( isNonProxyHosts( "www.sonatype.org", "www.sonatype.com" ) ); assertFalse( isNonProxyHosts( "www.sonatype.org", "*.com" ) ); assertFalse( isNonProxyHosts( "www.sonatype.org", "sonatype.org" ) ); assertTrue( isNonProxyHosts( "www.sonatype.org", "*.com|*.org" ) ); }