aboutsummaryrefslogtreecommitdiffstats
path: root/tests/netx/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/netx/unit')
-rw-r--r--tests/netx/unit/sun/applet/PluginAppletViewerTest.java37
-rw-r--r--tests/netx/unit/sun/applet/PluginProxySelectorTest.java41
2 files changed, 40 insertions, 38 deletions
diff --git a/tests/netx/unit/sun/applet/PluginAppletViewerTest.java b/tests/netx/unit/sun/applet/PluginAppletViewerTest.java
index 69e5cb1..1bf7e35 100644
--- a/tests/netx/unit/sun/applet/PluginAppletViewerTest.java
+++ b/tests/netx/unit/sun/applet/PluginAppletViewerTest.java
@@ -159,43 +159,6 @@ public class PluginAppletViewerTest {
assertEquals(expectedReturn, call.join());
}
- @Test
- public void testConvertUriSchemeForProxyQuery() throws Exception {
- URI[] testUris = {
- new URI("http", "foo.com", "/bar", null),
- new URI("https", "foo.com", "/bar", null),
- new URI("ftp", "foo.com", "/app/res/pub/channel.jar?i=1234", null),
- new URI("socket", "foo.co.uk", "/bar/pub/ale.jar", null),
- };
-
- for (URI uri : testUris) {
- URI result = new URI(PluginAppletViewer.convertUriSchemeForProxyQuery(uri));
- assertQueryForBrowserProxyUsesHttpFallback(uri, result);
- String hierarchicalPath = result.getAuthority() + result.getPath();
- assertQueryForBrowserProxyContainsNoDoubleSlashes(hierarchicalPath);
- assertQueryForBrowserProxyDoesNotChangeQuery(uri, result);
- }
- }
-
- // Test that only HTTP is used as fallback scheme if a protocol other than HTTP(S) or FTP is specified
- public void assertQueryForBrowserProxyUsesHttpFallback(URI expected, URI result) {
- if (expected.getScheme().equals("ftp") || expected.getScheme().startsWith("http")) {
- Assert.assertEquals(expected.getScheme(), result.getScheme());
- } else {
- Assert.assertEquals(result.getScheme(), "http");
- }
- }
-
- // Test that absolute resource paths do not result in double-slashes within the URI
- public void assertQueryForBrowserProxyContainsNoDoubleSlashes(String uri) {
- Assert.assertFalse(uri.contains("//"));
- }
-
- // Test that the query string of the URI is not changed
- public void assertQueryForBrowserProxyDoesNotChangeQuery(URI expected, URI result) {
- Assert.assertEquals(expected.getQuery(), result.getQuery());
- }
-
/**************************************************************************
* Test utilities *
**************************************************************************/
diff --git a/tests/netx/unit/sun/applet/PluginProxySelectorTest.java b/tests/netx/unit/sun/applet/PluginProxySelectorTest.java
index 322a798..a7321f6 100644
--- a/tests/netx/unit/sun/applet/PluginProxySelectorTest.java
+++ b/tests/netx/unit/sun/applet/PluginProxySelectorTest.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package sun.applet;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.net.InetSocketAddress;
@@ -65,7 +66,7 @@ public class PluginProxySelectorTest {
}
@Override
- protected Object getProxyFromRemoteCallToBrowser(URI uri) {
+ protected Object getProxyFromRemoteCallToBrowser(String uri) {
remoteCallCount++;
return browserResponse;
}
@@ -192,4 +193,42 @@ public class PluginProxySelectorTest {
assertEquals(2, proxySelector.getRemoteCallCount());
}
+
+ @Test
+ public void testConvertUriSchemeForProxyQuery() throws Exception {
+ URI[] testUris = {
+ new URI("http", "foo.com", "/bar", null),
+ new URI("https", "foo.com", "/bar", null),
+ new URI("ftp", "foo.com", "/app/res/pub/channel.jar?i=1234", null),
+ new URI("socket", "foo.co.uk", "/bar/pub/ale.jar", null),
+ };
+
+ for (URI uri : testUris) {
+ URI result = new URI(PluginProxySelector.convertUriSchemeForProxyQuery(uri));
+ assertQueryForBrowserProxyUsesHttpFallback(uri, result);
+ String hierarchicalPath = result.getAuthority() + result.getPath();
+ assertQueryForBrowserProxyContainsNoDoubleSlashes(hierarchicalPath);
+ assertQueryForBrowserProxyDoesNotChangeQuery(uri, result);
+ }
+ }
+
+ // Test that only HTTP is used as fallback scheme if a protocol other than HTTP(S) or FTP is specified
+ public void assertQueryForBrowserProxyUsesHttpFallback(URI expected, URI result) {
+ if (expected.getScheme().equals("ftp") || expected.getScheme().startsWith("http")) {
+ assertEquals(expected.getScheme(), result.getScheme());
+ } else {
+ assertEquals(result.getScheme(), "http");
+ }
+ }
+
+ // Test that absolute resource paths do not result in double-slashes within the URI
+ public void assertQueryForBrowserProxyContainsNoDoubleSlashes(String uri) {
+ assertFalse(uri.contains("//"));
+ }
+
+ // Test that the query string of the URI is not changed
+ public void assertQueryForBrowserProxyDoesNotChangeQuery(URI expected, URI result) {
+ assertEquals(expected.getQuery(), result.getQuery());
+ }
+
}