Browse Source

Fix tests for OS X when the tmpdir is the default /tmp

/tmp is a symbolic link and some tests break when the path
gets canonicalized by JGit or Jetty. Allow Jetty to serve
symlinks by setting init parameter "aliases" to true [1].

[1] http://wiki.eclipse.org/Jetty/Howto/How_to_serve_symbolically_linked_files

Change-Id: I45359a40435e8a33def6e0bb6784b4d8637793ac
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-3.1
Robin Rosenberg 12 years ago committed by Matthias Sohn
parent
commit
7f43d04986
  1. 6
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
  2. 4
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletInitTest.java
  3. 4
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
  4. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java

6
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java

@ -60,6 +60,7 @@ import java.util.Map;
import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent; import org.eclipse.jgit.junit.http.AccessEvent;
@ -97,8 +98,9 @@ public class DumbClientDumbServerTest extends HttpTestCase {
ServletContextHandler app = server.addContext("/git"); ServletContextHandler app = server.addContext("/git");
app.setResourceBase(base.toString()); app.setResourceBase(base.toString());
app.addServlet(DefaultServlet.class, "/"); ServletHolder holder = app.addServlet(DefaultServlet.class, "/");
// The tmp directory is symlinked on OS X
holder.setInitParameter("aliases", "true");
server.setUp(); server.setUp();
remoteRepository = src.getRepository(); remoteRepository = src.getRepository();

4
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletInitTest.java

@ -101,6 +101,8 @@ public class GitServletInitTest {
ServletHolder s = app.addServlet(GitServlet.class, "/git"); ServletHolder s = app.addServlet(GitServlet.class, "/git");
s.setInitOrder(1); s.setInitOrder(1);
s.getServletHandler().setStartWithUnavailable(false); s.getServletHandler().setStartWithUnavailable(false);
// The tmp directory is symlinked on OS X
s.setInitParameter("aliases", "true");
try { try {
server.setUp(); server.setUp();
@ -133,6 +135,8 @@ public class GitServletInitTest {
s.setInitOrder(1); s.setInitOrder(1);
s.setInitParameter("base-path", "."); s.setInitParameter("base-path", ".");
s.setInitParameter("export-all", "true"); s.setInitParameter("export-all", "true");
// The tmp directory is symlinked on OS X
s.setInitParameter("aliases", "true");
server.setUp(); server.setUp();
assertTrue("no warnings", RecordingLogger.getWarnings().isEmpty()); assertTrue("no warnings", RecordingLogger.getWarnings().isEmpty());

4
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java

@ -123,7 +123,9 @@ public class HttpClientTests extends HttpTestCase {
ServletContextHandler ctx = server.addContext(path); ServletContextHandler ctx = server.addContext(path);
ctx.setResourceBase(base.toString()); ctx.setResourceBase(base.toString());
ctx.addServlet(DefaultServlet.class, "/"); ServletHolder holder = ctx.addServlet(DefaultServlet.class, "/");
// The tmp directory is symlinked on OS X
holder.setInitParameter("aliases", "true");
return ctx; return ctx;
} }

9
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java

@ -148,7 +148,10 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
builder.setMustExist(true); builder.setMustExist(true);
Repository repo2 = builder.build(); Repository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory()); // The tmp directory may be a symlink so the actual path
// may not
assertEquals(repo1.getDirectory().getCanonicalPath(), repo2
.getDirectory().getCanonicalPath());
assertEquals(dir, repo2.getWorkTree()); assertEquals(dir, repo2.getWorkTree());
} }
@ -168,7 +171,9 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
builder.setMustExist(true); builder.setMustExist(true);
Repository repo2 = builder.build(); Repository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory()); // The tmp directory may be a symlink
assertEquals(repo1.getDirectory().getCanonicalPath(), repo2
.getDirectory().getCanonicalPath());
assertEquals(dir, repo2.getWorkTree()); assertEquals(dir, repo2.getWorkTree());
} }
} }

Loading…
Cancel
Save