aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2013-09-23 12:34:25 -0400
committerOmair Majid <[email protected]>2013-09-23 12:34:25 -0400
commit0b4378d462bf9e44afe71d8c87adf682dd116c50 (patch)
treec91b0ace61b30e086d54c2a09f3d748a09c8461a /netx/net/sourceforge/jnlp
parent9ba69baff18dd24b207e0a8b6ad76133fe4ea536 (diff)
Unit tests for JNLPProxySelector
This contains one functional change: - String host = uri.getSchemeSpecificPart().split(":")[0]; + String host = uri.getHost(); Given the URI of "socket://example.org", the first line evaluates to "//example.org", while the second one (correctly) evaluates to "example.org".
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java5
-rw-r--r--netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java4
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java16
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java2
4 files changed, 13 insertions, 14 deletions
diff --git a/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java b/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
index 831aee0..835444b 100644
--- a/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
+++ b/netx/net/sourceforge/jnlp/browser/BrowserAwareProxySelector.java
@@ -52,6 +52,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPProxySelector;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.runtime.PacEvaluator;
@@ -92,8 +93,8 @@ public class BrowserAwareProxySelector extends JNLPProxySelector {
/**
* Create a new instance of this class, reading configuration fropm the browser
*/
- public BrowserAwareProxySelector() {
- super();
+ public BrowserAwareProxySelector(DeploymentConfiguration config) {
+ super(config);
try {
initFromBrowserConfig();
} catch (IOException e) {
diff --git a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
index fd7cf9b..25aab36 100644
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
@@ -36,8 +36,8 @@ import java.util.Properties;
import java.util.Set;
import javax.naming.ConfigurationException;
-import net.sourceforge.jnlp.cache.CacheLRUWrapper;
+import net.sourceforge.jnlp.cache.CacheLRUWrapper;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
import net.sourceforge.jnlp.util.FileUtils;
@@ -126,6 +126,8 @@ public final class DeploymentConfiguration {
/*
* Networking
*/
+
+ /** the proxy type. possible values are {@code JNLPProxySelector.PROXY_TYPE_*} */
public static final String KEY_PROXY_TYPE = "deployment.proxy.type";
public static final String KEY_PROXY_SAME = "deployment.proxy.same";
public static final String KEY_PROXY_AUTO_CONFIG_URL = "deployment.proxy.auto.config.url";
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
index db5a9b7..b8fd25d 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java
@@ -82,19 +82,14 @@ public abstract class JNLPProxySelector extends ProxySelector {
// FIXME what is this? where should it be used?
private String overrideHosts = null;
- /**
- * Creates a new JNLPProxySelector.
- */
- public JNLPProxySelector() {
- parseConfiguration();
+ public JNLPProxySelector(DeploymentConfiguration config) {
+ parseConfiguration(config);
}
/**
* Initialize this ProxySelector by reading the configuration
*/
- private void parseConfiguration() {
- DeploymentConfiguration config = JNLPRuntime.getConfiguration();
-
+ private void parseConfiguration(DeploymentConfiguration config) {
proxyType = Integer.valueOf(config.getProperty(DeploymentConfiguration.KEY_PROXY_TYPE));
String autoConfigString = config.getProperty(DeploymentConfiguration.KEY_PROXY_AUTO_CONFIG_URL);
@@ -240,7 +235,7 @@ public abstract class JNLPProxySelector extends ProxySelector {
return true;
}
} else if (scheme.equals("socket")) {
- String host = uri.getSchemeSpecificPart().split(":")[0];
+ String host = uri.getHost();
if (bypassLocal && isLocalHost(host)) {
return true;
@@ -368,7 +363,8 @@ public abstract class JNLPProxySelector extends ProxySelector {
* suitable for java.
* @param pacString a string indicating proxies. For example
* "PROXY foo.bar:3128; DIRECT"
- * @return a list of Proxy objects represeting the parsed string.
+ * @return a list of Proxy objects representing the parsed string. In
+ * case of malformed input, an empty list may be returned
*/
public static List<Proxy> getProxiesFromPacResult(String pacString) {
List<Proxy> proxies = new ArrayList<Proxy>();
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
index 816807b..a2fcb7d 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
@@ -265,7 +265,7 @@ public class JNLPRuntime {
// plug in a custom authenticator and proxy selector
Authenticator.setDefault(new JNLPAuthenticator());
- ProxySelector.setDefault(new BrowserAwareProxySelector());
+ ProxySelector.setDefault(new BrowserAwareProxySelector(config));
// Restrict access to netx classes
Security.setProperty("package.access",