Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2012-10-08 00:27:55 +0000
committerslewis2012-10-08 00:27:55 +0000
commit75e169d2bc69328428723c81c895384416d0552e (patch)
tree892ec88bfa497e3c385beff00502f6b809f36443
parent2e1b8793b688f95ccc0438e6558795c91b8c43d4 (diff)
downloadorg.eclipse.ecf-75e169d2bc69328428723c81c895384416d0552e.tar.gz
org.eclipse.ecf-75e169d2bc69328428723c81c895384416d0552e.tar.xz
org.eclipse.ecf-75e169d2bc69328428723c81c895384416d0552e.zip
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=307477. Also
added two new test bundles: org.eclipse.ecf.tests.filetransfer.httpclient and org.eclipse.ecf.tests.filetransfer.httpclient4
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java8
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java8
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.classpath7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.project28
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/META-INF/MANIFEST.MF13
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/build.properties4
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/src/org/eclipse/ecf/tests/filetransfer/httpclient/HttpClientGetPortFromURLTest.java77
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.classpath7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.project28
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/META-INF/MANIFEST.MF14
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/build.properties4
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/src/org/eclipse/ecf/tests/filetransfer/httpclient4/HttpClientGetPortFromURLTest.java77
18 files changed, 295 insertions, 4 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/META-INF/MANIFEST.MF
index 2cca465a1..e734c270a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.httpclient;singleton:=true
-Bundle-Version: 4.0.200.qualifier
+Bundle-Version: 4.0.300.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.httpclient.Activator
Require-Bundle: org.eclipse.equinox.common,
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
index 6e1a9bc50..a58b6cb50 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient/src/org/eclipse/ecf/provider/filetransfer/httpclient/HttpClientRetrieveFileTransfer.java
@@ -825,13 +825,19 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
// This is wrong as if the url has no colonPort before '?' then it should return the default
- final int colonPort = url.indexOf(':', colonSlashSlash + 1);
+ int colonPort = url.indexOf(':', colonSlashSlash + 1);
if (colonPort < 0)
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
// Make sure that the colonPort is not from some part of the rest of the URL
int nextSlash = url.indexOf('/', colonSlashSlash + 3);
if (nextSlash != -1 && colonPort > nextSlash)
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
+ // Make sure the colonPort is not part of the credentials in URI
+ final int atServer = url.indexOf('@', colonSlashSlash + 1);
+ if (atServer != -1 && colonPort < atServer && atServer < nextSlash)
+ colonPort = url.indexOf(':', atServer + 1);
+ if (colonPort < 0)
+ return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
final int requestPath = url.indexOf('/', colonPort + 1);
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
index 6a84286c7..a82e21971 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.httpclient4;singleton:=true
-Bundle-Version: 1.0.100.qualifier
+Bundle-Version: 1.0.200.qualifier
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.httpclient4.Activator
Require-Bundle: org.eclipse.equinox.common,
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
index f8901b533..529b059fc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient4/src/org/eclipse/ecf/provider/filetransfer/httpclient4/HttpClientRetrieveFileTransfer.java
@@ -751,13 +751,19 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
// This is wrong as if the url has no colonPort before '?' then it should return the default
- final int colonPort = url.indexOf(':', colonSlashSlash + 1);
+ int colonPort = url.indexOf(':', colonSlashSlash + 1);
if (colonPort < 0)
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
// Make sure that the colonPort is not from some part of the rest of the URL
int nextSlash = url.indexOf('/', colonSlashSlash + 3);
if (nextSlash != -1 && colonPort > nextSlash)
return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
+ // Make sure the colonPort is not part of the credentials in URI
+ final int atServer = url.indexOf('@', colonSlashSlash + 1);
+ if (atServer != -1 && colonPort < atServer && atServer < nextSlash)
+ colonPort = url.indexOf(':', atServer + 1);
+ if (colonPort < 0)
+ return urlUsesHttps(url) ? HTTPS_PORT : HTTP_PORT;
final int requestPath = url.indexOf('/', colonPort + 1);
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.classpath b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.classpath
new file mode 100644
index 000000000..2d1a4302f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.project b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.project
new file mode 100644
index 000000000..e66409b35
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.filetransfer.httpclient</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.jdt.core.prefs b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..44217f8c0
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.pde.core.prefs b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..b7e72d019
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..8a6ab8d08
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Httpclient Provider Tests
+Bundle-SymbolicName: org.eclipse.ecf.tests.filetransfer.httpclient
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.junit;bundle-version="4.10.0",
+ org.eclipse.ecf.provider.filetransfer.httpclient;bundle-version="4.0.200",
+ org.apache.commons.httpclient;bundle-version="3.1.0",
+ org.eclipse.ecf.filetransfer;bundle-version="5.0.0",
+ org.eclipse.ecf.provider.filetransfer;bundle-version="3.2.0",
+ org.eclipse.ecf;bundle-version="3.1.300",
+ org.eclipse.equinox.common;bundle-version="3.6.100"
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/build.properties b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/build.properties
new file mode 100644
index 000000000..41eb6ade2
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/src/org/eclipse/ecf/tests/filetransfer/httpclient/HttpClientGetPortFromURLTest.java b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/src/org/eclipse/ecf/tests/filetransfer/httpclient/HttpClientGetPortFromURLTest.java
new file mode 100644
index 000000000..ae2edf5c3
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient/src/org/eclipse/ecf/tests/filetransfer/httpclient/HttpClientGetPortFromURLTest.java
@@ -0,0 +1,77 @@
+package org.eclipse.ecf.tests.filetransfer.httpclient;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientRetrieveFileTransfer;
+
+import junit.framework.TestCase;
+
+public class HttpClientGetPortFromURLTest extends TestCase {
+
+ public static class HttpClientRetrieveTest extends HttpClientRetrieveFileTransfer {
+
+ public HttpClientRetrieveTest(HttpClient client) {
+ super(client);
+ }
+
+ public static int getPortFromURLTest(String url) {
+ return getPortFromURL(url);
+ }
+ }
+
+ public void testHttp() {
+ int port;
+ String url = "http://www.test.com";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(80, port);
+ }
+
+ public void testHttpWithPort() {
+ int port;
+ String url = "http://www.test.com:80/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(80, port);
+ }
+
+ public void testHttps() {
+ int port;
+ String url = "https://www.test.com/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpsPortNOK() {
+ int port;
+ String url = "https://www.test.com:440/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertFalse(443 == port);
+ }
+
+ public void testHttpWithSearchpart() {
+ int port;
+ String url = "https://www.test.com/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpWithCredentialsAndSearchpart() {
+ int port;
+ String url = "https://testuser:testpasswd@www.test.com/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpWithCredentialsPortSearchpart() {
+ int port;
+ String url = "http://testuser:testpasswd@www.test.com:8080/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(8080, port);
+ }
+
+ public void testHttpWithCredentialsPortLongPath() {
+ int port;
+ String url = "https://testuser:testpasswd@host.domain.eu:443/pu/fisgui/svn/repository/fisgui/source-internal/trunk/target-platform/fisgui-5.8.1/content.xml";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.classpath b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.classpath
new file mode 100644
index 000000000..2d1a4302f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.project b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.project
new file mode 100644
index 000000000..ea8cbecfd
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.filetransfer.httpclient4</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.jdt.core.prefs b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..44217f8c0
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.pde.core.prefs b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..b7e72d019
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..7766a350b
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Httpclient4 Provider Tests
+Bundle-SymbolicName: org.eclipse.ecf.tests.filetransfer.httpclient4
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.equinox.common;bundle-version="3.6.100",
+ org.eclipse.ecf;bundle-version="3.1.300",
+ org.eclipse.ecf.filetransfer;bundle-version="5.0.0",
+ org.eclipse.ecf.provider.filetransfer;bundle-version="3.2.0",
+ org.junit;bundle-version="4.10.0",
+ org.eclipse.ecf.provider.filetransfer.httpclient4;bundle-version="1.0.100",
+ org.apache.httpcomponents.httpclient;bundle-version="4.1.2"
+Import-Package: org.apache.commons.httpclient
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/build.properties b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/build.properties
new file mode 100644
index 000000000..41eb6ade2
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/src/org/eclipse/ecf/tests/filetransfer/httpclient4/HttpClientGetPortFromURLTest.java b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/src/org/eclipse/ecf/tests/filetransfer/httpclient4/HttpClientGetPortFromURLTest.java
new file mode 100644
index 000000000..03c597c29
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.filetransfer.httpclient4/src/org/eclipse/ecf/tests/filetransfer/httpclient4/HttpClientGetPortFromURLTest.java
@@ -0,0 +1,77 @@
+package org.eclipse.ecf.tests.filetransfer.httpclient4;
+
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.eclipse.ecf.provider.filetransfer.httpclient4.HttpClientRetrieveFileTransfer;
+
+import junit.framework.TestCase;
+
+public class HttpClientGetPortFromURLTest extends TestCase {
+
+ public static class HttpClientRetrieveTest extends HttpClientRetrieveFileTransfer {
+
+ public HttpClientRetrieveTest(DefaultHttpClient httpClient) {
+ super(httpClient);
+ }
+
+ public static int getPortFromURLTest(String url) {
+ return getPortFromURL(url);
+ }
+ }
+
+ public void testHttp() {
+ int port;
+ String url = "http://www.test.com";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(80, port);
+ }
+
+ public void testHttpWithPort() {
+ int port;
+ String url = "http://www.test.com:80/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(80, port);
+ }
+
+ public void testHttps() {
+ int port;
+ String url = "https://www.test.com/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpsPortNOK() {
+ int port;
+ String url = "https://www.test.com:440/";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertFalse(443 == port);
+ }
+
+ public void testHttpWithSearchpart() {
+ int port;
+ String url = "https://www.test.com/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpWithCredentialsAndSearchpart() {
+ int port;
+ String url = "https://testuser:testpasswd@www.test.com/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+ public void testHttpWithCredentialsPortSearchpart() {
+ int port;
+ String url = "http://testuser:testpasswd@www.test.com:8080/test?value=yes";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(8080, port);
+ }
+
+ public void testHttpWithCredentialsPortLongPath() {
+ int port;
+ String url = "https://testuser:testpasswd@host.domain.eu:443/pu/fisgui/svn/repository/fisgui/source-internal/trunk/target-platform/fisgui-5.8.1/content.xml";
+ port = HttpClientRetrieveTest.getPortFromURLTest(url);
+ assertEquals(443, port);
+ }
+
+}

Back to the top