From fcd5c4c69fc5ea84b04f309eb40e295eab921fd8 Mon Sep 17 00:00:00 2001
From: Omair Majid <omajid@redhat.com>
Date: Tue, 24 Sep 2013 13:42:31 -0400
Subject: PR1474: Can't get javaws to use SOCKS proxy

If there is a SOCKS proxy specified, use it for https, http,
and ftp protocols too (as a fallback).

'sameProxy' now affects the https, http and ftp protocols,
but not the socket protocol.
---
 .../jnlp/runtime/JNLPProxySelectorTest.java        | 27 ++++++++++++++++------
 1 file changed, 20 insertions(+), 7 deletions(-)

(limited to 'tests/netx')

diff --git a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPProxySelectorTest.java b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPProxySelectorTest.java
index d522772..bef9745 100644
--- a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPProxySelectorTest.java
+++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPProxySelectorTest.java
@@ -45,7 +45,6 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.Proxy.Type;
-import java.net.SocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.UnknownHostException;
@@ -116,9 +115,11 @@ public class JNLPProxySelectorTest {
         assertEquals(Proxy.NO_PROXY, result.get(0));
     }
 
+    // TODO implement this
+    @Ignore("Implement this")
     @Test
     public void testLocalProxyBypassListIsIgnoredForNonLocal() {
-
+        fail();
     }
 
     @Test
@@ -209,6 +210,23 @@ public class JNLPProxySelectorTest {
         assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
     }
 
+    @Test
+    public void testHttpFallsBackToManualSocksProxy() throws URISyntaxException {
+        String SOCKS_HOST = "example.org";
+        int SOCKS_PORT = 42;
+
+        DeploymentConfiguration config = new DeploymentConfiguration();
+        config.setProperty(DeploymentConfiguration.KEY_PROXY_TYPE, String.valueOf(JNLPProxySelector.PROXY_TYPE_MANUAL));
+        config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST, SOCKS_HOST);
+        config.setProperty(DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT, String.valueOf(SOCKS_PORT));
+
+        JNLPProxySelector selector = new TestProxySelector(config);
+        List<Proxy> result = selector.select(new URI("http://example.org/"));
+
+        assertEquals(1, result.size());
+        assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(SOCKS_HOST, SOCKS_PORT)), result.get(0));
+    }
+
     @Test
     public void testManualUnknownProtocolProxy() throws URISyntaxException {
         DeploymentConfiguration config = new DeploymentConfiguration();
@@ -239,11 +257,6 @@ public class JNLPProxySelectorTest {
 
         assertEquals(1, result.size());
         assertEquals(new Proxy(Type.HTTP, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
-
-        result = selector.select(new URI("socket://example.org/"));
-
-        assertEquals(1, result.size());
-        assertEquals(new Proxy(Type.SOCKS, new InetSocketAddress(HTTP_HOST, HTTP_PORT)), result.get(0));
     }
 
     @Test
-- 
cgit v1.2.3