aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java')
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SetAdditionalHeadersTest.java76
1 files changed, 26 insertions, 50 deletions
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 5be7834546..d569431684 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
@@ -1,44 +1,11 @@
/*
- * Copyright (C) 2014, IBM Corporation
- * and other copyright owners as documented in the project's IP log.
+ * Copyright (C) 2014, IBM Corporation and others
*
- * 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
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://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.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.http.test;
@@ -51,13 +18,13 @@ import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
-import org.eclipse.jetty.servlet.DefaultServlet;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.ee10.servlet.DefaultServlet;
+import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
+import org.eclipse.jetty.ee10.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 +32,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,7 +44,11 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
private RevCommit A, B;
+ public SetAdditionalHeadersTest(HttpConnectionFactory cf) {
+ super(cf);
+ }
+ @Override
@Before
public void setUp() throws Exception {
super.setUp();
@@ -86,7 +58,7 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
final URI base = srcGit.getParentFile().toURI();
ServletContextHandler app = server.addContext("/git");
- app.setResourceBase(base.toString());
+ app.setBaseResourceAsString(base.toString());
ServletHolder holder = app.addServlet(DefaultServlet.class, "/");
// The tmp directory is symlinked on OS X
holder.setInitParameter("aliases", "true");
@@ -106,18 +78,22 @@ public class SetAdditionalHeadersTest extends HttpTestCase {
assertEquals("http", remoteURI.getScheme());
- Transport t = Transport.open(dst, remoteURI);
- try {
+ try (Transport t = Transport.open(dst, remoteURI)) {
assertTrue("isa TransportHttp", t instanceof TransportHttp);
assertTrue("isa HttpTransport", t instanceof HttpTransport);
- HashMap<String, String> headers = new HashMap<String, String>();
+ HashMap<String, String> headers = new HashMap<>();
headers.put("Cookie", "someTokenValue=23gBog34");
headers.put("AnotherKey", "someValue");
- ((TransportHttp) t).setAdditionalHeaders(headers);
+
+ @SuppressWarnings("resource")
+ TransportHttp th = (TransportHttp) t;
+ th.setAdditionalHeaders(headers);
t.openFetch();
- } finally {
- t.close();
+
+ Map<String, String> h = th.getAdditionalHeaders();
+ assertEquals("someTokenValue=23gBog34", h.get("Cookie"));
+ assertEquals("someValue", h.get("AnotherKey"));
}
List<AccessEvent> requests = getRequests();