Browse Source

Apache HTTP: run more tests

Factor out the test parameterization to use both connection factories
into a common super class and use it in more tests.

This made HttpClientTests.testV2HttpSubsequentResponse() fail for
Apache HTTP. The test used the pattern

  - create POST connection
  - setDoOutput(true)
  - connect()
  - write output stream
  - get & read input stream

This pattern is never used in JGit, which actually calls connect() only
in one case in LFS, and that's on a HEAD request.

The above pattern works on JDK, but fails on Apache HTTP because with
Apache HTTP a connect() actually executes the full request including
writing the entity. To work with Apache HTTP, the pattern would need
to be

  - create POST connection
  - setDoOutput(true)
  - write output stream
  - connect()
  - get & read input stream

which is fine for both. JDK connects implicitly in getOutputStream()
and treats the later explicit connect() as a no-op, and Apache works
because the entity is written when connect() is called.

Because JDK connects implicitly on getOutputStream(), the following
pattern also works with JDK:

  - create POST connection
  - setDoOutput(true)
  - write output stream
  - get & read input stream

Support this with Apache HTTP too: let getInputStream() execute
the request if it wasn't executed already.

Remove explicit connect() calls from test code, since JGit doesn't do
those either.

Change-Id: Ica038c00a7b8edcc01d5660d18e961146305b87f
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
stable-5.5
Thomas Wolf 5 years ago
parent
commit
308bdb5d1b
  1. 1
      org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java
  2. 9
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
  3. 91
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java
  4. 21
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
  5. 21
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
  6. 9
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
  7. 26
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
  8. 9
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/MeasurePackSizeTest.java
  9. 7
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
  10. 19
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
  11. 21
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java

1
org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java

@ -345,6 +345,7 @@ public class HttpClientConnection implements HttpConnection {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
execute();
return resp.getEntity().getContent(); return resp.getEntity().getContent();
} }

9
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.GitServlet;
import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory; import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId; 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.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish; 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.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class AdvertiseErrorTest extends HttpTestCase { public class AdvertiseErrorTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository; private Repository remoteRepository;
private URIish remoteURI; private URIish remoteURI;
public AdvertiseErrorTest(HttpConnectionFactory cf) {
super(cf);
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

91
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllFactoriesHttpTestCase.java

@ -0,0 +1,91 @@
/*
* 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.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}.
*/
@RunWith(Parameterized.class)
public abstract class AllFactoriesHttpTestCase extends HttpTestCase {
@Parameters
public static Collection<Object[]> data() {
// run all tests with both connection factories we have
return Arrays
.asList(new Object[][] { { new JDKHttpConnectionFactory() },
{ new HttpClientConnectionFactory() } });
}
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);
}
}

21
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.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -66,7 +64,6 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; 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.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Ref; 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.TransportHttp;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.http.HttpConnectionFactory; 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.Before;
import org.junit.Test; 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 AllFactoriesHttpTestCase {
public class DumbClientDumbServerTest extends HttpTestCase {
private Repository remoteRepository; private Repository remoteRepository;
private URIish remoteURI; private URIish remoteURI;
@ -97,16 +88,8 @@ public class DumbClientDumbServerTest extends HttpTestCase {
private RevCommit A, B; 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) { public DumbClientDumbServerTest(HttpConnectionFactory cf) {
HttpTransport.setConnectionFactory(cf); super(cf);
} }
@Override @Override

21
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 static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; 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.http.server.GitServlet;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; 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.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Ref; 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.TransportHttp;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.http.HttpConnectionFactory; 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.Before;
import org.junit.Test; 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 AllFactoriesHttpTestCase {
public class DumbClientSmartServerTest extends HttpTestCase {
private Repository remoteRepository; private Repository remoteRepository;
private URIish remoteURI; private URIish remoteURI;
@ -97,16 +88,8 @@ public class DumbClientSmartServerTest extends HttpTestCase {
private RevCommit A, B; 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) { public DumbClientSmartServerTest(HttpConnectionFactory cf) {
HttpTransport.setConnectionFactory(cf); super(cf);
} }
@Override @Override

9
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.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; 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.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId; 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.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish; 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.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class HookMessageTest extends HttpTestCase { public class HookMessageTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository; private Repository remoteRepository;
private URIish remoteURI; private URIish remoteURI;
public HookMessageTest(HttpConnectionFactory cf) {
super(cf);
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

26
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.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer; 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.Constants;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate; 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.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.FetchConnection; import org.eclipse.jgit.transport.FetchConnection;
import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.PacketLineIn; import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut; import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnection; 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.Before;
import org.junit.Test; import org.junit.Test;
public class HttpClientTests extends HttpTestCase { public class HttpClientTests extends AllFactoriesHttpTestCase {
private TestRepository<Repository> remoteRepository; private TestRepository<Repository> remoteRepository;
private URIish dumbAuthNoneURI; private URIish dumbAuthNoneURI;
@ -100,6 +101,10 @@ public class HttpClientTests extends HttpTestCase {
private URIish smartAuthBasicURI; private URIish smartAuthBasicURI;
public HttpClientTests(HttpConnectionFactory cf) {
super(cf);
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
@ -353,12 +358,11 @@ public class HttpClientTests extends HttpTestCase {
@Test @Test
public void testHttpClientWantsV2ButServerNotConfigured() throws Exception { public void testHttpClientWantsV2ButServerNotConfigured() throws Exception {
JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack"; 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.setRequestMethod("GET");
c.setRequestProperty("Git-Protocol", "version=2"); c.setRequestProperty("Git-Protocol", "version=2");
c.connect();
assertEquals(200, c.getResponseCode()); assertEquals(200, c.getResponseCode());
PacketLineIn pckIn = new PacketLineIn(c.getInputStream()); PacketLineIn pckIn = new PacketLineIn(c.getInputStream());
@ -374,12 +378,11 @@ public class HttpClientTests extends HttpTestCase {
remoteRepository.getRepository().getConfig().setInt( remoteRepository.getRepository().getConfig().setInt(
"protocol", null, "version", 2); "protocol", null, "version", 2);
JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack"; 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.setRequestMethod("GET");
c.setRequestProperty("Git-Protocol", "version=2"); c.setRequestProperty("Git-Protocol", "version=2");
c.connect();
assertEquals(200, c.getResponseCode()); assertEquals(200, c.getResponseCode());
PacketLineIn pckIn = new PacketLineIn(c.getInputStream()); PacketLineIn pckIn = new PacketLineIn(c.getInputStream());
@ -397,14 +400,13 @@ public class HttpClientTests extends HttpTestCase {
remoteRepository.getRepository().getConfig().setInt( remoteRepository.getRepository().getConfig().setInt(
"protocol", null, "version", 2); "protocol", null, "version", 2);
JDKHttpConnectionFactory f = new JDKHttpConnectionFactory();
String url = smartAuthNoneURI.toString() + "/git-upload-pack"; 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.setRequestMethod("POST");
c.setRequestProperty("Content-Type", "application/x-git-upload-pack-request"); c.setRequestProperty("Content-Type", "application/x-git-upload-pack-request");
c.setRequestProperty("Git-Protocol", "version=2"); c.setRequestProperty("Git-Protocol", "version=2");
c.setDoOutput(true); c.setDoOutput(true);
c.connect();
// Test ls-refs to verify that everything is connected // Test ls-refs to verify that everything is connected
// properly. Tests for other commands go in // properly. Tests for other commands go in

9
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.GitServlet;
import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory; import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId; 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.RemoteRefUpdate;
import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish; 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.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class MeasurePackSizeTest extends HttpTestCase { public class MeasurePackSizeTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository; private Repository remoteRepository;
private URIish remoteURI; private URIish remoteURI;
long packSize = -1; long packSize = -1;
public MeasurePackSizeTest(HttpConnectionFactory cf) {
super(cf);
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

7
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.jetty.servlet.ServletHolder;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.HttpTestCase;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevBlob; import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit; 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.Transport;
import org.eclipse.jgit.transport.TransportHttp; import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
public class SetAdditionalHeadersTest extends HttpTestCase { public class SetAdditionalHeadersTest extends AllFactoriesHttpTestCase {
private URIish remoteURI; private URIish remoteURI;
@ -76,6 +76,9 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
private RevCommit A, B; private RevCommit A, B;
public SetAdditionalHeadersTest(HttpConnectionFactory cf) {
super(cf);
}
@Override @Override
@Before @Before

19
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 static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; 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.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer; 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.ConfigConstants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.Repository; 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.revwalk.RevCommit;
import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialItem;
import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.Transport; import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnectionFactory; 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.HttpSupport;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @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 // 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 // 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; 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) { public SmartClientSmartServerSslTest(HttpConnectionFactory cf) {
HttpTransport.setConnectionFactory(cf); super(cf);
} }
@Override @Override

21
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java

@ -59,8 +59,6 @@ import java.io.PrintWriter;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
@ -93,7 +91,6 @@ import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.TestRng; import org.eclipse.jgit.junit.TestRng;
import org.eclipse.jgit.junit.http.AccessEvent; import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer; 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.ConfigConstants;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.NullProgressMonitor;
@ -122,8 +119,6 @@ import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnectionFactory; 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.HttpSupport;
import org.eclipse.jgit.util.SystemReader; import org.eclipse.jgit.util.SystemReader;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
@ -131,12 +126,8 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; 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 AllFactoriesHttpTestCase {
public class SmartClientSmartServerTest extends HttpTestCase {
private static final String HDR_TRANSFER_ENCODING = "Transfer-Encoding"; private static final String HDR_TRANSFER_ENCODING = "Transfer-Encoding";
@Rule @Rule
@ -163,16 +154,8 @@ public class SmartClientSmartServerTest extends HttpTestCase {
private RevCommit A, B, unreachableCommit; 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) { public SmartClientSmartServerTest(HttpConnectionFactory cf) {
HttpTransport.setConnectionFactory(cf); super(cf);
} }
@Override @Override

Loading…
Cancel
Save