You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/08/04 06:51:32 UTC
svn commit: r428620 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/net/ProxySelectorImpl.java
test/java/tests/api/java/net/ProxySelectorTest.java
Author: pyang
Date: Thu Aug 3 21:51:31 2006
New Revision: 428620
URL: http://svn.apache.org/viewvc?rev=428620&view=rev
Log:
Fix for HARMONY-1063 ([classlib][luni] java.net.ProxySelector.select(URI uri) throws unexpected IllegalArgumentException when uri.host is null.)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java?rev=428620&r1=428619&r2=428620&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java Thu Aug 3 21:51:31 2006
@@ -71,12 +71,8 @@
if (null == scheme) {
throw new IllegalArgumentException();
}
- // check host
+
String host = uri.getHost();
- if (null == host) {
- throw new IllegalArgumentException();
- }
-
Proxy proxy = Proxy.NO_PROXY;
if ("http".equals(scheme)) { //$NON-NLS-1$
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java?rev=428620&r1=428619&r2=428620&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ProxySelectorTest.java Thu Aug 3 21:51:31 2006
@@ -185,6 +185,51 @@
assertProxyEquals(proxyList,Proxy.Type.SOCKS,SOCKS_PROXY_HOST,SOCKS_PROXY_PORT);
}
+
+ /**
+ * @tests java.net.ProxySelector#select(URI)
+ */
+ public void test_selectLjava_net_URI_SelectExact_NullHost()
+ throws URISyntaxException {
+ // regression test for Harmony-1063
+ httpUri = new URI("http://a@");
+ ftpUri = new URI("ftp://a@");
+ httpsUri = new URI("https://a@");
+ tcpUri = new URI("socket://a@");
+ // no proxy, return a proxyList only contains NO_PROXY
+ proxyList = selector.select(httpUri);
+ assertProxyEquals(proxyList, Proxy.NO_PROXY);
+
+ // set http proxy
+ System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
+ System.setProperty("http.proxyPort", String.valueOf(HTTP_PROXY_PORT));
+ // set https proxy
+ System.setProperty("https.proxyHost", HTTPS_PROXY_HOST);
+ System.setProperty("https.proxyPort", String.valueOf(HTTPS_PROXY_PORT));
+ // set ftp proxy
+ System.setProperty("ftp.proxyHost", FTP_PROXY_HOST);
+ System.setProperty("ftp.proxyPort", String.valueOf(FTP_PROXY_PORT));
+ // set socks proxy
+ System.setProperty("socksProxyHost", SOCKS_PROXY_HOST);
+ System.setProperty("socksProxyPort", String.valueOf(SOCKS_PROXY_PORT));
+
+ proxyList = selector.select(httpUri);
+ assertProxyEquals(proxyList, Proxy.Type.HTTP, HTTP_PROXY_HOST,
+ HTTP_PROXY_PORT);
+
+ proxyList = selector.select(httpsUri);
+ assertProxyEquals(proxyList, Proxy.Type.HTTP, HTTPS_PROXY_HOST,
+ HTTPS_PROXY_PORT);
+
+ proxyList = selector.select(ftpUri);
+ assertProxyEquals(proxyList, Proxy.Type.HTTP, FTP_PROXY_HOST,
+ FTP_PROXY_PORT);
+
+ proxyList = selector.select(tcpUri);
+ assertProxyEquals(proxyList, Proxy.Type.SOCKS, SOCKS_PROXY_HOST,
+ SOCKS_PROXY_PORT);
+
+ }
/**
* @tests java.net.ProxySelector#select(URI)
@@ -518,7 +563,7 @@
}
- public List select(URI uri) {
+ public List <Proxy> select(URI uri) {
return null;
}
}