Convert tests to JUnit 4 @Tests
Change-Id: Ic0eb0bdb83fb998f35f4026ca0062a34a6b20bb0
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/ConfigUtilTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/ConfigUtilTest.java
index c5c8389..cf2997b 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/ConfigUtilTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/ConfigUtilTest.java
@@ -15,14 +15,16 @@
package com.google.gitiles;
import static com.google.gitiles.ConfigUtil.getDuration;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.jgit.lib.Config;
import org.joda.time.Duration;
+import org.junit.Test;
/** Tests for configuration utilities. */
-public class ConfigUtilTest extends TestCase {
- public void testGetDuration() throws Exception {
+public class ConfigUtilTest {
+ @Test
+ public void getDurationReturnsDuration() throws Exception {
Duration def = Duration.standardSeconds(2);
Config config = new Config();
Duration t;
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesFilterTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesFilterTest.java
index dde2297..349a0af 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesFilterTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesFilterTest.java
@@ -17,14 +17,18 @@
import static com.google.gitiles.GitilesFilter.REPO_PATH_REGEX;
import static com.google.gitiles.GitilesFilter.REPO_REGEX;
import static com.google.gitiles.GitilesFilter.ROOT_REGEX;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
import java.util.regex.Matcher;
-import junit.framework.TestCase;
-
/** Tests for the Gitiles filter. */
-public class GitilesFilterTest extends TestCase {
- public void testRootUrls() throws Exception {
+public class GitilesFilterTest {
+ @Test
+ public void rootUrls() throws Exception {
assertFalse(ROOT_REGEX.matcher("").matches());
assertFalse(ROOT_REGEX.matcher("/foo").matches());
assertFalse(ROOT_REGEX.matcher("/foo/").matches());
@@ -53,7 +57,8 @@
assertEquals("", m.group(4));
}
- public void testRepoUrls() throws Exception {
+ @Test
+ public void repoUrls() throws Exception {
assertFalse(REPO_REGEX.matcher("").matches());
// These match the regex but are served by the root regex binder, which is
@@ -100,7 +105,8 @@
assertEquals("", m.group(4));
}
- public void testRepoPathUrls() throws Exception {
+ @Test
+ public void repoPathUrls() throws Exception {
assertFalse(REPO_PATH_REGEX.matcher("").matches());
assertFalse(REPO_PATH_REGEX.matcher("/").matches());
assertFalse(REPO_PATH_REGEX.matcher("//").matches());
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesUrlsTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesUrlsTest.java
index d262f47..3316f44 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesUrlsTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesUrlsTest.java
@@ -13,13 +13,15 @@
// limitations under the License.
package com.google.gitiles;
-
import static com.google.gitiles.GitilesUrls.NAME_ESCAPER;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
/** Unit tests for {@link GitilesUrls}. */
-public class GitilesUrlsTest extends TestCase {
- public void testNameEscaperEscapesAppropriateSpecialCharacters() throws Exception {
+public class GitilesUrlsTest {
+ @Test
+ public void nameEscaperEscapesAppropriateSpecialCharacters() throws Exception {
assertEquals("foo_bar", NAME_ESCAPER.apply("foo_bar"));
assertEquals("foo-bar", NAME_ESCAPER.apply("foo-bar"));
assertEquals("foo%25bar", NAME_ESCAPER.apply("foo%bar"));
@@ -35,11 +37,14 @@
assertEquals("foo%7Bbar", NAME_ESCAPER.apply("foo{bar"));
assertEquals("foo%7Dbar", NAME_ESCAPER.apply("foo}bar"));
}
- public void testNameEscaperDoesNotEscapeSlashes() throws Exception {
+
+ @Test
+ public void nameEscaperDoesNotEscapeSlashes() throws Exception {
assertEquals("foo/bar", NAME_ESCAPER.apply("foo/bar"));
}
- public void testNameEscaperEscapesSpacesWithPercentInsteadOfPlus() throws Exception {
+ @Test
+ public void nameEscaperEscapesSpacesWithPercentInsteadOfPlus() throws Exception {
assertEquals("foo+bar", NAME_ESCAPER.apply("foo+bar"));
assertEquals("foo%20bar", NAME_ESCAPER.apply("foo bar"));
assertEquals("foo%2520bar", NAME_ESCAPER.apply("foo%20bar"));
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesViewTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesViewTest.java
index 2e1e005..8235130 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/GitilesViewTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/GitilesViewTest.java
@@ -14,23 +14,28 @@
package com.google.gitiles;
-import junit.framework.TestCase;
-
-import org.eclipse.jgit.lib.ObjectId;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.gitiles.GitilesView.Type;
+import org.eclipse.jgit.lib.ObjectId;
+import org.junit.Test;
+
/** Tests for Gitiles views. */
-public class GitilesViewTest extends TestCase {
+public class GitilesViewTest {
private static final GitilesView HOST = GitilesView.hostIndex()
.setServletPath("/b")
.setHostName("host")
.build();
- public void testEmptyServletPath() throws Exception {
+ @Test
+ public void emptyServletPath() throws Exception {
GitilesView view = GitilesView.hostIndex()
.setServletPath("")
.setHostName("host")
@@ -48,7 +53,8 @@
view.getBreadcrumbs());
}
- public void testHostIndex() throws Exception {
+ @Test
+ public void hostIndex() throws Exception {
assertEquals("/b", HOST.getServletPath());
assertEquals(Type.HOST_INDEX, HOST.getType());
assertEquals("host", HOST.getHostName());
@@ -62,7 +68,8 @@
HOST.getBreadcrumbs());
}
- public void testQueryParams() throws Exception {
+ @Test
+ public void queryParams() throws Exception {
GitilesView view = GitilesView.hostIndex().copyFrom(HOST)
.putParam("foo", "foovalue")
.putParam("bar", "barvalue")
@@ -85,7 +92,8 @@
view.getBreadcrumbs());
}
- public void testQueryParamsNotCopied() throws Exception {
+ @Test
+ public void queryParamsNotCopied() throws Exception {
GitilesView view = GitilesView.hostIndex().copyFrom(HOST)
.putParam("foo", "foovalue")
.putParam("bar", "barvalue")
@@ -95,7 +103,8 @@
assertTrue(copy.getParameters().isEmpty());
}
- public void testRepositoryIndex() throws Exception {
+ @Test
+ public void repositoryIndex() throws Exception {
GitilesView view = GitilesView.repositoryIndex()
.copyFrom(HOST)
.setRepositoryName("foo/bar")
@@ -117,7 +126,8 @@
view.getBreadcrumbs());
}
- public void testRefs() throws Exception {
+ @Test
+ public void refs() throws Exception {
GitilesView view = GitilesView.refs()
.copyFrom(HOST)
.setRepositoryName("foo/bar")
@@ -139,7 +149,8 @@
view.getBreadcrumbs());
}
- public void testRefWithRevision() throws Exception {
+ @Test
+ public void refWithRevision() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.revision()
.copyFrom(HOST)
@@ -165,7 +176,8 @@
view.getBreadcrumbs());
}
- public void testDescribe() throws Exception {
+ @Test
+ public void describe() throws Exception {
GitilesView view = GitilesView.describe()
.copyFrom(HOST)
.setRepositoryName("foo/bar")
@@ -181,7 +193,8 @@
assertTrue(HOST.getParameters().isEmpty());
}
- public void testNoPathComponents() throws Exception {
+ @Test
+ public void noPathComponents() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.copyFrom(HOST)
@@ -209,7 +222,8 @@
view.getBreadcrumbs());
}
- public void testOnePathComponent() throws Exception {
+ @Test
+ public void onePathComponent() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.copyFrom(HOST)
@@ -238,7 +252,8 @@
view.getBreadcrumbs());
}
- public void testMultiplePathComponents() throws Exception {
+ @Test
+ public void multiplePathComponents() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.copyFrom(HOST)
@@ -270,7 +285,8 @@
view.getBreadcrumbs());
}
- public void testDiffAgainstFirstParent() throws Exception {
+ @Test
+ public void diffAgainstFirstParent() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId parent = ObjectId.fromString("efab5678efab5678efab5678efab5678efab5678");
GitilesView view = GitilesView.diff()
@@ -305,7 +321,8 @@
view.getBreadcrumbs());
}
- public void testDiffAgainstEmptyRevision() throws Exception {
+ @Test
+ public void diffAgainstEmptyRevision() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.diff()
.copyFrom(HOST)
@@ -338,7 +355,8 @@
view.getBreadcrumbs());
}
- public void testDiffAgainstOther() throws Exception {
+ @Test
+ public void diffAgainstOther() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId other = ObjectId.fromString("efab5678efab5678efab5678efab5678efab5678");
GitilesView view = GitilesView.diff()
@@ -373,7 +391,8 @@
view.getBreadcrumbs());
}
- public void testBranchLogWithoutPath() throws Exception {
+ @Test
+ public void branchLogWithoutPath() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.log()
.copyFrom(HOST)
@@ -400,7 +419,8 @@
view.getBreadcrumbs());
}
- public void testIdLogWithoutPath() throws Exception {
+ @Test
+ public void idLogWithoutPath() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.log()
.copyFrom(HOST)
@@ -427,7 +447,8 @@
view.getBreadcrumbs());
}
- public void testLogWithoutOldRevision() throws Exception {
+ @Test
+ public void logWithoutOldRevision() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.log()
.copyFrom(HOST)
@@ -459,7 +480,8 @@
view.getBreadcrumbs());
}
- public void testLogWithOldRevision() throws Exception {
+ @Test
+ public void logWithOldRevision() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId parent = ObjectId.fromString("efab5678efab5678efab5678efab5678efab5678");
GitilesView view = GitilesView.log()
@@ -493,7 +515,8 @@
view.getBreadcrumbs());
}
- public void testLogWithNoRevision() throws Exception {
+ @Test
+ public void logWithNoRevision() throws Exception {
GitilesView view = GitilesView.log()
.copyFrom(HOST)
.setRepositoryName("foo/bar")
@@ -516,7 +539,8 @@
view.getBreadcrumbs());
}
- public void testArchiveWithNoPath() throws Exception {
+ @Test
+ public void archiveWithNoPath() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.archive()
.copyFrom(HOST)
@@ -537,7 +561,8 @@
assertEquals("/b/foo/bar/+archive/master.tar.bz2", view.toUrl());
}
- public void testArchiveWithPath() throws Exception {
+ @Test
+ public void archiveWithPath() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.archive()
.copyFrom(HOST)
@@ -559,7 +584,8 @@
assertEquals("/b/foo/bar/+archive/master/path/to/a/dir.tar.bz2", view.toUrl());
}
- public void testBlame() throws Exception {
+ @Test
+ public void blame() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.blame()
.copyFrom(HOST)
@@ -589,7 +615,8 @@
view.getBreadcrumbs());
}
- public void testEscaping() throws Exception {
+ @Test
+ public void escaping() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
ObjectId parent = ObjectId.fromString("efab5678efab5678efab5678efab5678efab5678");
// Some of these values are not valid for Git, but check them anyway.
@@ -632,7 +659,8 @@
view.getBreadcrumbs());
}
- public void testBreadcrumbsHasSingleTree() throws Exception {
+ @Test
+ public void breadcrumbsHasSingleTree() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.copyFrom(HOST)
@@ -666,7 +694,8 @@
view.getBreadcrumbs(ImmutableList.of(true, false, false)));
}
- public void testBreadcrumbsHasSingleTreeRootPath() throws Exception {
+ @Test
+ public void breadcrumbsHasSingleTreeRootPath() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.copyFrom(HOST)
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/GitwebRedirectFilterTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/GitwebRedirectFilterTest.java
index b552ff6..b06da2a 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/GitwebRedirectFilterTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/GitwebRedirectFilterTest.java
@@ -18,10 +18,9 @@
import static com.google.gitiles.TestGitilesUrls.HOST_NAME;
import static javax.servlet.http.HttpServletResponse.SC_GONE;
import static javax.servlet.http.HttpServletResponse.SC_MOVED_PERMANENTLY;
+import static org.junit.Assert.assertEquals;
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.TestCase;
+import com.google.common.net.HttpHeaders;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -29,16 +28,18 @@
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Before;
+import org.junit.Test;
-import com.google.common.net.HttpHeaders;
+import javax.servlet.http.HttpServletRequest;
/** Tests for gitweb redirector. */
-public class GitwebRedirectFilterTest extends TestCase {
+public class GitwebRedirectFilterTest {
private TestRepository<DfsRepository> repo;
private GitilesServlet servlet;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
servlet = TestGitilesServlet.create(repo);
@@ -64,7 +65,8 @@
return req;
}
- public void testHostIndex() throws Exception {
+ @Test
+ public void hostIndex() throws Exception {
assertRedirectsTo(
GitilesView.hostIndex()
.setHostName(HOST_NAME)
@@ -73,7 +75,8 @@
newRequest("a=project_index"));
}
- public void testRepositoryIndex() throws Exception {
+ @Test
+ public void repositoryIndex() throws Exception {
assertGone(newRequest("a=summary"));
assertRedirectsTo(
GitilesView.repositoryIndex()
@@ -84,7 +87,8 @@
newRequest("a=summary;p=test"));
}
- public void testShow() throws Exception {
+ @Test
+ public void show() throws Exception {
assertGone(newRequest("a=commit"));
assertGone(newRequest("a=commit;p=test"));
RevCommit commit = repo.branch("refs/heads/master").commit().create();
@@ -98,7 +102,8 @@
newRequest("a=commit;p=test&h=" + ObjectId.toString(commit)));
}
- public void testNoStripDotGit() throws Exception {
+ @Test
+ public void noStripDotGit() throws Exception {
assertRedirectsTo(
GitilesView.repositoryIndex()
.setHostName(HOST_NAME)
@@ -115,7 +120,8 @@
newRequest("a=summary;p=test"));
}
- public void testStripDotGit() throws Exception {
+ @Test
+ public void stripDotGit() throws Exception {
servlet = TestGitilesServlet.create(repo, new GitwebRedirectFilter(true));
assertRedirectsTo(
GitilesView.repositoryIndex()
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/LinkifierTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/LinkifierTest.java
index 84f5f4f..cfd2423 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/LinkifierTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/LinkifierTest.java
@@ -14,28 +14,28 @@
package com.google.gitiles;
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletRequest;
+
/** Tests for {@link Linkifier}. */
-public class LinkifierTest extends TestCase {
+public class LinkifierTest {
private static final HttpServletRequest REQ = FakeHttpServletRequest.newRequest();
- @Override
- protected void setUp() throws Exception {
- }
-
- public void testlinkifyMessageNoMatch() throws Exception {
+ @Test
+ public void linkifyMessageNoMatch() throws Exception {
Linkifier l = new Linkifier(TestGitilesUrls.URLS);
assertEquals(ImmutableList.of(ImmutableMap.of("text", "some message text")),
l.linkify(FakeHttpServletRequest.newRequest(), "some message text"));
}
- public void testlinkifyMessageUrl() throws Exception {
+ @Test
+ public void linkifyMessageUrl() throws Exception {
Linkifier l = new Linkifier(TestGitilesUrls.URLS);
assertEquals(ImmutableList.of(
ImmutableMap.of("text", "http://my/url", "url", "http://my/url")),
@@ -57,7 +57,8 @@
l.linkify(REQ, "foo http://my/url bar http://my/other/url baz"));
}
- public void testlinkifyMessageChangeIdNoGerrit() throws Exception {
+ @Test
+ public void linkifyMessageChangeIdNoGerrit() throws Exception {
Linkifier l = new Linkifier(new GitilesUrls() {
@Override
public String getBaseGerritUrl(HttpServletRequest req) {
@@ -82,7 +83,8 @@
l.linkify(REQ, "Change-Id: I0123456789 does not exist"));
}
- public void testlinkifyMessageChangeId() throws Exception {
+ @Test
+ public void linkifyMessageChangeId() throws Exception {
Linkifier l = new Linkifier(TestGitilesUrls.URLS);
assertEquals(ImmutableList.of(
ImmutableMap.of("text", "I0123456789",
@@ -101,7 +103,8 @@
l.linkify(REQ, "Change-Id: I0123456789 exists"));
}
- public void testlinkifyMessageUrlAndChangeId() throws Exception {
+ @Test
+ public void linkifyMessageUrlAndChangeId() throws Exception {
Linkifier l = new Linkifier(TestGitilesUrls.URLS);
assertEquals(ImmutableList.of(
ImmutableMap.of("text", "http://my/url/I0123456789", "url", "http://my/url/I0123456789"),
@@ -111,7 +114,8 @@
l.linkify(REQ, "http://my/url/I0123456789 is not change I0123456789"));
}
- public void testLinkifyAmpersand() throws Exception {
+ @Test
+ public void linkifyAmpersand() throws Exception {
Linkifier l = new Linkifier(TestGitilesUrls.URLS);
assertEquals(ImmutableList.of(
ImmutableMap.of("text", "http://my/url?a&b", "url", "http://my/url?a&b")),
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/PaginatorTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/PaginatorTest.java
index 4f8b30b..2ac3f96 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/PaginatorTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/PaginatorTest.java
@@ -15,10 +15,11 @@
package com.google.gitiles;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-import java.util.List;
-
-import junit.framework.TestCase;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -26,28 +27,31 @@
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
+import java.util.List;
/** Unit tests for {@link LogServlet}. */
-public class PaginatorTest extends TestCase {
+public class PaginatorTest {
private TestRepository<DfsRepository> repo;
private RevWalk walk;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
walk = new RevWalk(repo.getRepository());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
walk.release();
}
- public void testStart() throws Exception {
+ @Test
+ public void start() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, commits.get(9));
@@ -61,7 +65,8 @@
assertEquals(commits.get(6), p.getNextStart());
}
- public void testNoStartCommit() throws Exception {
+ @Test
+ public void noStartCommit() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, null);
@@ -75,7 +80,8 @@
assertEquals(commits.get(6), p.getNextStart());
}
- public void testLessThanOnePageIn() throws Exception {
+ @Test
+ public void lessThanOnePageIn() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, commits.get(8));
@@ -89,7 +95,8 @@
assertEquals(commits.get(5), p.getNextStart());
}
- public void testAtLeastOnePageIn() throws Exception {
+ @Test
+ public void atLeastOnePageIn() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, commits.get(7));
@@ -103,7 +110,8 @@
assertEquals(commits.get(4), p.getNextStart());
}
- public void testEnd() throws Exception {
+ @Test
+ public void end() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, commits.get(2));
@@ -117,7 +125,8 @@
assertNull(p.getNextStart());
}
- public void testOnePastEnd() throws Exception {
+ @Test
+ public void onePastEnd() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 3, commits.get(1));
@@ -130,7 +139,8 @@
assertNull(p.getNextStart());
}
- public void testManyPastEnd() throws Exception {
+ @Test
+ public void manyPastEnd() throws Exception {
List<RevCommit> commits = linearCommits(10);
walk.markStart(commits.get(9));
Paginator p = new Paginator(walk, 5, commits.get(1));
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/PathsTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/PathsTest.java
index 09d4ccb..f6d3a00 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/PathsTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/PathsTest.java
@@ -15,11 +15,15 @@
package com.google.gitiles;
import static com.google.gitiles.Paths.simplifyPathUpToRoot;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
/** Tests for {@link Paths}. */
-public class PathsTest extends TestCase {
- public void testSimplifyPathUpToRoot() throws Exception {
+public class PathsTest {
+ @Test
+ public void simplifyPathUpToRootSimplifiesPath() throws Exception {
String root = "a/b/c";
assertNull(simplifyPathUpToRoot("/foo", root));
assertEquals("a", simplifyPathUpToRoot("../../", root));
@@ -33,7 +37,8 @@
assertNull(simplifyPathUpToRoot("../../a/../../..", root));
}
- public void testSimplifyPathUpToNullRoot() throws Exception {
+ @Test
+ public void simplifyPathUpToNullRootDetectsNullRoot() throws Exception {
assertNull(simplifyPathUpToRoot("/foo", null));
assertNull(simplifyPathUpToRoot("../", null));
assertNull(simplifyPathUpToRoot("../../", null));
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/RefServletTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/RefServletTest.java
index d5f768d..6f50185 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/RefServletTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/RefServletTest.java
@@ -14,9 +14,8 @@
package com.google.gitiles;
-import java.io.IOException;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -26,14 +25,18 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTag;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
/** Tests for {@link Linkifier}. */
-public class RefServletTest extends TestCase {
+public class RefServletTest {
private TestRepository<DfsRepository> repo;
private GitilesServlet servlet;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
DfsRepository r = new InMemoryRepository(new DfsRepositoryDescription("test"));
repo = new TestRepository<DfsRepository>(r);
@@ -56,7 +59,8 @@
repo.getRepository().getRef(refName)).getPeeledObjectId());
}
- public void testEvilRefName() throws Exception {
+ @Test
+ public void evilRefName() throws Exception {
String evilRefName = "refs/evil/<script>window.close();</script>/&foo";
assertTrue(Repository.isValidRefName(evilRefName));
repo.branch(evilRefName).commit().create();
@@ -72,7 +76,8 @@
res.getActualBodyString());
}
- public void testGetRefsTextAll() throws Exception {
+ @Test
+ public void getRefsTextAll() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs");
req.setQueryString("format=TEXT");
@@ -90,7 +95,8 @@
res.getActualBodyString());
}
- public void testGetRefsTextAllTrailingSlash() throws Exception {
+ @Test
+ public void getRefsTextAllTrailingSlash() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs");
req.setQueryString("format=TEXT");
@@ -108,7 +114,8 @@
res.getActualBodyString());
}
- public void testGetRefsHeadsText() throws Exception {
+ @Test
+ public void getRefsHeadsText() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs/heads");
req.setQueryString("format=TEXT");
@@ -122,7 +129,8 @@
res.getActualBodyString());
}
- public void testGetRefsHeadsTextTrailingSlash() throws Exception {
+ @Test
+ public void getRefsHeadsTextTrailingSlash() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs/heads/");
req.setQueryString("format=TEXT");
@@ -136,7 +144,8 @@
res.getActualBodyString());
}
- public void testNoHeadText() throws Exception {
+ @Test
+ public void noHeadText() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs/HEAD");
req.setQueryString("format=TEXT");
@@ -148,7 +157,8 @@
assertEquals("", res.getActualBodyString());
}
- public void testSingleHeadText() throws Exception {
+ @Test
+ public void singleHeadText() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs/heads/master");
req.setQueryString("format=TEXT");
@@ -161,7 +171,8 @@
res.getActualBodyString());
}
- public void testSinglePeeledTagText() throws Exception {
+ @Test
+ public void singlePeeledTagText() throws Exception {
FakeHttpServletRequest req = FakeHttpServletRequest.newRequest();
req.setPathInfo("/test/+refs/tags/atag");
req.setQueryString("format=TEXT");
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/RepositoryIndexServletTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/RepositoryIndexServletTest.java
index f239b82..b4243c4 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/RepositoryIndexServletTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/RepositoryIndexServletTest.java
@@ -15,16 +15,17 @@
package com.google.gitiles;
import static com.google.gitiles.TestGitilesUrls.URLS;
+import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import junit.framework.TestCase;
-
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository;
+import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
import java.util.Map;
@@ -32,12 +33,12 @@
import javax.servlet.http.HttpServletRequest;
/** Tests for {@link RepositoryIndexServlet}. */
-public class RepositoryIndexServletTest extends TestCase {
+public class RepositoryIndexServletTest {
private TestRepository<DfsRepository> repo;
private RepositoryIndexServlet servlet;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
servlet = new RepositoryIndexServlet(
@@ -46,13 +47,15 @@
new TimeCache());
}
- public void testEmpty() throws Exception {
+ @Test
+ public void empty() throws Exception {
Map<String, ?> data = buildData();
assertEquals(ImmutableList.of(), data.get("branches"));
assertEquals(ImmutableList.of(), data.get("tags"));
}
- public void testBranchesAndTags() throws Exception {
+ @Test
+ public void branchesAndTags() throws Exception {
repo.branch("refs/heads/foo").commit().create();
repo.branch("refs/heads/bar").commit().create();
repo.branch("refs/tags/baz").commit().create();
@@ -70,7 +73,8 @@
data.get("tags"));
}
- public void testAmbiguousBranch() throws Exception {
+ @Test
+ public void ambiguousBranch() throws Exception {
repo.branch("refs/heads/foo").commit().create();
repo.branch("refs/heads/bar").commit().create();
repo.branch("refs/tags/foo").commit().create();
@@ -89,7 +93,8 @@
data.get("tags"));
}
- public void testAmbiguousRelativeToNonBranchOrTag() throws Exception {
+ @Test
+ public void ambiguousRelativeToNonBranchOrTag() throws Exception {
repo.branch("refs/foo").commit().create();
repo.branch("refs/heads/foo").commit().create();
repo.branch("refs/tags/foo").commit().create();
@@ -105,7 +110,8 @@
data.get("tags"));
}
- public void testRefsHeads() throws Exception {
+ @Test
+ public void refsHeads() throws Exception {
repo.branch("refs/heads/foo").commit().create();
repo.branch("refs/heads/refs/heads/foo").commit().create();
Map<String, ?> data = buildData();
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/RevisionParserTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/RevisionParserTest.java
index 6cba43d..60df64d 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/RevisionParserTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/RevisionParserTest.java
@@ -17,8 +17,11 @@
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
import static org.eclipse.jgit.lib.Constants.OBJ_TAG;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-import junit.framework.TestCase;
+import com.google.common.cache.CacheBuilder;
+import com.google.gitiles.RevisionParser.Result;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -27,17 +30,16 @@
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTag;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.gitiles.RevisionParser.Result;
+import org.junit.Before;
+import org.junit.Test;
/** Tests for the revision parser. */
-public class RevisionParserTest extends TestCase {
+public class RevisionParserTest {
private TestRepository<DfsRepository> repo;
private RevisionParser parser;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
parser = new RevisionParser(
@@ -46,7 +48,8 @@
new VisibilityCache(false, CacheBuilder.newBuilder().maximumSize(0)));
}
- public void testParseRef() throws Exception {
+ @Test
+ public void parseRef() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
assertEquals(new Result(Revision.peeled("master", master)),
parser.parse("master"));
@@ -56,7 +59,8 @@
assertNull(parser.parse("refs heads master"));
}
- public void testParseRefParentExpression() throws Exception {
+ @Test
+ public void parseRefParentExpression() throws Exception {
RevCommit root = repo.commit().create();
RevCommit parent1 = repo.commit().parent(root).create();
RevCommit parent2 = repo.commit().parent(root).create();
@@ -72,7 +76,8 @@
assertEquals(new Result(Revision.peeled("master~2", root)), parser.parse("master~2"));
}
- public void testParseCommitShaVisibleFromHead() throws Exception {
+ @Test
+ public void parseCommitShaVisibleFromHead() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.branch("master").commit().parent(parent).create();
assertEquals(new Result(Revision.peeled(commit.name(), commit)), parser.parse(commit.name()));
@@ -82,7 +87,8 @@
assertEquals(new Result(Revision.peeled(abbrev, commit)), parser.parse(abbrev));
}
- public void testParseCommitShaVisibleFromTag() throws Exception {
+ @Test
+ public void parseCommitShaVisibleFromTag() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.commit().parent(parent).create();
repo.branch("master").commit().create();
@@ -92,7 +98,8 @@
assertEquals(new Result(Revision.peeled(parent.name(), parent)), parser.parse(parent.name()));
}
- public void testParseCommitShaVisibleFromOther() throws Exception {
+ @Test
+ public void parseCommitShaVisibleFromOther() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.commit().parent(parent).create();
repo.branch("master").commit().create();
@@ -103,7 +110,8 @@
assertEquals(new Result(Revision.peeled(parent.name(), parent)), parser.parse(parent.name()));
}
- public void testParseCommitShaVisibleFromChange() throws Exception {
+ @Test
+ public void parseCommitShaVisibleFromChange() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.commit().parent(parent).create();
repo.branch("master").commit().create();
@@ -115,7 +123,8 @@
assertEquals(null, parser.parse(parent.name()));
}
- public void testParseNonVisibleCommitSha() throws Exception {
+ @Test
+ public void parseNonVisibleCommitSha() throws Exception {
RevCommit other = repo.commit().create();
repo.branch("master").commit().create();
assertEquals(null, parser.parse(other.name()));
@@ -124,7 +133,8 @@
assertEquals(new Result(Revision.peeled(other.name(), other)), parser.parse(other.name()));
}
- public void testParseDiffRevisions() throws Exception {
+ @Test
+ public void parseDiffRevisions() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.branch("master").commit().parent(parent).create();
RevCommit other = repo.branch("other").commit().create();
@@ -176,7 +186,8 @@
parser.parse("other..master"));
}
- public void testParseFirstParentExpression() throws Exception {
+ @Test
+ public void parseFirstParentExpression() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit commit = repo.branch("master").commit().parent(parent).create();
@@ -214,7 +225,8 @@
parser.parse("tag^^!"));
}
- public void testNonVisibleDiffShas() throws Exception {
+ @Test
+ public void nonVisibleDiffShas() throws Exception {
RevCommit other = repo.commit().create();
RevCommit master = repo.branch("master").commit().create();
assertEquals(null, parser.parse("other..master"));
@@ -235,7 +247,8 @@
parser.parse("master..other"));
}
- public void testParseTag() throws Exception {
+ @Test
+ public void parseTag() throws Exception {
RevCommit master = repo.branch("master").commit().create();
RevTag masterTag = repo.update("refs/tags/master-tag", repo.tag("master-tag", master));
RevTag masterTagTag = repo.update("refs/tags/master-tag-tag",
@@ -255,7 +268,8 @@
parser.parse("blob-tag"));
}
- public void testParseUnsupportedRevisionExpressions() throws Exception {
+ @Test
+ public void parseUnsupportedRevisionExpressions() throws Exception {
RevBlob blob = repo.blob("blob contents");
RevCommit master = repo.branch("master").commit().add("blob", blob).create();
@@ -273,7 +287,8 @@
assertEquals(null, parser.parse("master@{0}"));
}
- public void testParseMissingSha() throws Exception {
+ @Test
+ public void parseMissingSha() throws Exception {
assertNull(parser.parse("deadbeef"));
assertNull(parser.parse("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
}
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/TimeCacheTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/TimeCacheTest.java
index c839f37..135614b 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/TimeCacheTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/TimeCacheTest.java
@@ -14,9 +14,7 @@
package com.google.gitiles;
-import java.io.IOException;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -30,9 +28,13 @@
import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
/** Unit tests for {@link TimeCache}. */
-public class TimeCacheTest extends TestCase {
+public class TimeCacheTest {
private TestRepository<DfsRepository> repo;
private RevWalk walk;
private TimeCache cache;
@@ -44,8 +46,8 @@
*/
private long start;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
walk = new RevWalk(repo.getRepository());
@@ -57,14 +59,16 @@
return cache.getTime(walk, id);
}
- public void testCommitTime() throws Exception {
+ @Test
+ public void commitTime() throws Exception {
RevCommit root = repo.commit().create();
RevCommit master = repo.commit().parent(root).create();
assertEquals(start + 1, getTime(root));
assertEquals(start + 2, getTime(master));
}
- public void testTaggedCommitTime() throws Exception {
+ @Test
+ public void taggedCommitTime() throws Exception {
RevCommit commit = repo.commit().create();
repo.tick(1);
RevTag tag = repo.tag("tag", commit);
@@ -72,7 +76,8 @@
assertEquals(start + 2, getTime(tag));
}
- public void testTaggedTreeAndBlobTime() throws Exception {
+ @Test
+ public void taggedTreeAndBlobTime() throws Exception {
RevBlob blob = repo.blob("contents");
RevTree tree = repo.tree(repo.file("foo", blob));
repo.tick(1);
@@ -83,7 +88,8 @@
assertEquals(start + 2, getTime(treeTag));
}
- public void testTaggedTagTime() throws Exception {
+ @Test
+ public void taggedTagTime() throws Exception {
repo.tick(2);
RevTag tag = repo.tag("tag", repo.commit().create());
repo.tick(-1);
@@ -92,14 +98,16 @@
assertEquals(start + 2, getTime(tagTag));
}
- public void testTreeAndBlobTime() throws Exception {
+ @Test
+ public void treeAndBlobTime() throws Exception {
RevBlob blob = repo.blob("contents");
RevTree tree = repo.tree(repo.file("foo", blob));
assertEquals(Long.MIN_VALUE, getTime(blob));
assertEquals(Long.MIN_VALUE, getTime(tree));
}
- public void testTagMissingTime() throws Exception {
+ @Test
+ public void tagMissingTime() throws Exception {
RevCommit commit = repo.commit().create();
TagBuilder builder = new TagBuilder();
builder.setObjectId(commit);
@@ -117,7 +125,8 @@
assertEquals(start + 1, getTime(id));
}
- public void testFirstTagMissingTime() throws Exception {
+ @Test
+ public void firstTagMissingTime() throws Exception {
RevCommit commit = repo.commit().create();
repo.tick(1);
RevTag tag = repo.tag("tag", commit);
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/TreeSoyDataTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/TreeSoyDataTest.java
index e1ed3e8..1a09dd8 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/TreeSoyDataTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/TreeSoyDataTest.java
@@ -16,15 +16,18 @@
import static com.google.gitiles.TreeSoyData.getTargetDisplayName;
import static com.google.gitiles.TreeSoyData.resolveTargetUrl;
-import junit.framework.TestCase;
-
-import org.eclipse.jgit.lib.ObjectId;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import com.google.common.base.Strings;
+import org.eclipse.jgit.lib.ObjectId;
+import org.junit.Test;
+
/** Tests for {@link TreeSoyData}. */
-public class TreeSoyDataTest extends TestCase {
- public void testGetTargetDisplayName() throws Exception {
+public class TreeSoyDataTest {
+ @Test
+ public void getTargetDisplayNameReturnsDisplayName() throws Exception {
assertEquals("foo", getTargetDisplayName("foo"));
assertEquals("foo/bar", getTargetDisplayName("foo/bar"));
assertEquals("a/a/a/a/a/a/a/a/a/a/bar",
@@ -37,7 +40,8 @@
getTargetDisplayName(Strings.repeat("a", 80)));
}
- public void testResolveTargetUrl() throws Exception {
+ @Test
+ public void resolveTargetUrlReturnsUrl() throws Exception {
ObjectId id = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
GitilesView view = GitilesView.path()
.setServletPath("/x")
diff --git a/gitiles-servlet/src/test/java/com/google/gitiles/ViewFilterTest.java b/gitiles-servlet/src/test/java/com/google/gitiles/ViewFilterTest.java
index 2660541..581bee0 100644
--- a/gitiles-servlet/src/test/java/com/google/gitiles/ViewFilterTest.java
+++ b/gitiles-servlet/src/test/java/com/google/gitiles/ViewFilterTest.java
@@ -18,14 +18,15 @@
import static com.google.gitiles.GitilesFilter.REPO_PATH_REGEX;
import static com.google.gitiles.GitilesFilter.REPO_REGEX;
import static com.google.gitiles.GitilesFilter.ROOT_REGEX;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HttpHeaders;
import com.google.common.util.concurrent.Atomics;
import com.google.gitiles.GitilesView.Type;
-import junit.framework.TestCase;
-
import org.eclipse.jgit.http.server.glue.MetaFilter;
import org.eclipse.jgit.http.server.glue.MetaServlet;
import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
@@ -33,6 +34,8 @@
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Before;
+import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
@@ -44,23 +47,25 @@
import javax.servlet.http.HttpServletResponse;
/** Tests for the view filter. */
-public class ViewFilterTest extends TestCase {
+public class ViewFilterTest {
private TestRepository<DfsRepository> repo;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
repo = new TestRepository<DfsRepository>(
new InMemoryRepository(new DfsRepositoryDescription("test")));
}
- public void testNoCommand() throws Exception {
+ @Test
+ public void noCommand() throws Exception {
assertEquals(Type.HOST_INDEX, getView("/").getType());
assertEquals(Type.REPOSITORY_INDEX, getView("/repo").getType());
assertNull(getView("/repo/+"));
assertNull(getView("/repo/+/"));
}
- public void testAutoCommand() throws Exception {
+ @Test
+ public void autoCommand() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit master = repo.branch("refs/heads/master").commit().parent(parent).create();
String hex = master.name();
@@ -78,7 +83,8 @@
assertEquals(Type.DIFF, getView("/repo/+/" + parent.name() + ".." + hex + "/").getType());
}
- public void testHostIndex() throws Exception {
+ @Test
+ public void hostIndex() throws Exception {
GitilesView view = getView("/");
assertEquals(Type.HOST_INDEX, view.getType());
assertEquals("test-host", view.getHostName());
@@ -88,7 +94,8 @@
assertNull(view.getPathPart());
}
- public void testRepositoryIndex() throws Exception {
+ @Test
+ public void repositoryIndex() throws Exception {
GitilesView view = getView("/repo");
assertEquals(Type.REPOSITORY_INDEX, view.getType());
assertEquals("repo", view.getRepositoryName());
@@ -97,7 +104,8 @@
assertNull(view.getPathPart());
}
- public void testRefs() throws Exception {
+ @Test
+ public void refs() throws Exception {
GitilesView view;
view = getView("/repo/+refs");
@@ -136,7 +144,8 @@
assertEquals("heads/master", view.getPathPart());
}
- public void testDescribe() throws Exception {
+ @Test
+ public void describe() throws Exception {
GitilesView view;
assertNull(getView("/repo/+describe"));
@@ -157,7 +166,8 @@
assertEquals("refs/heads/master~3^~2", view.getPathPart());
}
- public void testShowBranches() throws Exception {
+ @Test
+ public void showBranches() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
RevCommit stable = repo.branch("refs/heads/stable").commit().create();
GitilesView view;
@@ -189,7 +199,8 @@
assertNull(getView("/repo/+show/stable..master"));
}
- public void testAmbiguousBranchAndTag() throws Exception {
+ @Test
+ public void ambiguousBranchAndTag() throws Exception {
RevCommit branch = repo.branch("refs/heads/name").commit().create();
RevCommit tag = repo.branch("refs/tags/name").commit().create();
GitilesView view;
@@ -225,7 +236,8 @@
assertNull(view.getPathPart());
}
- public void testPath() throws Exception {
+ @Test
+ public void path() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
repo.branch("refs/heads/stable").commit().create();
GitilesView view;
@@ -253,7 +265,8 @@
assertNull(getView("/repo/+show/stable..master/foo"));
}
- public void testMultipleSlashes() throws Exception {
+ @Test
+ public void multipleSlashes() throws Exception {
repo.branch("refs/heads/master").commit().create();
assertEquals(Type.HOST_INDEX, getView("//").getType());
assertEquals(Type.REPOSITORY_INDEX, getView("//repo").getType());
@@ -264,7 +277,8 @@
assertNull(getView("/repo/+//master/foo//bar"));
}
- public void testDiff() throws Exception {
+ @Test
+ public void diff() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit master = repo.branch("refs/heads/master").commit().parent(parent).create();
GitilesView view;
@@ -302,7 +316,8 @@
assertEquals("", view.getPathPart());
}
- public void testDiffAgainstEmptyCommit() throws Exception {
+ @Test
+ public void diffAgainstEmptyCommit() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
GitilesView view = getView("/repo/+diff/master^!");
assertEquals(Type.DIFF, view.getType());
@@ -312,7 +327,8 @@
assertEquals("", view.getPathPart());
}
- public void testLog() throws Exception {
+ @Test
+ public void log() throws Exception {
RevCommit parent = repo.commit().create();
RevCommit master = repo.branch("refs/heads/master").commit().parent(parent).create();
GitilesView view;
@@ -381,7 +397,8 @@
assertEquals("", view.getPathPart());
}
- public void testArchive() throws Exception {
+ @Test
+ public void archive() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
repo.branch("refs/heads/branch").commit().create();
GitilesView view;
@@ -422,7 +439,8 @@
assertEquals("foo/bar", view.getPathPart());
}
- public void testBlame() throws Exception {
+ @Test
+ public void blame() throws Exception {
RevCommit master = repo.branch("refs/heads/master").commit().create();
repo.branch("refs/heads/branch").commit().create();
GitilesView view;