aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.http.test')
-rw-r--r--org.eclipse.jgit.http.test/META-INF/MANIFEST.MF44
-rw-r--r--org.eclipse.jgit.http.test/plugin.properties4
-rw-r--r--org.eclipse.jgit.http.test/pom.xml2
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java9
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java101
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java21
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java21
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java9
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java26
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java9
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java7
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java19
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java62
13 files changed, 213 insertions, 121 deletions
diff --git a/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
index ef21e8bdb5..cec2a09c08 100644
--- a/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
@@ -1,10 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: %plugin_name
+Bundle-Name: %Bundle-Name
Automatic-Module-Name: org.eclipse.jgit.http.test
Bundle-SymbolicName: org.eclipse.jgit.http.test
-Bundle-Version: 5.4.4.qualifier
-Bundle-Vendor: %provider_name
+Bundle-Version: 5.5.2.qualifier
+Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.servlet;version="[2.5.0,3.2.0)",
@@ -28,25 +28,25 @@ Import-Package: javax.servlet;version="[2.5.0,3.2.0)",
org.eclipse.jetty.util.log;version="[9.4.5,10.0.0)",
org.eclipse.jetty.util.security;version="[9.4.5,10.0.0)",
org.eclipse.jetty.util.thread;version="[9.4.5,10.0.0)",
- org.eclipse.jgit.errors;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.http.server;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.http.server.glue;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.http.server.resolver;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.internal;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.internal.storage.dfs;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.internal.storage.file;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.internal.storage.reftable;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.junit;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.junit.http;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.lib;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.nls;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.revwalk;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.storage.file;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.transport;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.transport.http;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.transport.http.apache;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.transport.resolver;version="[5.4.4,5.5.0)",
- org.eclipse.jgit.util;version="[5.4.4,5.5.0)",
+ org.eclipse.jgit.errors;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.http.server;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.http.server.glue;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.http.server.resolver;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.internal;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.internal.storage.dfs;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.internal.storage.file;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.internal.storage.reftable;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.junit;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.junit.http;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.lib;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.nls;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.revwalk;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.storage.file;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.transport;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.transport.http;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.transport.http.apache;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.transport.resolver;version="[5.5.2,5.6.0)",
+ org.eclipse.jgit.util;version="[5.5.2,5.6.0)",
org.hamcrest;version="[1.1.0,2.0.0)",
org.hamcrest.core;version="[1.1.0,2.0.0)",
org.junit;version="[4.12,5.0.0)",
diff --git a/org.eclipse.jgit.http.test/plugin.properties b/org.eclipse.jgit.http.test/plugin.properties
index 0a620aa302..d574f0d791 100644
--- a/org.eclipse.jgit.http.test/plugin.properties
+++ b/org.eclipse.jgit.http.test/plugin.properties
@@ -1,2 +1,2 @@
-plugin_name=JGit HTTP Tests
-provider_name=Eclipse JGit
+Bundle-Name=JGit HTTP Tests
+Bundle-Vendor=Eclipse JGit
diff --git a/org.eclipse.jgit.http.test/pom.xml b/org.eclipse.jgit.http.test/pom.xml
index 29e54cd625..5ab6a7e143 100644
--- a/org.eclipse.jgit.http.test/pom.xml
+++ b/org.eclipse.jgit.http.test/pom.xml
@@ -51,7 +51,7 @@
<parent>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit-parent</artifactId>
- <version>5.4.4-SNAPSHOT</version>
+ <version>5.5.2-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jgit.http.test</artifactId>
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
index ec9ced0f70..3f2b0e7f03 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
@@ -57,7 +57,6 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
@@ -69,16 +68,22 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
import org.junit.Test;
-public class AdvertiseErrorTest extends HttpTestCase {
+public class AdvertiseErrorTest extends AllFactoriesHttpTestCase {
+
private Repository remoteRepository;
private URIish remoteURI;
+ public AdvertiseErrorTest(HttpConnectionFactory cf) {
+ super(cf);
+ }
+
@Override
@Before
public void setUp() throws Exception {
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java
new file mode 100644
index 0000000000..d292d79c48
--- /dev/null
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2019, Thomas Wolf <thomas.wolf@paranor.ch>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.eclipse.jgit.http.test;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.jgit.junit.http.HttpTestCase;
+import org.eclipse.jgit.transport.HttpTransport;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
+import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
+import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Abstract test base class for running HTTP-related tests with all connection
+ * factories provided in JGit: the JDK {@link JDKHttpConnectionFactory} and the
+ * Apache HTTP {@link HttpClientConnectionFactory}.
+ */
+@Ignore
+@RunWith(Parameterized.class)
+public abstract class AllFactoriesHttpTestCase extends HttpTestCase {
+
+ @Parameters(name = "{0}")
+ public static Collection<Object[]> data() {
+ // run all tests with both connection factories we have
+ return Arrays.asList(new Object[][] { { new JDKHttpConnectionFactory() {
+ @Override
+ public String toString() {
+ return this.getClass().getSuperclass().getName();
+ }
+ } }, { new HttpClientConnectionFactory() {
+ @Override
+ public String toString() {
+ return this.getClass().getSuperclass().getName();
+ }
+ } } });
+ }
+
+ protected AllFactoriesHttpTestCase(HttpConnectionFactory cf) {
+ HttpTransport.setConnectionFactory(cf);
+ }
+
+ private static HttpConnectionFactory originalFactory;
+
+ @BeforeClass
+ public static void saveConnectionFactory() {
+ originalFactory = HttpTransport.getConnectionFactory();
+ }
+
+ @AfterClass
+ public static void restoreConnectionFactory() {
+ HttpTransport.setConnectionFactory(originalFactory);
+ }
+
+}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
index c1e55cb6f5..e8f84ae9c9 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
@@ -55,8 +55,6 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -66,7 +64,6 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Ref;
@@ -79,16 +76,10 @@ import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-@RunWith(Parameterized.class)
-public class DumbClientDumbServerTest extends HttpTestCase {
+public class DumbClientDumbServerTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository;
private URIish remoteURI;
@@ -97,16 +88,8 @@ public class DumbClientDumbServerTest extends HttpTestCase {
private RevCommit A, B;
- @Parameters
- public static Collection<Object[]> data() {
- // run all tests with both connection factories we have
- return Arrays.asList(new Object[][] {
- { new JDKHttpConnectionFactory() },
- { new HttpClientConnectionFactory() } });
- }
-
public DumbClientDumbServerTest(HttpConnectionFactory cf) {
- HttpTransport.setConnectionFactory(cf);
+ super(cf);
}
@Override
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
index 2d22bafd86..5efc5a2aee 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
@@ -55,8 +55,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -66,7 +64,6 @@ import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Ref;
@@ -79,16 +76,10 @@ import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-@RunWith(Parameterized.class)
-public class DumbClientSmartServerTest extends HttpTestCase {
+public class DumbClientSmartServerTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository;
private URIish remoteURI;
@@ -97,16 +88,8 @@ public class DumbClientSmartServerTest extends HttpTestCase {
private RevCommit A, B;
- @Parameters
- public static Collection<Object[]> data() {
- // run all tests with both connection factories we have
- return Arrays.asList(new Object[][] {
- { new JDKHttpConnectionFactory() },
- { new HttpClientConnectionFactory() } });
- }
-
public DumbClientSmartServerTest(HttpConnectionFactory cf) {
- HttpTransport.setConnectionFactory(cf);
+ super(cf);
}
@Override
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
index 49ff51a5b1..5559c8cdfa 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
@@ -62,7 +62,6 @@ import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
@@ -76,16 +75,22 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
import org.junit.Test;
-public class HookMessageTest extends HttpTestCase {
+public class HookMessageTest extends AllFactoriesHttpTestCase {
+
private Repository remoteRepository;
private URIish remoteURI;
+ public HookMessageTest(HttpConnectionFactory cf) {
+ super(cf);
+ }
+
@Override
@Before
public void setUp() throws Exception {
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
index 8ec2f51cff..7588a95092 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
@@ -71,7 +71,6 @@ import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
@@ -79,17 +78,19 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.FetchConnection;
+import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnection;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-public class HttpClientTests extends HttpTestCase {
+public class HttpClientTests extends AllFactoriesHttpTestCase {
+
private TestRepository<Repository> remoteRepository;
private URIish dumbAuthNoneURI;
@@ -100,6 +101,10 @@ public class HttpClientTests extends HttpTestCase {
private URIish smartAuthBasicURI;
+ public HttpClientTests(HttpConnectionFactory cf) {
+ super(cf);
+ }
+
@Override
@Before
public void setUp() throws Exception {
@@ -353,12 +358,11 @@ public class HttpClientTests extends HttpTestCase {
@Test
public void testHttpClientWantsV2ButServerNotConfigured() throws Exception {
- JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
- HttpConnection c = f.create(new URL(url));
+ HttpConnection c = HttpTransport.getConnectionFactory()
+ .create(new URL(url));
c.setRequestMethod("GET");
c.setRequestProperty("Git-Protocol", "version=2");
- c.connect();
assertEquals(200, c.getResponseCode());
PacketLineIn pckIn = new PacketLineIn(c.getInputStream());
@@ -374,12 +378,11 @@ public class HttpClientTests extends HttpTestCase {
remoteRepository.getRepository().getConfig().setInt(
"protocol", null, "version", 2);
- JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
- HttpConnection c = f.create(new URL(url));
+ HttpConnection c = HttpTransport.getConnectionFactory()
+ .create(new URL(url));
c.setRequestMethod("GET");
c.setRequestProperty("Git-Protocol", "version=2");
- c.connect();
assertEquals(200, c.getResponseCode());
PacketLineIn pckIn = new PacketLineIn(c.getInputStream());
@@ -397,14 +400,13 @@ public class HttpClientTests extends HttpTestCase {
remoteRepository.getRepository().getConfig().setInt(
"protocol", null, "version", 2);
- JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/git-upload-pack";
- HttpConnection c = f.create(new URL(url));
+ HttpConnection c = HttpTransport.getConnectionFactory()
+ .create(new URL(url));
c.setRequestMethod("POST");
c.setRequestProperty("Content-Type", "application/x-git-upload-pack-request");
c.setRequestProperty("Git-Protocol", "version=2");
c.setDoOutput(true);
- c.connect();
// Test ls-refs to verify that everything is connected
// properly. Tests for other commands go in
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
index 79df5a2ab2..dd49e565b9 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
@@ -55,7 +55,6 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
@@ -69,18 +68,24 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before;
import org.junit.Test;
-public class MeasurePackSizeTest extends HttpTestCase {
+public class MeasurePackSizeTest extends AllFactoriesHttpTestCase {
+
private Repository remoteRepository;
private URIish remoteURI;
long packSize = -1;
+ public MeasurePackSizeTest(HttpConnectionFactory cf) {
+ super(cf);
+ }
+
@Override
@Before
public void setUp() throws Exception {
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
index fbc54f3872..f24768b6ca 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
@@ -57,7 +57,6 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -65,10 +64,11 @@ import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-public class SetAdditionalHeadersTest extends HttpTestCase {
+public class SetAdditionalHeadersTest extends AllFactoriesHttpTestCase {
private URIish remoteURI;
@@ -76,6 +76,9 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
private RevCommit A, B;
+ public SetAdditionalHeadersTest(HttpConnectionFactory cf) {
+ super(cf);
+ }
@Override
@Before
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
index 30501dfd5c..d6e9dbe921 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
@@ -49,8 +49,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
@@ -73,7 +71,6 @@ import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Repository;
@@ -81,22 +78,18 @@ import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider;
-import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
import org.eclipse.jgit.util.HttpSupport;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
-public class SmartClientSmartServerSslTest extends HttpTestCase {
+public class SmartClientSmartServerSslTest extends AllFactoriesHttpTestCase {
// We run these tests with a server on localhost with a self-signed
// certificate. We don't do authentication tests here, so there's no need
@@ -152,16 +145,8 @@ public class SmartClientSmartServerSslTest extends HttpTestCase {
private RevCommit A, B;
- @Parameters
- public static Collection<Object[]> data() {
- // run all tests with both connection factories we have
- return Arrays.asList(new Object[][] {
- { new JDKHttpConnectionFactory() },
- { new HttpClientConnectionFactory() } });
- }
-
public SmartClientSmartServerSslTest(HttpConnectionFactory cf) {
- HttpTransport.setConnectionFactory(cf);
+ super(cf);
}
@Override
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index 8b85bef305..3401e264c0 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -56,10 +56,9 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.PrintWriter;
+import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
@@ -92,7 +91,6 @@ import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.TestRng;
import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer;
-import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
@@ -121,8 +119,6 @@ import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
import org.eclipse.jgit.util.HttpSupport;
import org.eclipse.jgit.util.SystemReader;
import org.hamcrest.Matchers;
@@ -130,12 +126,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-@RunWith(Parameterized.class)
-public class SmartClientSmartServerTest extends HttpTestCase {
+public class SmartClientSmartServerTest extends AllFactoriesHttpTestCase {
private static final String HDR_TRANSFER_ENCODING = "Transfer-Encoding";
@Rule
@@ -162,16 +154,8 @@ public class SmartClientSmartServerTest extends HttpTestCase {
private RevCommit A, B, unreachableCommit;
- @Parameters
- public static Collection<Object[]> data() {
- // run all tests with both connection factories we have
- return Arrays.asList(new Object[][] {
- { new JDKHttpConnectionFactory() },
- { new HttpClientConnectionFactory() } });
- }
-
public SmartClientSmartServerTest(HttpConnectionFactory cf) {
- HttpTransport.setConnectionFactory(cf);
+ super(cf);
}
@Override
@@ -338,6 +322,23 @@ public class SmartClientSmartServerTest extends HttpTestCase {
// empty
}
+ private String local(String url, boolean toLocal) {
+ if (!toLocal) {
+ return url;
+ }
+ try {
+ URI u = new URI(url);
+ String fragment = u.getRawFragment();
+ if (fragment != null) {
+ return u.getRawPath() + '#' + fragment;
+ } else {
+ return u.getRawPath();
+ }
+ } catch (URISyntaxException e) {
+ return url;
+ }
+ }
+
@Override
public void doFilter(ServletRequest request,
ServletResponse response, FilterChain chain)
@@ -350,6 +351,11 @@ public class SmartClientSmartServerTest extends HttpTestCase {
.append(httpServletRequest.getQueryString());
}
String urlString = fullUrl.toString();
+ boolean localRedirect = false;
+ if (urlString.contains("/local")) {
+ urlString = urlString.replace("/local", "");
+ localRedirect = true;
+ }
if (urlString.contains("/loop/")) {
urlString = urlString.replace("/loop/", "/loop/x/");
if (urlString.contains("/loop/x/x/x/x/x/x/x/x/")) {
@@ -360,7 +366,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
httpServletResponse.setStatus(
HttpServletResponse.SC_MOVED_TEMPORARILY);
httpServletResponse.setHeader(HttpSupport.HDR_LOCATION,
- urlString);
+ local(urlString, localRedirect));
return;
}
int responseCode = HttpServletResponse.SC_MOVED_PERMANENTLY;
@@ -390,9 +396,10 @@ public class SmartClientSmartServerTest extends HttpTestCase {
targetContext = matcher.group(1);
}
urlString = urlString.replace("/redirect", targetContext);
+
}
httpServletResponse.setHeader(HttpSupport.HDR_LOCATION,
- urlString);
+ local(urlString, localRedirect));
}
@Override
@@ -559,7 +566,15 @@ public class SmartClientSmartServerTest extends HttpTestCase {
private void initialClone_Redirect(int nofRedirects, int code)
throws Exception {
+ initialClone_Redirect(nofRedirects, code, false);
+ }
+
+ private void initialClone_Redirect(int nofRedirects, int code,
+ boolean localRedirect) throws Exception {
URIish cloneFrom = redirectURI;
+ if (localRedirect) {
+ cloneFrom = extendPath(cloneFrom, "/local");
+ }
if (code != 301 || nofRedirects > 1) {
cloneFrom = extendPath(cloneFrom,
"/response/" + nofRedirects + "/" + code);
@@ -613,6 +628,11 @@ public class SmartClientSmartServerTest extends HttpTestCase {
}
@Test
+ public void testInitialClone_Redirect301Local() throws Exception {
+ initialClone_Redirect(1, 301, true);
+ }
+
+ @Test
public void testInitialClone_Redirect302Small() throws Exception {
initialClone_Redirect(1, 302);
}