]> source.dussan.org Git - jgit.git/commitdiff
Introduce http test bundle 76/2076/3
authorJens Baumgart <jens.baumgart@sap.com>
Wed, 8 Dec 2010 15:20:28 +0000 (16:20 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 8 Dec 2010 15:20:28 +0000 (16:20 +0100)
Introduce a http test bundle to make this functionality available for
EGit tests. A simple http server class is provided. The jetty version
was updated to a version that is also available via p2 (needed in EGit
UI tests).

Change-Id: I13bfc4c6c47e27d8f97d3e9752347d6d23e553d4
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
38 files changed:
org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
org.eclipse.jgit.http.test/pom.xml
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AdvertiseErrorTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ErrorServletTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletInitTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AccessEvent.java [deleted file]
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AppServer.java [deleted file]
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/HttpTestCase.java [deleted file]
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/MockServletConfig.java [deleted file]
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/RecordingLogger.java [deleted file]
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/TestRequestLog.java [deleted file]
org.eclipse.jgit.junit.http/.classpath [new file with mode: 0644]
org.eclipse.jgit.junit.http/.gitignore [new file with mode: 0644]
org.eclipse.jgit.junit.http/.project [new file with mode: 0644]
org.eclipse.jgit.junit.http/.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
org.eclipse.jgit.junit.http/.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.ui.prefs [new file with mode: 0644]
org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.jgit.junit.http/build.properties [new file with mode: 0644]
org.eclipse.jgit.junit.http/plugin.properties [new file with mode: 0644]
org.eclipse.jgit.junit.http/pom.xml [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AccessEvent.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/MockServletConfig.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java [new file with mode: 0644]
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/TestRequestLog.java [new file with mode: 0644]
org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml
org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/pom.xml
pom.xml

index 3d219949106e720788a7ec48667805be1d617851..167ee1aa0e038f5519a08b314fea30d0fd0259ed 100644 (file)
@@ -33,4 +33,5 @@ Import-Package: javax.servlet;version="[2.5.0,3.0.0)",
  org.eclipse.jgit.revwalk;version="[0.10.0,0.11.0)",
  org.eclipse.jgit.storage.file;version="[0.10.0,0.11.0)",
  org.eclipse.jgit.transport;version="[0.10.0,0.11.0)",
- org.eclipse.jgit.util;version="[0.10.0,0.11.0)"
+ org.eclipse.jgit.util;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.junit.http;version="[0.10.0,0.11.0)"
index 501eb5766ce9810dea38f17b2f85015030648582..49e4b07407109eecec7ab6e5bf9e4f1a640e075e 100644 (file)
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit.junit.http</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
       <artifactId>org.eclipse.jgit.junit</artifactId>
index db4aa802e22fb75dcec133ee3ac808a842094ec8..ddb32c94e59280ef0dd5e0d72dd7e3bfb1bb9deb 100644 (file)
@@ -56,8 +56,8 @@ import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
 import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotAuthorizedException;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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;
index 1ec324428496408ae09a57f5d32cd58e436cf360..e6f763c918e8569deae017cab58a13afddf9de7c 100644 (file)
@@ -56,9 +56,9 @@ import java.util.Map;
 import org.eclipse.jetty.servlet.DefaultServlet;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jgit.errors.NotSupportedException;
-import org.eclipse.jgit.http.test.util.AccessEvent;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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;
index 0b28712f69e4126f0f723007bfe0a5b45a0b6a92..92a11890438d02fb701aacc484c76d602d03c91d 100644 (file)
@@ -61,9 +61,9 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
 import org.eclipse.jgit.http.server.GitServlet;
 import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.http.test.util.AccessEvent;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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;
index 18c1bb8f6d659294367275887226fb1e0acb03a2..f92052d1c73dea5f565fdd900ae2587ae97e677a 100644 (file)
@@ -51,7 +51,7 @@ import junit.framework.TestCase;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jgit.http.server.glue.ErrorServlet;
-import org.eclipse.jgit.http.test.util.AppServer;
+import org.eclipse.jgit.junit.http.AppServer;
 
 public class ErrorServletTest extends TestCase {
        private AppServer server;
index 8407036782bb50e5999561eb821d278d97ce2f54..d6c1c46e53b92ca6bd761eb176fbc655fb7448fa 100644 (file)
@@ -52,9 +52,9 @@ import junit.framework.TestCase;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jgit.http.server.GitServlet;
-import org.eclipse.jgit.http.test.util.AppServer;
-import org.eclipse.jgit.http.test.util.MockServletConfig;
-import org.eclipse.jgit.http.test.util.RecordingLogger;
+import org.eclipse.jgit.junit.http.AppServer;
+import org.eclipse.jgit.junit.http.MockServletConfig;
+import org.eclipse.jgit.junit.http.RecordingLogger;
 
 public class GitServletInitTest extends TestCase {
        private AppServer server;
index 18f8dc928bf46d4cd397bf72f500c165730e5c6c..b75735dea86da566136901c1381101f39611a533 100644 (file)
@@ -57,9 +57,9 @@ import org.eclipse.jgit.http.server.resolver.DefaultReceivePackFactory;
 import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotAuthorizedException;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.http.test.util.AccessEvent;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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;
index 92584cbe101973ee942179cb6e4761d158e61975..c4912d40551c2c588567a03847a2d95d48d1870a 100644 (file)
@@ -59,10 +59,10 @@ import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.http.server.GitServlet;
 import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.http.test.util.AccessEvent;
-import org.eclipse.jgit.http.test.util.AppServer;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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;
index 6f06f1f9a73dd4aba19985445d4058a2c9928c42..491094ca6ddc6858b69635c9255db6163311c1bd 100644 (file)
@@ -72,10 +72,10 @@ import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.http.server.GitServlet;
 import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
 import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
-import org.eclipse.jgit.http.test.util.AccessEvent;
-import org.eclipse.jgit.http.test.util.HttpTestCase;
 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.HttpTestCase;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.NullProgressMonitor;
 import org.eclipse.jgit.lib.ObjectId;
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AccessEvent.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AccessEvent.java
deleted file mode 100644 (file)
index c6d531e..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc.
- * 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.util;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.Response;
-
-/** A single request made through {@link AppServer}. */
-public class AccessEvent {
-       private final String method;
-
-       private final String uri;
-
-       private final Map<String, String> requestHeaders;
-
-       private final Map<String, String[]> parameters;
-
-       private final int status;
-
-       private final Map<String, String> responseHeaders;
-
-       AccessEvent(final Request req, final Response rsp) {
-               method = req.getMethod();
-               uri = req.getRequestURI();
-               requestHeaders = cloneHeaders(req);
-               parameters = clone(req.getParameterMap());
-
-               status = rsp.getStatus();
-               responseHeaders = cloneHeaders(rsp);
-       }
-
-       private static Map<String, String> cloneHeaders(final Request req) {
-               Map<String, String> r = new TreeMap<String, String>();
-               Enumeration hn = req.getHeaderNames();
-               while (hn.hasMoreElements()) {
-                       String key = (String) hn.nextElement();
-                       if (!r.containsKey(key)) {
-                               r.put(key, req.getHeader(key));
-                       }
-               }
-               return Collections.unmodifiableMap(r);
-       }
-
-       private static Map<String, String> cloneHeaders(final Response rsp) {
-               Map<String, String> r = new TreeMap<String, String>();
-               Enumeration<String> hn = rsp.getHttpFields().getFieldNames();
-               while (hn.hasMoreElements()) {
-                       String key = hn.nextElement();
-                       if (!r.containsKey(key)) {
-                               Enumeration<String> v = rsp.getHttpFields().getValues(key);
-                               r.put(key, v.nextElement());
-                       }
-               }
-               return Collections.unmodifiableMap(r);
-       }
-
-       @SuppressWarnings("unchecked")
-       private static Map<String, String[]> clone(Map parameterMap) {
-               return new TreeMap<String, String[]>(parameterMap);
-       }
-
-       /** @return {@code "GET"} or {@code "POST"} */
-       public String getMethod() {
-               return method;
-       }
-
-       /** @return path of the file on the server, e.g. {@code /git/HEAD}. */
-       public String getPath() {
-               return uri;
-       }
-
-       /**
-        * @param name
-        *            name of the request header to read.
-        * @return first value of the request header; null if not sent.
-        */
-       public String getRequestHeader(String name) {
-               return requestHeaders.get(name);
-       }
-
-       /**
-        * @param name
-        *            name of the request parameter to read.
-        * @return first value of the request parameter; null if not sent.
-        */
-       public String getParameter(String name) {
-               String[] r = parameters.get(name);
-               return r != null && 1 <= r.length ? r[0] : null;
-       }
-
-       /** @return all parameters in the request. */
-       public Map<String, String[]> getParameters() {
-               return parameters;
-       }
-
-       /** @return HTTP status code of the response, e.g. 200, 403, 500. */
-       public int getStatus() {
-               return status;
-       }
-
-       /**
-        * @param name
-        *            name of the response header to read.
-        * @return first value of the response header; null if not sent.
-        */
-       public String getResponseHeader(String name) {
-               return responseHeaders.get(name);
-       }
-
-       public String toString() {
-               StringBuilder b = new StringBuilder();
-               b.append(method);
-               b.append(' ');
-               b.append(uri);
-               if (!parameters.isEmpty()) {
-                       b.append('?');
-                       boolean first = true;
-                       for (Map.Entry<String, String[]> e : parameters.entrySet()) {
-                               for (String val : e.getValue()) {
-                                       if (!first) {
-                                               b.append('&');
-                                       }
-                                       first = false;
-
-                                       b.append(e.getKey());
-                                       b.append('=');
-                                       b.append(val);
-                               }
-                       }
-               }
-               b.append(' ');
-               b.append(status);
-               return b.toString();
-       }
-}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AppServer.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/AppServer.java
deleted file mode 100644 (file)
index 6e357f1..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc.
- * 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.util;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.eclipse.jetty.http.security.Constraint;
-import org.eclipse.jetty.http.security.Password;
-import org.eclipse.jetty.security.Authenticator;
-import org.eclipse.jetty.security.ConstraintMapping;
-import org.eclipse.jetty.security.ConstraintSecurityHandler;
-import org.eclipse.jetty.security.MappedLoginService;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.server.handler.ContextHandlerCollection;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.util.thread.QueuedThreadPool;
-import org.eclipse.jgit.transport.URIish;
-
-/**
- * Tiny web application server for unit testing.
- * <p>
- * Tests should start the server in their {@code setUp()} method and stop the
- * server in their {@code tearDown()} method. Only while started the server's
- * URL and/or port number can be obtained.
- */
-public class AppServer {
-       /** Realm name for the secure access areas. */
-       public static final String realm = "Secure Area";
-
-       /** Username for secured access areas. */
-       public static final String username = "agitter";
-
-       /** Password for {@link #username} in secured access areas. */
-       public static final String password = "letmein";
-
-       static {
-               // Install a logger that throws warning messages.
-               //
-               final String prop = "org.eclipse.jetty.util.log.class";
-               System.setProperty(prop, RecordingLogger.class.getName());
-       }
-
-       private final Server server;
-
-       private final Connector connector;
-
-       private final ContextHandlerCollection contexts;
-
-       private final TestRequestLog log;
-
-       public AppServer() {
-               connector = new SelectChannelConnector();
-               connector.setPort(0);
-               try {
-                       final InetAddress me = InetAddress.getByName("localhost");
-                       connector.setHost(me.getHostAddress());
-               } catch (UnknownHostException e) {
-                       throw new RuntimeException("Cannot find localhost", e);
-               }
-
-               // We need a handful of threads in the thread pool, otherwise
-               // our tests will deadlock when they can't open enough requests.
-               // In theory we only need 1 concurrent connection at a time, but
-               // I suspect the JRE isn't doing request pipelining on existing
-               // connections like we want it to.
-               //
-               final QueuedThreadPool pool = new QueuedThreadPool();
-               pool.setMinThreads(1);
-               pool.setMaxThreads(4);
-               pool.setMaxQueued(8);
-
-               contexts = new ContextHandlerCollection();
-
-               log = new TestRequestLog();
-               log.setHandler(contexts);
-
-               server = new Server();
-               server.setConnectors(new Connector[] { connector });
-               server.setThreadPool(pool);
-               server.setHandler(log);
-
-               server.setStopAtShutdown(false);
-               server.setGracefulShutdown(0);
-       }
-
-       /**
-        * Create a new servlet context within the server.
-        * <p>
-        * This method should be invoked before the server is started, once for each
-        * context the caller wants to register.
-        *
-        * @param path
-        *            path of the context; use "/" for the root context if binding
-        *            to the root is desired.
-        * @return the context to add servlets into.
-        */
-       public ServletContextHandler addContext(String path) {
-               assertNotYetSetUp();
-               if ("".equals(path))
-                       path = "/";
-
-               ServletContextHandler ctx = new ServletContextHandler();
-               ctx.setContextPath(path);
-               contexts.addHandler(ctx);
-
-               return ctx;
-       }
-
-       public ServletContextHandler authBasic(ServletContextHandler ctx) {
-               assertNotYetSetUp();
-               auth(ctx, new BasicAuthenticator());
-               return ctx;
-       }
-
-       private void auth(ServletContextHandler ctx, Authenticator authType) {
-               final String role = "can-access";
-
-               MappedLoginService users = new MappedLoginService() {
-                       @Override
-                       protected UserIdentity loadUser(String who) {
-                               return null;
-                       }
-
-                       @Override
-                       protected void loadUsers() throws IOException {
-                               putUser(username, new Password(password), new String[] { role });
-                       }
-               };
-
-               ConstraintMapping cm = new ConstraintMapping();
-               cm.setConstraint(new Constraint());
-               cm.getConstraint().setAuthenticate(true);
-               cm.getConstraint().setDataConstraint(Constraint.DC_NONE);
-               cm.getConstraint().setRoles(new String[] { role });
-               cm.setPathSpec("/*");
-
-               ConstraintSecurityHandler sec = new ConstraintSecurityHandler();
-               sec.setStrict(false);
-               sec.setRealmName(realm);
-               sec.setAuthenticator(authType);
-               sec.setLoginService(users);
-               sec.setConstraintMappings(new ConstraintMapping[] { cm });
-               sec.setHandler(ctx);
-
-               contexts.removeHandler(ctx);
-               contexts.addHandler(sec);
-       }
-
-       /**
-        * Start the server on a random local port.
-        *
-        * @throws Exception
-        *             the server cannot be started, testing is not possible.
-        */
-       public void setUp() throws Exception {
-               RecordingLogger.clear();
-               log.clear();
-               server.start();
-       }
-
-       /**
-        * Shutdown the server.
-        *
-        * @throws Exception
-        *             the server refuses to halt, or wasn't running.
-        */
-       public void tearDown() throws Exception {
-               RecordingLogger.clear();
-               log.clear();
-               server.stop();
-       }
-
-       /**
-        * Get the URI to reference this server.
-        * <p>
-        * The returned URI includes the proper host name and port number, but does
-        * not contain a path.
-        *
-        * @return URI to reference this server's root context.
-        */
-       public URI getURI() {
-               assertAlreadySetUp();
-               String host = connector.getHost();
-               if (host.contains(":") && !host.startsWith("["))
-                       host = "[" + host + "]";
-               final String uri = "http://" + host + ":" + getPort();
-               try {
-                       return new URI(uri);
-               } catch (URISyntaxException e) {
-                       throw new RuntimeException("Unexpected URI error on " + uri, e);
-               }
-       }
-
-       /** @return the local port number the server is listening on. */
-       public int getPort() {
-               assertAlreadySetUp();
-               return ((SelectChannelConnector) connector).getLocalPort();
-       }
-
-       /** @return all requests since the server was started. */
-       public List<AccessEvent> getRequests() {
-               return new ArrayList<AccessEvent>(log.getEvents());
-       }
-
-       /**
-        * @param base
-        *            base URI used to access the server.
-        * @param path
-        *            the path to locate requests for, relative to {@code base}.
-        * @return all requests which match the given path.
-        */
-       public List<AccessEvent> getRequests(URIish base, String path) {
-               return getRequests(HttpTestCase.join(base, path));
-       }
-
-       /**
-        * @param path
-        *            the path to locate requests for.
-        * @return all requests which match the given path.
-        */
-       public List<AccessEvent> getRequests(String path) {
-               ArrayList<AccessEvent> r = new ArrayList<AccessEvent>();
-               for (AccessEvent event : log.getEvents()) {
-                       if (event.getPath().equals(path)) {
-                               r.add(event);
-                       }
-               }
-               return r;
-       }
-
-       private void assertNotYetSetUp() {
-               Assert.assertFalse("server is not running", server.isRunning());
-       }
-
-       private void assertAlreadySetUp() {
-               Assert.assertTrue("server is running", server.isRunning());
-       }
-}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/HttpTestCase.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/HttpTestCase.java
deleted file mode 100644 (file)
index 313b6ad..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2009-2010, Google Inc.
- * 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.util;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
-import org.eclipse.jgit.junit.TestRepository;
-import org.eclipse.jgit.lib.AnyObjectId;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.revwalk.RevObject;
-import org.eclipse.jgit.storage.file.FileRepository;
-import org.eclipse.jgit.transport.RefSpec;
-import org.eclipse.jgit.transport.RemoteRefUpdate;
-import org.eclipse.jgit.transport.URIish;
-
-/** Base class for HTTP related transport testing. */
-public abstract class HttpTestCase extends LocalDiskRepositoryTestCase {
-       protected static final String master = Constants.R_HEADS + Constants.MASTER;
-
-       /** In-memory application server; subclass must start. */
-       protected AppServer server;
-
-       protected void setUp() throws Exception {
-               super.setUp();
-               server = new AppServer();
-       }
-
-       protected void tearDown() throws Exception {
-               server.tearDown();
-               super.tearDown();
-       }
-
-       protected TestRepository<FileRepository> createTestRepository()
-                       throws IOException {
-               return new TestRepository<FileRepository>(createBareRepository());
-       }
-
-       protected URIish toURIish(String path) throws URISyntaxException {
-               URI u = server.getURI().resolve(path);
-               return new URIish(u.toString());
-       }
-
-       protected URIish toURIish(ServletContextHandler app, String name)
-                       throws URISyntaxException {
-               String p = app.getContextPath();
-               if (!p.endsWith("/") && !name.startsWith("/"))
-                       p += "/";
-               p += name;
-               return toURIish(p);
-       }
-
-       protected List<AccessEvent> getRequests() {
-               return server.getRequests();
-       }
-
-       protected List<AccessEvent> getRequests(URIish base, String path) {
-               return server.getRequests(base, path);
-       }
-
-       protected List<AccessEvent> getRequests(String path) {
-               return server.getRequests(path);
-       }
-
-       protected static void fsck(Repository db, RevObject... tips)
-                       throws Exception {
-               new TestRepository(db).fsck(tips);
-       }
-
-       protected static Set<RefSpec> mirror(String... refs) {
-               HashSet<RefSpec> r = new HashSet<RefSpec>();
-               for (String name : refs) {
-                       RefSpec rs = new RefSpec(name);
-                       rs = rs.setDestination(name);
-                       rs = rs.setForceUpdate(true);
-                       r.add(rs);
-               }
-               return r;
-       }
-
-       protected static Collection<RemoteRefUpdate> push(TestRepository from,
-                       RevCommit q) throws IOException {
-               final Repository db = from.getRepository();
-               final String srcExpr = q.name();
-               final String dstName = master;
-               final boolean forceUpdate = true;
-               final String localName = null;
-               final ObjectId oldId = null;
-
-               RemoteRefUpdate u = new RemoteRefUpdate(db, srcExpr, dstName,
-                               forceUpdate, localName, oldId);
-               return Collections.singleton(u);
-       }
-
-       public static String loose(URIish base, AnyObjectId id) {
-               final String objectName = id.name();
-               final String d = objectName.substring(0, 2);
-               final String f = objectName.substring(2);
-               return join(base, "objects/" + d + "/" + f);
-       }
-
-       public static String join(URIish base, String path) {
-               if (path.startsWith("/"))
-                       fail("Cannot join absolute path " + path + " to URIish " + base);
-
-               String dir = base.getPath();
-               if (!dir.endsWith("/"))
-                       dir += "/";
-               return dir + path;
-       }
-}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/MockServletConfig.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/MockServletConfig.java
deleted file mode 100644 (file)
index cf6f6f6..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc.
- * 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.util;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-
-public class MockServletConfig implements ServletConfig {
-       private final Map<String, String> parameters = new HashMap<String, String>();
-
-       public void setInitParameter(String name, String value) {
-               parameters.put(name, value);
-       }
-
-       public String getInitParameter(String name) {
-               return parameters.get(name);
-       }
-
-       public Enumeration getInitParameterNames() {
-               final Iterator<String> i = parameters.keySet().iterator();
-               return new Enumeration<String>() {
-                       public boolean hasMoreElements() {
-                               return i.hasNext();
-                       }
-
-                       public String nextElement() {
-                               return i.next();
-                       }
-               };
-       }
-
-       public String getServletName() {
-               return "MOCK_SERVLET";
-       }
-
-       public ServletContext getServletContext() {
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/RecordingLogger.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/RecordingLogger.java
deleted file mode 100644 (file)
index dafc3c5..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc.
- * 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.util;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jetty.util.log.Logger;
-
-/** Logs warnings into an array for later inspection. */
-public class RecordingLogger implements Logger {
-       private static List<Warning> warnings = new ArrayList<Warning>();
-
-       /** Clear the warnings, automatically done by {@link AppServer#setUp()} */
-       public static void clear() {
-               synchronized (warnings) {
-                       warnings.clear();
-               }
-       }
-
-       /** @return the warnings (if any) from the last execution */
-       public static List<Warning> getWarnings() {
-               synchronized (warnings) {
-                       ArrayList<Warning> copy = new ArrayList<Warning>(warnings);
-                       return Collections.unmodifiableList(copy);
-               }
-       }
-
-       @SuppressWarnings("serial")
-       public static class Warning extends Exception {
-               public Warning(String msg) {
-                       super(msg);
-               }
-
-               public Warning(String msg, Throwable cause) {
-                       super(msg, cause);
-               }
-
-               public Warning(Throwable thrown) {
-                       super(thrown);
-               }
-       }
-
-       private final String name;
-
-       public RecordingLogger() {
-               this("");
-       }
-
-       public RecordingLogger(final String name) {
-               this.name = name;
-       }
-
-       public Logger getLogger(@SuppressWarnings("hiding") String name) {
-               return new RecordingLogger(name);
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void warn(String msg, Object arg0, Object arg1) {
-               synchronized (warnings) {
-                       warnings.add(new Warning(MessageFormat.format(msg, arg0, arg1)));
-               }
-       }
-
-       public void warn(String msg, Throwable th) {
-               synchronized (warnings) {
-                       warnings.add(new Warning(msg, th));
-               }
-       }
-
-       public void warn(String msg) {
-               synchronized (warnings) {
-                       warnings.add(new Warning(msg));
-               }
-       }
-
-       public void debug(@SuppressWarnings("unused") String msg,
-                                 @SuppressWarnings("unused") Object arg0,
-                                 @SuppressWarnings("unused") Object arg1) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void debug(String msg, Throwable th) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void debug(@SuppressWarnings("unused") String msg) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void info(@SuppressWarnings("unused") String msg,
-                                @SuppressWarnings("unused") Object arg0,
-                                @SuppressWarnings("unused") Object arg1) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void info(@SuppressWarnings("unused") String msg) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public boolean isDebugEnabled() {
-               return false;
-       }
-
-       public void setDebugEnabled(boolean enabled) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void warn(String msg, Object... args) {
-               synchronized (warnings) {
-                       warnings.add(new Warning(MessageFormat.format(msg, args)));
-               }
-       }
-
-       public void warn(Throwable thrown) {
-               synchronized (warnings) {
-                       warnings.add(new Warning(thrown));
-               }
-       }
-
-       public void info(String msg, Object... args) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void info(Throwable thrown) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void info(String msg, Throwable thrown) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void debug(String msg, Object... args) {
-               // Ignore (not relevant to test failures)
-       }
-
-       public void debug(Throwable thrown) {
-               // Ignore (not relevant to test failures)
-       }
-}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/TestRequestLog.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/util/TestRequestLog.java
deleted file mode 100644 (file)
index 6d3341b..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2010, Google Inc.
- * 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.util;
-
-import org.eclipse.jetty.server.DispatcherType;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.Response;
-import org.eclipse.jetty.server.handler.HandlerWrapper;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Semaphore;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/** Logs request made through {@link AppServer}. */
-class TestRequestLog extends HandlerWrapper {
-  private static final int MAX = 16;
-
-  private final List<AccessEvent> events = new ArrayList<AccessEvent>();
-
-  private final Semaphore active = new Semaphore(MAX);
-
-  /** Reset the log back to its original empty state. */
-  void clear() {
-    try {
-      for (;;) {
-        try {
-          active.acquire(MAX);
-          break;
-        } catch (InterruptedException e) {
-          continue;
-        }
-      }
-
-      synchronized (events) {
-        events.clear();
-      }
-    } finally {
-      active.release(MAX);
-    }
-  }
-
-  /** @return all of the events made since the last clear. */
-  List<AccessEvent> getEvents() {
-    try {
-      for (;;) {
-        try {
-          active.acquire(MAX);
-          break;
-        } catch (InterruptedException e) {
-          continue;
-        }
-      }
-
-      synchronized (events) {
-        return events;
-      }
-    } finally {
-      active.release(MAX);
-    }
-  }
-
-  @Override
-  public void handle(String target, Request baseRequest, HttpServletRequest request,
-      HttpServletResponse response) throws IOException, ServletException {
-    try {
-      for (;;) {
-        try {
-          active.acquire();
-          break;
-        } catch (InterruptedException e) {
-          continue;
-        }
-      }
-
-      super.handle(target, baseRequest, request, response);
-
-      if (DispatcherType.REQUEST.equals(baseRequest.getDispatcherType()))
-        log((Request) request, (Response) response);
-
-    } finally {
-      active.release();
-    }
-  }
-
-  private void log(Request request, Response response) {
-    synchronized (events) {
-      events.add(new AccessEvent(request, response));
-    }
-  }
-}
diff --git a/org.eclipse.jgit.junit.http/.classpath b/org.eclipse.jgit.junit.http/.classpath
new file mode 100644 (file)
index 0000000..2d1a430
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
diff --git a/org.eclipse.jgit.junit.http/.gitignore b/org.eclipse.jgit.junit.http/.gitignore
new file mode 100644 (file)
index 0000000..934e0e0
--- /dev/null
@@ -0,0 +1,2 @@
+/bin
+/target
diff --git a/org.eclipse.jgit.junit.http/.project b/org.eclipse.jgit.junit.http/.project
new file mode 100644 (file)
index 0000000..0a38e4a
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.eclipse.jgit.junit.http</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.ManifestBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.eclipse.pde.SchemaBuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.pde.PluginNature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/org.eclipse.jgit.junit.http/.settings/org.eclipse.core.resources.prefs b/org.eclipse.jgit.junit.http/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..f77db3b
--- /dev/null
@@ -0,0 +1,3 @@
+#Sat Dec 20 21:21:24 CET 2008
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/org.eclipse.jgit.junit.http/.settings/org.eclipse.core.runtime.prefs b/org.eclipse.jgit.junit.http/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..9f733ee
--- /dev/null
@@ -0,0 +1,3 @@
+#Mon Mar 24 18:55:56 EDT 2008
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..8bfa5f1
--- /dev/null
@@ -0,0 +1,320 @@
+#Tue Feb 05 00:01:29 CET 2008
+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.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=error
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=1
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
+org.eclipse.jdt.core.formatter.comment.format_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
diff --git a/org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644 (file)
index 0000000..efb1359
--- /dev/null
@@ -0,0 +1,63 @@
+#Thu Aug 26 12:30:39 CDT 2010
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_JGit Format
+formatter_settings_version=11
+internal.default.compliance=default
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=java;javax;org;com;
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=false
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..19a1722
--- /dev/null
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin_name
+Bundle-SymbolicName: org.eclipse.jgit.junit.http
+Bundle-Version: 0.10.0.qualifier
+Bundle-Localization: plugin
+Bundle-Vendor: %provider_name
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: javax.servlet;version="[2.5.0,3.0.0)",
+ javax.servlet.http;version="[2.5.0,3.0.0)",
+ junit.framework;version="[3.8.2,4.0.0)",
+ org.eclipse.jgit.errors;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.http.server;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.http.server.resolver;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.junit;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.lib;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.revwalk;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.storage.file;version="[0.10.0,0.11.0)",
+ org.eclipse.jgit.transport;version="[0.10.0,0.11.0)"
+Export-Package: org.eclipse.jgit.junit.http;version="0.10.0"
+Require-Bundle: org.eclipse.jetty.http;bundle-version="7.0.1",
+ org.eclipse.jetty.server;bundle-version="7.0.1",
+ org.eclipse.jetty.servlet;bundle-version="7.0.1",
+ org.eclipse.jetty.util;bundle-version="7.0.1",
+ org.eclipse.jetty.security;bundle-version="7.0.1"
diff --git a/org.eclipse.jgit.junit.http/build.properties b/org.eclipse.jgit.junit.http/build.properties
new file mode 100644 (file)
index 0000000..f4ae970
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+               .,\\r
+               plugin.properties\r
diff --git a/org.eclipse.jgit.junit.http/plugin.properties b/org.eclipse.jgit.junit.http/plugin.properties
new file mode 100644 (file)
index 0000000..3f22ec8
--- /dev/null
@@ -0,0 +1,2 @@
+plugin_name=JGit JUnit Http Utility Classes (Incubation)
+provider_name=Eclipse.org
diff --git a/org.eclipse.jgit.junit.http/pom.xml b/org.eclipse.jgit.junit.http/pom.xml
new file mode 100644 (file)
index 0000000..6770475
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+   Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>\r
+   and other copyright owners as documented in the project's IP log.\r
+\r
+   This program and the accompanying materials are made available\r
+   under the terms of the Eclipse Distribution License v1.0 which\r
+   accompanies this distribution, is reproduced below, and is\r
+   available at http://www.eclipse.org/org/documents/edl-v10.php\r
+\r
+   All rights reserved.\r
+\r
+   Redistribution and use in source and binary forms, with or\r
+   without modification, are permitted provided that the following\r
+   conditions are met:\r
+\r
+   - Redistributions of source code must retain the above copyright\r
+     notice, this list of conditions and the following disclaimer.\r
+\r
+   - Redistributions in binary form must reproduce the above\r
+     copyright notice, this list of conditions and the following\r
+     disclaimer in the documentation and/or other materials provided\r
+     with the distribution.\r
+\r
+   - Neither the name of the Eclipse Foundation, Inc. nor the\r
+     names of its contributors may be used to endorse or promote\r
+     products derived from this software without specific prior\r
+     written permission.\r
+\r
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r
+   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\r
+   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+-->\r
+\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+  <modelVersion>4.0.0</modelVersion>\r
+\r
+  <parent>\r
+    <groupId>org.eclipse.jgit</groupId>\r
+    <artifactId>org.eclipse.jgit-parent</artifactId>\r
+    <version>0.10.0-SNAPSHOT</version>\r
+  </parent>\r
+\r
+  <artifactId>org.eclipse.jgit.junit.http</artifactId>\r
+  <name>JGit - JUnit Http Utility Classes</name>\r
+\r
+  <description>\r
+    Utility classes to support Http based JUnit testing of JGit applications.\r
+  </description>\r
+\r
+  <properties>\r
+    <translate-qualifier/>\r
+  </properties>\r
+\r
+  <dependencies>\r
+    <dependency>\r
+      <groupId>org.eclipse.jgit</groupId>\r
+      <artifactId>org.eclipse.jgit</artifactId>\r
+      <version>${project.version}</version>\r
+    </dependency>\r
+\r
+    <dependency>\r
+      <groupId>junit</groupId>\r
+      <artifactId>junit</artifactId>\r
+      <scope>provided</scope>\r
+    </dependency>\r
+\r
+    <dependency>\r
+      <groupId>org.eclipse.jgit</groupId>\r
+      <artifactId>org.eclipse.jgit.http.server</artifactId>\r
+      <version>${project.version}</version>\r
+    </dependency>\r
+\r
+    <dependency>\r
+      <groupId>org.eclipse.jgit</groupId>\r
+      <artifactId>org.eclipse.jgit.junit</artifactId>\r
+      <version>${project.version}</version>\r
+    </dependency>\r
+\r
+    <dependency>\r
+      <groupId>org.eclipse.jetty</groupId>\r
+      <artifactId>jetty-servlet</artifactId>\r
+    </dependency>\r
+  </dependencies>\r
+\r
+  <build>\r
+    <sourceDirectory>src/</sourceDirectory>\r
+\r
+    <resources>\r
+      <resource>\r
+        <directory>.</directory>\r
+        <includes>\r
+          <include>plugin.properties</include>\r
+        </includes>\r
+      </resource>\r
+    </resources>\r
+\r
+    <plugins>\r
+      <plugin>\r
+        <artifactId>maven-jar-plugin</artifactId>\r
+        <configuration>\r
+          <archive>\r
+            <manifestFile>${bundle-manifest}</manifestFile>\r
+          </archive>\r
+        </configuration>\r
+      </plugin>\r
+    </plugins>\r
+  </build>\r
+</project>\r
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AccessEvent.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AccessEvent.java
new file mode 100644 (file)
index 0000000..aaccc66
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * 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.junit.http;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+
+/** A single request made through {@link AppServer}. */
+public class AccessEvent {
+       private final String method;
+
+       private final String uri;
+
+       private final Map<String, String> requestHeaders;
+
+       private final Map<String, String[]> parameters;
+
+       private final int status;
+
+       private final Map<String, String> responseHeaders;
+
+       AccessEvent(final Request req, final Response rsp) {
+               method = req.getMethod();
+               uri = req.getRequestURI();
+               requestHeaders = cloneHeaders(req);
+               parameters = clone(req.getParameterMap());
+
+               status = rsp.getStatus();
+               responseHeaders = cloneHeaders(rsp);
+       }
+
+       private static Map<String, String> cloneHeaders(final Request req) {
+               Map<String, String> r = new TreeMap<String, String>();
+               Enumeration hn = req.getHeaderNames();
+               while (hn.hasMoreElements()) {
+                       String key = (String) hn.nextElement();
+                       if (!r.containsKey(key)) {
+                               r.put(key, req.getHeader(key));
+                       }
+               }
+               return Collections.unmodifiableMap(r);
+       }
+
+       private static Map<String, String> cloneHeaders(final Response rsp) {
+               Map<String, String> r = new TreeMap<String, String>();
+               Enumeration<String> hn = rsp.getHttpFields().getFieldNames();
+               while (hn.hasMoreElements()) {
+                       String key = hn.nextElement();
+                       if (!r.containsKey(key)) {
+                               Enumeration<String> v = rsp.getHttpFields().getValues(key);
+                               r.put(key, v.nextElement());
+                       }
+               }
+               return Collections.unmodifiableMap(r);
+       }
+
+       @SuppressWarnings("unchecked")
+       private static Map<String, String[]> clone(Map parameterMap) {
+               return new TreeMap<String, String[]>(parameterMap);
+       }
+
+       /** @return {@code "GET"} or {@code "POST"} */
+       public String getMethod() {
+               return method;
+       }
+
+       /** @return path of the file on the server, e.g. {@code /git/HEAD}. */
+       public String getPath() {
+               return uri;
+       }
+
+       /**
+        * @param name
+        *            name of the request header to read.
+        * @return first value of the request header; null if not sent.
+        */
+       public String getRequestHeader(String name) {
+               return requestHeaders.get(name);
+       }
+
+       /**
+        * @param name
+        *            name of the request parameter to read.
+        * @return first value of the request parameter; null if not sent.
+        */
+       public String getParameter(String name) {
+               String[] r = parameters.get(name);
+               return r != null && 1 <= r.length ? r[0] : null;
+       }
+
+       /** @return all parameters in the request. */
+       public Map<String, String[]> getParameters() {
+               return parameters;
+       }
+
+       /** @return HTTP status code of the response, e.g. 200, 403, 500. */
+       public int getStatus() {
+               return status;
+       }
+
+       /**
+        * @param name
+        *            name of the response header to read.
+        * @return first value of the response header; null if not sent.
+        */
+       public String getResponseHeader(String name) {
+               return responseHeaders.get(name);
+       }
+
+       public String toString() {
+               StringBuilder b = new StringBuilder();
+               b.append(method);
+               b.append(' ');
+               b.append(uri);
+               if (!parameters.isEmpty()) {
+                       b.append('?');
+                       boolean first = true;
+                       for (Map.Entry<String, String[]> e : parameters.entrySet()) {
+                               for (String val : e.getValue()) {
+                                       if (!first) {
+                                               b.append('&');
+                                       }
+                                       first = false;
+
+                                       b.append(e.getKey());
+                                       b.append('=');
+                                       b.append(val);
+                               }
+                       }
+               }
+               b.append(' ');
+               b.append(status);
+               return b.toString();
+       }
+}
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
new file mode 100644 (file)
index 0000000..2d1c98c
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * 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.junit.http;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.jetty.http.security.Constraint;
+import org.eclipse.jetty.http.security.Password;
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.MappedLoginService;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.UserIdentity;
+import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jgit.transport.URIish;
+
+/**
+ * Tiny web application server for unit testing.
+ * <p>
+ * Tests should start the server in their {@code setUp()} method and stop the
+ * server in their {@code tearDown()} method. Only while started the server's
+ * URL and/or port number can be obtained.
+ */
+public class AppServer {
+       /** Realm name for the secure access areas. */
+       public static final String realm = "Secure Area";
+
+       /** Username for secured access areas. */
+       public static final String username = "agitter";
+
+       /** Password for {@link #username} in secured access areas. */
+       public static final String password = "letmein";
+
+       static {
+               // Install a logger that throws warning messages.
+               //
+               final String prop = "org.eclipse.jetty.util.log.class";
+               System.setProperty(prop, RecordingLogger.class.getName());
+       }
+
+       private final Server server;
+
+       private final Connector connector;
+
+       private final ContextHandlerCollection contexts;
+
+       private final TestRequestLog log;
+
+       public AppServer() {
+               connector = new SelectChannelConnector();
+               connector.setPort(0);
+               try {
+                       final InetAddress me = InetAddress.getByName("localhost");
+                       connector.setHost(me.getHostAddress());
+               } catch (UnknownHostException e) {
+                       throw new RuntimeException("Cannot find localhost", e);
+               }
+
+               // We need a handful of threads in the thread pool, otherwise
+               // our tests will deadlock when they can't open enough requests.
+               // In theory we only need 1 concurrent connection at a time, but
+               // I suspect the JRE isn't doing request pipelining on existing
+               // connections like we want it to.
+               //
+               final QueuedThreadPool pool = new QueuedThreadPool();
+               pool.setMinThreads(1);
+               pool.setMaxThreads(4);
+               pool.setMaxQueued(8);
+
+               contexts = new ContextHandlerCollection();
+
+               log = new TestRequestLog();
+               log.setHandler(contexts);
+
+               server = new Server();
+               server.setConnectors(new Connector[] { connector });
+               server.setThreadPool(pool);
+               server.setHandler(log);
+
+               server.setStopAtShutdown(false);
+               server.setGracefulShutdown(0);
+       }
+
+       /**
+        * Create a new servlet context within the server.
+        * <p>
+        * This method should be invoked before the server is started, once for each
+        * context the caller wants to register.
+        *
+        * @param path
+        *            path of the context; use "/" for the root context if binding
+        *            to the root is desired.
+        * @return the context to add servlets into.
+        */
+       public ServletContextHandler addContext(String path) {
+               assertNotYetSetUp();
+               if ("".equals(path))
+                       path = "/";
+
+               ServletContextHandler ctx = new ServletContextHandler();
+               ctx.setContextPath(path);
+               contexts.addHandler(ctx);
+
+               return ctx;
+       }
+
+       public ServletContextHandler authBasic(ServletContextHandler ctx) {
+               assertNotYetSetUp();
+               auth(ctx, new BasicAuthenticator());
+               return ctx;
+       }
+
+       private void auth(ServletContextHandler ctx, Authenticator authType) {
+               final String role = "can-access";
+
+               MappedLoginService users = new MappedLoginService() {
+                       @Override
+                       protected UserIdentity loadUser(String who) {
+                               return null;
+                       }
+
+                       @Override
+                       protected void loadUsers() throws IOException {
+                               putUser(username, new Password(password), new String[] { role });
+                       }
+               };
+
+               ConstraintMapping cm = new ConstraintMapping();
+               cm.setConstraint(new Constraint());
+               cm.getConstraint().setAuthenticate(true);
+               cm.getConstraint().setDataConstraint(Constraint.DC_NONE);
+               cm.getConstraint().setRoles(new String[] { role });
+               cm.setPathSpec("/*");
+
+               ConstraintSecurityHandler sec = new ConstraintSecurityHandler();
+               sec.setStrict(false);
+               sec.setRealmName(realm);
+               sec.setAuthenticator(authType);
+               sec.setLoginService(users);
+               sec.setConstraintMappings(new ConstraintMapping[] { cm });
+               sec.setHandler(ctx);
+
+               contexts.removeHandler(ctx);
+               contexts.addHandler(sec);
+       }
+
+       /**
+        * Start the server on a random local port.
+        *
+        * @throws Exception
+        *             the server cannot be started, testing is not possible.
+        */
+       public void setUp() throws Exception {
+               RecordingLogger.clear();
+               log.clear();
+               server.start();
+       }
+
+       /**
+        * Shutdown the server.
+        *
+        * @throws Exception
+        *             the server refuses to halt, or wasn't running.
+        */
+       public void tearDown() throws Exception {
+               RecordingLogger.clear();
+               log.clear();
+               server.stop();
+       }
+
+       /**
+        * Get the URI to reference this server.
+        * <p>
+        * The returned URI includes the proper host name and port number, but does
+        * not contain a path.
+        *
+        * @return URI to reference this server's root context.
+        */
+       public URI getURI() {
+               assertAlreadySetUp();
+               String host = connector.getHost();
+               if (host.contains(":") && !host.startsWith("["))
+                       host = "[" + host + "]";
+               final String uri = "http://" + host + ":" + getPort();
+               try {
+                       return new URI(uri);
+               } catch (URISyntaxException e) {
+                       throw new RuntimeException("Unexpected URI error on " + uri, e);
+               }
+       }
+
+       /** @return the local port number the server is listening on. */
+       public int getPort() {
+               assertAlreadySetUp();
+               return ((SelectChannelConnector) connector).getLocalPort();
+       }
+
+       /** @return all requests since the server was started. */
+       public List<AccessEvent> getRequests() {
+               return new ArrayList<AccessEvent>(log.getEvents());
+       }
+
+       /**
+        * @param base
+        *            base URI used to access the server.
+        * @param path
+        *            the path to locate requests for, relative to {@code base}.
+        * @return all requests which match the given path.
+        */
+       public List<AccessEvent> getRequests(URIish base, String path) {
+               return getRequests(HttpTestCase.join(base, path));
+       }
+
+       /**
+        * @param path
+        *            the path to locate requests for.
+        * @return all requests which match the given path.
+        */
+       public List<AccessEvent> getRequests(String path) {
+               ArrayList<AccessEvent> r = new ArrayList<AccessEvent>();
+               for (AccessEvent event : log.getEvents()) {
+                       if (event.getPath().equals(path)) {
+                               r.add(event);
+                       }
+               }
+               return r;
+       }
+
+       private void assertNotYetSetUp() {
+               Assert.assertFalse("server is not running", server.isRunning());
+       }
+
+       private void assertAlreadySetUp() {
+               Assert.assertTrue("server is running", server.isRunning());
+       }
+}
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java
new file mode 100644 (file)
index 0000000..7da9034
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2009-2010, Google Inc.
+ * 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.junit.http;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
+import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.transport.RefSpec;
+import org.eclipse.jgit.transport.RemoteRefUpdate;
+import org.eclipse.jgit.transport.URIish;
+
+/** Base class for HTTP related transport testing. */
+public abstract class HttpTestCase extends LocalDiskRepositoryTestCase {
+       protected static final String master = Constants.R_HEADS + Constants.MASTER;
+
+       /** In-memory application server; subclass must start. */
+       protected AppServer server;
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               server = new AppServer();
+       }
+
+       protected void tearDown() throws Exception {
+               server.tearDown();
+               super.tearDown();
+       }
+
+       protected TestRepository<FileRepository> createTestRepository()
+                       throws IOException {
+               return new TestRepository<FileRepository>(createBareRepository());
+       }
+
+       protected URIish toURIish(String path) throws URISyntaxException {
+               URI u = server.getURI().resolve(path);
+               return new URIish(u.toString());
+       }
+
+       protected URIish toURIish(ServletContextHandler app, String name)
+                       throws URISyntaxException {
+               String p = app.getContextPath();
+               if (!p.endsWith("/") && !name.startsWith("/"))
+                       p += "/";
+               p += name;
+               return toURIish(p);
+       }
+
+       protected List<AccessEvent> getRequests() {
+               return server.getRequests();
+       }
+
+       protected List<AccessEvent> getRequests(URIish base, String path) {
+               return server.getRequests(base, path);
+       }
+
+       protected List<AccessEvent> getRequests(String path) {
+               return server.getRequests(path);
+       }
+
+       protected static void fsck(Repository db, RevObject... tips)
+                       throws Exception {
+               new TestRepository(db).fsck(tips);
+       }
+
+       protected static Set<RefSpec> mirror(String... refs) {
+               HashSet<RefSpec> r = new HashSet<RefSpec>();
+               for (String name : refs) {
+                       RefSpec rs = new RefSpec(name);
+                       rs = rs.setDestination(name);
+                       rs = rs.setForceUpdate(true);
+                       r.add(rs);
+               }
+               return r;
+       }
+
+       protected static Collection<RemoteRefUpdate> push(TestRepository from,
+                       RevCommit q) throws IOException {
+               final Repository db = from.getRepository();
+               final String srcExpr = q.name();
+               final String dstName = master;
+               final boolean forceUpdate = true;
+               final String localName = null;
+               final ObjectId oldId = null;
+
+               RemoteRefUpdate u = new RemoteRefUpdate(db, srcExpr, dstName,
+                               forceUpdate, localName, oldId);
+               return Collections.singleton(u);
+       }
+
+       public static String loose(URIish base, AnyObjectId id) {
+               final String objectName = id.name();
+               final String d = objectName.substring(0, 2);
+               final String f = objectName.substring(2);
+               return join(base, "objects/" + d + "/" + f);
+       }
+
+       public static String join(URIish base, String path) {
+               if (path.startsWith("/"))
+                       fail("Cannot join absolute path " + path + " to URIish " + base);
+
+               String dir = base.getPath();
+               if (!dir.endsWith("/"))
+                       dir += "/";
+               return dir + path;
+       }
+}
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/MockServletConfig.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/MockServletConfig.java
new file mode 100644 (file)
index 0000000..0b4530d
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * 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.junit.http;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+public class MockServletConfig implements ServletConfig {
+       private final Map<String, String> parameters = new HashMap<String, String>();
+
+       public void setInitParameter(String name, String value) {
+               parameters.put(name, value);
+       }
+
+       public String getInitParameter(String name) {
+               return parameters.get(name);
+       }
+
+       public Enumeration getInitParameterNames() {
+               final Iterator<String> i = parameters.keySet().iterator();
+               return new Enumeration<String>() {
+                       public boolean hasMoreElements() {
+                               return i.hasNext();
+                       }
+
+                       public String nextElement() {
+                               return i.next();
+                       }
+               };
+       }
+
+       public String getServletName() {
+               return "MOCK_SERVLET";
+       }
+
+       public ServletContext getServletContext() {
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java
new file mode 100644 (file)
index 0000000..3295d44
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * 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.junit.http;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jetty.util.log.Logger;
+
+/** Logs warnings into an array for later inspection. */
+public class RecordingLogger implements Logger {
+       private static List<Warning> warnings = new ArrayList<Warning>();
+
+       /** Clear the warnings, automatically done by {@link AppServer#setUp()} */
+       public static void clear() {
+               synchronized (warnings) {
+                       warnings.clear();
+               }
+       }
+
+       /** @return the warnings (if any) from the last execution */
+       public static List<Warning> getWarnings() {
+               synchronized (warnings) {
+                       ArrayList<Warning> copy = new ArrayList<Warning>(warnings);
+                       return Collections.unmodifiableList(copy);
+               }
+       }
+
+       @SuppressWarnings("serial")
+       public static class Warning extends Exception {
+               public Warning(String msg) {
+                       super(msg);
+               }
+
+               public Warning(String msg, Throwable cause) {
+                       super(msg, cause);
+               }
+
+               public Warning(Throwable thrown) {
+                       super(thrown);
+               }
+       }
+
+       private final String name;
+
+       public RecordingLogger() {
+               this("");
+       }
+
+       public RecordingLogger(final String name) {
+               this.name = name;
+       }
+
+       public Logger getLogger(@SuppressWarnings("hiding") String name) {
+               return new RecordingLogger(name);
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void warn(String msg, Object arg0, Object arg1) {
+               synchronized (warnings) {
+                       warnings.add(new Warning(MessageFormat.format(msg, arg0, arg1)));
+               }
+       }
+
+       public void warn(String msg, Throwable th) {
+               synchronized (warnings) {
+                       warnings.add(new Warning(msg, th));
+               }
+       }
+
+       public void warn(String msg) {
+               synchronized (warnings) {
+                       warnings.add(new Warning(msg));
+               }
+       }
+
+       public void debug(@SuppressWarnings("unused") String msg,
+                                 @SuppressWarnings("unused") Object arg0,
+                                 @SuppressWarnings("unused") Object arg1) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void debug(String msg, Throwable th) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void debug(@SuppressWarnings("unused") String msg) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void info(@SuppressWarnings("unused") String msg,
+                                @SuppressWarnings("unused") Object arg0,
+                                @SuppressWarnings("unused") Object arg1) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void info(@SuppressWarnings("unused") String msg) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public boolean isDebugEnabled() {
+               return false;
+       }
+
+       public void setDebugEnabled(boolean enabled) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void warn(String msg, Object... args) {
+               synchronized (warnings) {
+                       warnings.add(new Warning(MessageFormat.format(msg, args)));
+               }
+       }
+
+       public void warn(Throwable thrown) {
+               synchronized (warnings) {
+                       warnings.add(new Warning(thrown));
+               }
+       }
+
+       public void info(String msg, Object... args) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void info(Throwable thrown) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void info(String msg, Throwable thrown) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void debug(String msg, Object... args) {
+               // Ignore (not relevant to test failures)
+       }
+
+       public void debug(Throwable thrown) {
+               // Ignore (not relevant to test failures)
+       }
+}
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/SimpleHttpServer.java
new file mode 100644 (file)
index 0000000..987f211
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2009-2010, Google Inc.
+ * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
+ * 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.junit.http;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.http.server.GitServlet;
+import org.eclipse.jgit.http.server.resolver.RepositoryResolver;
+import org.eclipse.jgit.http.server.resolver.ServiceNotEnabledException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
+import org.eclipse.jgit.transport.URIish;
+
+/**
+ * Simple http server for testing http access to Git repositories.
+ * Authentication with hardcoded credentials user:agitter password:letmein.
+ */
+public class SimpleHttpServer {
+
+       AppServer server;
+
+       private final FileRepository db;
+
+       private URIish uri;
+
+       public SimpleHttpServer(FileRepository repository) {
+               this.db = repository;
+               server = new AppServer();
+       }
+
+       public void start() throws Exception {
+               ServletContextHandler sBasic = server.authBasic(smart("/sbasic"));
+               server.setUp();
+               final String srcName = db.getDirectory().getName();
+               uri = toURIish(sBasic, srcName);
+       }
+
+       public void stop() throws Exception {
+               server.tearDown();
+       }
+
+       public URIish getUri() {
+               return uri;
+       }
+
+       private ServletContextHandler smart(final String path) {
+               GitServlet gs = new GitServlet();
+               gs.setRepositoryResolver(new RepositoryResolver() {
+                       public Repository open(HttpServletRequest req, String name)
+                                       throws RepositoryNotFoundException,
+                                       ServiceNotEnabledException {
+                               if (!name.equals(nameOf(db)))
+                                       throw new RepositoryNotFoundException(name);
+
+                               db.incrementOpen();
+                               return db;
+                       }
+               });
+
+               ServletContextHandler ctx = server.addContext(path);
+               ctx.addServlet(new ServletHolder(gs), "/*");
+               return ctx;
+       }
+
+       private static String nameOf(final FileRepository db) {
+               return db.getDirectory().getName();
+       }
+
+       private URIish toURIish(String path) throws URISyntaxException {
+               URI u = server.getURI().resolve(path);
+               return new URIish(u.toString());
+       }
+
+       private URIish toURIish(ServletContextHandler app, String name)
+                       throws URISyntaxException {
+               String p = app.getContextPath();
+               if (!p.endsWith("/") && !name.startsWith("/"))
+                       p += "/";
+               p += name;
+               return toURIish(p);
+       }
+}
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/TestRequestLog.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/TestRequestLog.java
new file mode 100644 (file)
index 0000000..b186e1f
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2010, Google Inc.
+ * 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.junit.http;
+
+import org.eclipse.jetty.server.DispatcherType;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.handler.HandlerWrapper;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/** Logs request made through {@link AppServer}. */
+class TestRequestLog extends HandlerWrapper {
+  private static final int MAX = 16;
+
+  private final List<AccessEvent> events = new ArrayList<AccessEvent>();
+
+  private final Semaphore active = new Semaphore(MAX);
+
+  /** Reset the log back to its original empty state. */
+  void clear() {
+    try {
+      for (;;) {
+        try {
+          active.acquire(MAX);
+          break;
+        } catch (InterruptedException e) {
+          continue;
+        }
+      }
+
+      synchronized (events) {
+        events.clear();
+      }
+    } finally {
+      active.release(MAX);
+    }
+  }
+
+  /** @return all of the events made since the last clear. */
+  List<AccessEvent> getEvents() {
+    try {
+      for (;;) {
+        try {
+          active.acquire(MAX);
+          break;
+        } catch (InterruptedException e) {
+          continue;
+        }
+      }
+
+      synchronized (events) {
+        return events;
+      }
+    } finally {
+      active.release(MAX);
+    }
+  }
+
+  @Override
+  public void handle(String target, Request baseRequest, HttpServletRequest request,
+      HttpServletResponse response) throws IOException, ServletException {
+    try {
+      for (;;) {
+        try {
+          active.acquire();
+          break;
+        } catch (InterruptedException e) {
+          continue;
+        }
+      }
+
+      super.handle(target, baseRequest, request, response);
+
+      if (DispatcherType.REQUEST.equals(baseRequest.getDispatcherType()))
+        log((Request) request, (Response) response);
+
+    } finally {
+      active.release();
+    }
+  }
+
+  private void log(Request request, Response response) {
+    synchronized (events) {
+      events.add(new AccessEvent(request, response));
+    }
+  }
+}
index d3b3aec752d64921fdc9bc7d5683289712b8df3a..c76acc6d062b8dd59084bb9e53293aea080dcbad 100644 (file)
@@ -1,35 +1,48 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
-      id="org.eclipse.jgit.junit"
-      label="%featureName"
-      version="0.10.0.qualifier"
-      provider-name="%providerName">
-
-   <description url="http://www.eclipse.org/jgit/">
-     %description
-   </description>
-
-   <copyright>
-     %copyright
-   </copyright>
-
-   <license url="%licenseURL">
-     %license
-   </license>
-
-   <url>
-      <update label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
-      <discovery label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>
-   </url>
-
-   <requires>
-     <import plugin="com.jcraft.jsch"/>
-   </requires>
-
-   <plugin
-         id="org.eclipse.jgit.junit"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-</feature>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<feature\r
+      id="org.eclipse.jgit.junit"\r
+      label="%featureName"\r
+      version="0.10.0.qualifier"\r
+      provider-name="%providerName">\r
+\r
+   <description url="http://www.eclipse.org/jgit/">\r
+      %description\r
+   </description>\r
+\r
+   <copyright>\r
+      %copyright\r
+   </copyright>\r
+\r
+   <license url="%licenseURL">\r
+      %license\r
+   </license>\r
+\r
+   <url>\r
+      <update label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>\r
+      <discovery label="%updateSiteName" url="http://download.eclipse.org/egit/updates"/>\r
+   </url>\r
+\r
+   <requires>\r
+      <import plugin="com.jcraft.jsch"/>\r
+   </requires>\r
+\r
+   <plugin\r
+         id="org.eclipse.jgit.junit"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"\r
+         unpack="false"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jgit.junit.http"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"/>\r
+\r
+   <plugin\r
+         id="org.eclipse.jgit.http.server"\r
+         download-size="0"\r
+         install-size="0"\r
+         version="0.0.0"/>\r
+\r
+</feature>\r
index 4f5d030457083c171ac650d3052b1c5dba58e1f6..3ab205792927653fa38b55b4c1efd27b9ff678a6 100644 (file)
       <artifactId>org.eclipse.jgit.junit</artifactId>
       <version>0.10.0-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit.junit.http</artifactId>
+      <version>0.10.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit.http.server</artifactId>
+      <version>0.10.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
 </project>
index b3aebf899fc90732b34ee35eeebdb8dce361ca53..c87b0ea1f1c8b88c15437c947f2d6a7bcaf2e106 100644 (file)
       <artifactId>org.eclipse.jgit.junit</artifactId>
       <version>0.10.0-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit.junit.http</artifactId>
+      <version>0.10.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit.http.server</artifactId>
+      <version>0.10.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/pom.xml b/pom.xml
index a6c76e5b310099180c304c1367cf3ae2485549cb..6c45ae207a7f69495bd62f3d6fecd3d608890291 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <junit-version>3.8.2</junit-version>
     <args4j-version>2.0.12</args4j-version>
     <servlet-api-version>2.5</servlet-api-version>
-    <jetty-version>7.0.1.v20091125</jetty-version>
+    <jetty-version>7.1.1.v20100517</jetty-version>
   </properties>
 
   <pluginRepositories>
     <module>org.eclipse.jgit.iplog</module>
     <module>org.eclipse.jgit.pgm</module>
     <module>org.eclipse.jgit.junit</module>
+       <module>org.eclipse.jgit.junit.http</module>
 
     <module>org.eclipse.jgit.test</module>
     <module>org.eclipse.jgit.http.test</module>