View Javadoc
1   /*
2    * Copyright (C) 2019, Thomas Wolf <thomas.wolf@paranor.ch> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.http.test;
11  
12  import java.util.Arrays;
13  import java.util.Collection;
14  
15  import org.eclipse.jgit.junit.http.HttpTestCase;
16  import org.eclipse.jgit.transport.HttpTransport;
17  import org.eclipse.jgit.transport.http.HttpConnectionFactory;
18  import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
19  import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
20  import org.junit.AfterClass;
21  import org.junit.BeforeClass;
22  import org.junit.Ignore;
23  import org.junit.runner.RunWith;
24  import org.junit.runners.Parameterized;
25  import org.junit.runners.Parameterized.Parameters;
26  
27  /**
28   * Abstract test base class for running HTTP-related tests with all connection
29   * factories provided in JGit: the JDK {@link JDKHttpConnectionFactory} and the
30   * Apache HTTP {@link HttpClientConnectionFactory}.
31   */
32  @Ignore
33  @RunWith(Parameterized.class)
34  public abstract class AllFactoriesHttpTestCase extends HttpTestCase {
35  
36  	@Parameters(name = "{0}")
37  	public static Collection<Object[]> data() {
38  		// run all tests with both connection factories we have
39  		return Arrays.asList(new Object[][] { { new JDKHttpConnectionFactory() {
40  			@Override
41  			public String toString() {
42  				return this.getClass().getSuperclass().getName();
43  			}
44  		} }, { new HttpClientConnectionFactory() {
45  			@Override
46  			public String toString() {
47  				return this.getClass().getSuperclass().getName();
48  			}
49  		} } });
50  	}
51  
52  	protected AllFactoriesHttpTestCase(HttpConnectionFactory cf) {
53  		HttpTransport.setConnectionFactory(cf);
54  	}
55  
56  	private static HttpConnectionFactory originalFactory;
57  
58  	@BeforeClass
59  	public static void saveConnectionFactory() {
60  		originalFactory = HttpTransport.getConnectionFactory();
61  	}
62  
63  	@AfterClass
64  	public static void restoreConnectionFactory() {
65  		HttpTransport.setConnectionFactory(originalFactory);
66  	}
67  
68  }