diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-05-30 02:07:25 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-05-30 22:08:49 +0200 |
commit | 4e1454ded6e2fcf6cb789c004756883c3ea5f77e (patch) | |
tree | 413bd8a7185dd31c6bcd942099091b3d2222d02e /org.eclipse.jgit.test | |
parent | 629e7cd926779871e9c0d6306e4c184ac67da864 (diff) | |
download | jgit-4e1454ded6e2fcf6cb789c004756883c3ea5f77e.tar.gz jgit-4e1454ded6e2fcf6cb789c004756883c3ea5f77e.zip |
Git API does not declare GitAPIException call() and related cleanups
All commands should throw a GitAPIException so new exceptions can be
added without breaking the builds of old code, i.e. anyone that calls
a Git API should catch GitAPIException and not just the currently known
exceptions.
Now the only checked exceptions on Git API calls are GitException and
subclasses of it. New checked exceptions that are subclasses of
GitException may be added without breaking the API.
Javadoc for GitAPIException is declared on GitCommand and
inherited to subclasses. JGitInternalException is not explicitly
documented anymore.
Unfortunately this change itself breaks the API. The intention is
that it shall be possible to add new checked subclasses of
GitAPIException without breaking the API.
Bug: 366914
EGit-Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5
Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
19 files changed, 122 insertions, 165 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index 2fb228e01d..fd74098496 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java @@ -52,6 +52,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheBuilder; @@ -72,7 +73,7 @@ import org.junit.Test; public class AddCommandTest extends RepositoryTestCase { @Test - public void testAddNothing() { + public void testAddNothing() throws GitAPIException { Git git = new Git(db); try { @@ -85,7 +86,7 @@ public class AddCommandTest extends RepositoryTestCase { } @Test - public void testAddNonExistingSingleFile() throws NoFilepatternException { + public void testAddNonExistingSingleFile() throws GitAPIException { Git git = new Git(db); DirCache dc = git.add().addFilepattern("a.txt").call(); @@ -94,7 +95,7 @@ public class AddCommandTest extends RepositoryTestCase { } @Test - public void testAddExistingSingleFile() throws IOException, NoFilepatternException { + public void testAddExistingSingleFile() throws IOException, GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); @@ -112,7 +113,7 @@ public class AddCommandTest extends RepositoryTestCase { @Test public void testAddExistingSingleSmallFileWithNewLine() throws IOException, - NoFilepatternException { + GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); @@ -136,7 +137,7 @@ public class AddCommandTest extends RepositoryTestCase { @Test public void testAddExistingSingleMediumSizeFileWithNewLine() - throws IOException, NoFilepatternException { + throws IOException, GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); StringBuilder data = new StringBuilder(); @@ -165,7 +166,7 @@ public class AddCommandTest extends RepositoryTestCase { @Test public void testAddExistingSingleBinaryFile() throws IOException, - NoFilepatternException { + GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); @@ -188,7 +189,8 @@ public class AddCommandTest extends RepositoryTestCase { } @Test - public void testAddExistingSingleFileInSubDir() throws IOException, NoFilepatternException { + public void testAddExistingSingleFileInSubDir() throws IOException, + GitAPIException { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); @@ -206,7 +208,8 @@ public class AddCommandTest extends RepositoryTestCase { } @Test - public void testAddExistingSingleFileTwice() throws IOException, NoFilepatternException { + public void testAddExistingSingleFileTwice() throws IOException, + GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java index 32d2e01b24..b000fe24e5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java @@ -466,9 +466,7 @@ public class BranchCommandTest extends RepositoryTestCase { public Ref createBranch(Git actGit, String name, boolean force, String startPoint, SetupUpstreamMode mode) - throws JGitInternalException, RefAlreadyExistsException, - RefNotFoundException, - InvalidRefNameException { + throws JGitInternalException, GitAPIException { CreateBranchCommand cmd = actGit.branchCreate(); cmd.setName(name); cmd.setForce(force); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java index a51a8b4697..9060cd5307 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java @@ -56,10 +56,8 @@ import java.io.FileInputStream; import java.io.IOException; import org.eclipse.jgit.api.CheckoutResult.Status; -import org.eclipse.jgit.api.errors.CheckoutConflictException; -import org.eclipse.jgit.api.errors.InvalidRefNameException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.RefAlreadyExistsException; import org.eclipse.jgit.api.errors.RefNotFoundException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEntry; @@ -129,9 +127,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { } @Test - public void testCheckoutToNonExistingBranch() throws JGitInternalException, - RefAlreadyExistsException, InvalidRefNameException, - CheckoutConflictException { + public void testCheckoutToNonExistingBranch() throws GitAPIException { try { git.checkout().setName("badbranch").call(); fail("Should have failed"); @@ -225,8 +221,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { @Test public void testDetachedHeadOnCheckout() throws JGitInternalException, - RefAlreadyExistsException, RefNotFoundException, - InvalidRefNameException, IOException, CheckoutConflictException { + IOException, GitAPIException { CheckoutCommand co = git.checkout(); co.setName("master").call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java index a660a5292b..07387e4fa6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CleanCommandTest.java @@ -44,10 +44,10 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertTrue; -import java.io.IOException; import java.util.Set; import java.util.TreeSet; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.lib.RepositoryTestCase; import org.junit.Before; @@ -75,7 +75,7 @@ public class CleanCommandTest extends RepositoryTestCase { } @Test - public void testClean() throws NoWorkTreeException, IOException { + public void testClean() throws NoWorkTreeException, GitAPIException { // create status StatusCommand command = git.status(); Status status = command.call(); @@ -94,7 +94,8 @@ public class CleanCommandTest extends RepositoryTestCase { } @Test - public void testCleanWithPaths() throws NoWorkTreeException, IOException { + public void testCleanWithPaths() throws NoWorkTreeException, + GitAPIException { // create status StatusCommand command = git.status(); Status status = command.call(); @@ -114,7 +115,8 @@ public class CleanCommandTest extends RepositoryTestCase { } @Test - public void testCleanWithDryRun() throws NoWorkTreeException, IOException { + public void testCleanWithDryRun() throws NoWorkTreeException, + GitAPIException { // create status StatusCommand command = git.status(); Status status = command.call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index 906a8966fa..4441ea9301 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -55,6 +55,7 @@ import java.util.List; import java.util.Map; import org.eclipse.jgit.api.ListBranchCommand.ListMode; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.ConfigConstants; @@ -103,7 +104,8 @@ public class CloneCommandTest extends RepositoryTestCase { } @Test - public void testCloneRepository() throws IOException { + public void testCloneRepository() throws IOException, + JGitInternalException, GitAPIException { File directory = createTempDirectory("testCloneRepository"); CloneCommand command = Git.cloneRepository(); command.setDirectory(directory); @@ -131,7 +133,8 @@ public class CloneCommandTest extends RepositoryTestCase { } @Test - public void testCloneRepositoryWithBranch() throws IOException { + public void testCloneRepositoryWithBranch() throws IOException, + JGitInternalException, GitAPIException { File directory = createTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.cloneRepository(); command.setBranch("refs/heads/master"); @@ -178,7 +181,8 @@ public class CloneCommandTest extends RepositoryTestCase { } @Test - public void testCloneRepositoryOnlyOneBranch() throws IOException { + public void testCloneRepositoryOnlyOneBranch() throws IOException, + JGitInternalException, GitAPIException { File directory = createTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.cloneRepository(); command.setBranch("refs/heads/master"); @@ -222,7 +226,7 @@ public class CloneCommandTest extends RepositoryTestCase { @Test public void testCloneRepositoryWhenDestinationDirectoryExistsAndIsNotEmpty() - throws IOException { + throws IOException, JGitInternalException, GitAPIException { String dirName = "testCloneTargetDirectoryNotEmpty"; File directory = createTempDirectory(dirName); CloneCommand command = Git.cloneRepository(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java index e6b6a096fa..ed32e27b0a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java @@ -50,15 +50,12 @@ import static org.junit.Assert.fail; import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; + +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.NoFilepatternException; -import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.api.errors.NoMessageException; -import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.PersonIdent; @@ -77,9 +74,8 @@ import org.junit.Test; */ public class CommitAndLogCommandTests extends RepositoryTestCase { @Test - public void testSomeCommits() throws NoHeadException, NoMessageException, - ConcurrentRefUpdateException, JGitInternalException, - WrongRepositoryStateException, IOException { + public void testSomeCommits() throws JGitInternalException, IOException, + GitAPIException { // do 4 commits Git git = new Git(db); @@ -115,9 +111,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testLogWithFilter() throws IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testLogWithFilter() throws IOException, JGitInternalException, + GitAPIException { Git git = new Git(db); @@ -170,9 +165,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { // try to do a commit without specifying a message. Should fail! @Test - public void testWrongParams() throws UnmergedPathException, - NoHeadException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testWrongParams() throws GitAPIException { Git git = new Git(db); try { git.commit().setAuthor(author).call(); @@ -185,10 +178,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { // try to work with Commands after command has been invoked. Should throw // exceptions @Test - public void testMultipleInvocations() throws NoHeadException, - ConcurrentRefUpdateException, NoMessageException, - UnmergedPathException, JGitInternalException, - WrongRepositoryStateException { + public void testMultipleInvocations() throws GitAPIException { Git git = new Git(db); CommitCommand commitCmd = git.commit(); commitCmd.setMessage("initial commit").call(); @@ -211,9 +201,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testMergeEmptyBranches() throws IOException, NoHeadException, - NoMessageException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testMergeEmptyBranches() throws IOException, + JGitInternalException, GitAPIException { Git git = new Git(db); git.commit().setMessage("initial commit").call(); RefUpdate r = db.updateRef("refs/heads/side"); @@ -235,10 +224,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testAddUnstagedChanges() throws IOException, NoHeadException, - NoMessageException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException, - NoFilepatternException { + public void testAddUnstagedChanges() throws IOException, + JGitInternalException, GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); PrintWriter writer = new PrintWriter(file); @@ -268,9 +255,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testModeChange() throws IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testModeChange() throws IOException, GitAPIException { Git git = new Git(db); // create file @@ -298,10 +283,9 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testCommitRange() throws NoHeadException, NoMessageException, - UnmergedPathException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException, - IncorrectObjectTypeException, MissingObjectException { + public void testCommitRange() throws GitAPIException, + JGitInternalException, MissingObjectException, + IncorrectObjectTypeException { // do 4 commits and set the range to the second and fourth one Git git = new Git(db); git.commit().setMessage("first commit").call(); @@ -334,9 +318,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testCommitAmend() throws NoHeadException, NoMessageException, - ConcurrentRefUpdateException, JGitInternalException, - WrongRepositoryStateException, IOException { + public void testCommitAmend() throws JGitInternalException, IOException, + GitAPIException { Git git = new Git(db); git.commit().setMessage("first comit").call(); // typo git.commit().setAmend(true).setMessage("first commit").call(); @@ -357,10 +340,8 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { } @Test - public void testInsertChangeId() throws NoHeadException, - NoMessageException, - UnmergedPathException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testInsertChangeId() throws JGitInternalException, + GitAPIException { Git git = new Git(db); String messageHeader = "Some header line\n\nSome detail explanation\n"; String changeIdTemplate = "\nChange-Id: I" diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java index 8031769204..d8e1a058f7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java @@ -48,6 +48,8 @@ import static org.junit.Assert.fail; import java.io.IOException; import org.eclipse.jgit.api.ListBranchCommand.ListMode; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryTestCase; @@ -84,7 +86,7 @@ public class GitConstructionTest extends RepositoryTestCase { } @Test - public void testWrap() { + public void testWrap() throws JGitInternalException, GitAPIException { Git git = Git.wrap(db); assertEquals(1, git.branchList().call().size()); @@ -101,7 +103,8 @@ public class GitConstructionTest extends RepositoryTestCase { } @Test - public void testOpen() throws IOException { + public void testOpen() throws IOException, JGitInternalException, + GitAPIException { Git git = Git.open(db.getDirectory()); assertEquals(1, git.branchList().call().size()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java index 28236369e4..7db9ce71c1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java @@ -48,6 +48,8 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryTestCase; import org.junit.Before; @@ -62,7 +64,8 @@ public class InitCommandTest extends RepositoryTestCase { } @Test - public void testInitRepository() throws IOException { + public void testInitRepository() throws IOException, JGitInternalException, + GitAPIException { File directory = createTempDirectory("testInitRepository"); InitCommand command = new InitCommand(); command.setDirectory(directory); @@ -72,7 +75,8 @@ public class InitCommandTest extends RepositoryTestCase { } @Test - public void testInitNonEmptyRepository() throws IOException { + public void testInitNonEmptyRepository() throws IOException, + JGitInternalException, GitAPIException { File directory = createTempDirectory("testInitRepository2"); File someFile = new File(directory, "someFile"); someFile.createNewFile(); @@ -86,7 +90,8 @@ public class InitCommandTest extends RepositoryTestCase { } @Test - public void testInitBareRepository() throws IOException { + public void testInitBareRepository() throws IOException, + JGitInternalException, GitAPIException { File directory = createTempDirectory("testInitBareRepository"); InitCommand command = new InitCommand(); command.setDirectory(directory); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index 3087ca829b..f16d436d94 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -54,12 +54,8 @@ import java.io.IOException; import java.io.PrintWriter; import org.eclipse.jgit.api.ResetCommand.ResetType; -import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.NoFilepatternException; -import org.eclipse.jgit.api.errors.NoHeadException; -import org.eclipse.jgit.api.errors.NoMessageException; -import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.errors.AmbiguousObjectException; @@ -87,9 +83,8 @@ public class ResetCommandTest extends RepositoryTestCase { private DirCacheEntry prestage; - public void setupRepository() throws IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void setupRepository() throws IOException, JGitInternalException, + GitAPIException { // create initial commit git = new Git(db); @@ -138,9 +133,7 @@ public class ResetCommandTest extends RepositoryTestCase { @Test public void testHardReset() throws JGitInternalException, - AmbiguousObjectException, IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - WrongRepositoryStateException { + AmbiguousObjectException, IOException, GitAPIException { setupRepository(); ObjectId prevHead = db.resolve(Constants.HEAD); git.reset().setMode(ResetType.HARD).setRef(initialCommit.getName()) @@ -160,7 +153,7 @@ public class ResetCommandTest extends RepositoryTestCase { @Test public void testResetToNonexistingHEAD() throws JGitInternalException, - AmbiguousObjectException, IOException { + AmbiguousObjectException, IOException, GitAPIException { // create a file in the working tree of a fresh repo git = new Git(db); @@ -176,9 +169,7 @@ public class ResetCommandTest extends RepositoryTestCase { @Test public void testSoftReset() throws JGitInternalException, - AmbiguousObjectException, IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - WrongRepositoryStateException { + AmbiguousObjectException, IOException, GitAPIException { setupRepository(); ObjectId prevHead = db.resolve(Constants.HEAD); git.reset().setMode(ResetType.SOFT).setRef(initialCommit.getName()) @@ -198,9 +189,7 @@ public class ResetCommandTest extends RepositoryTestCase { @Test public void testMixedReset() throws JGitInternalException, - AmbiguousObjectException, IOException, NoFilepatternException, - NoHeadException, NoMessageException, ConcurrentRefUpdateException, - WrongRepositoryStateException { + AmbiguousObjectException, IOException, GitAPIException { setupRepository(); ObjectId prevHead = db.resolve(Constants.HEAD); git.reset().setMode(ResetType.MIXED).setRef(initialCommit.getName()) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RmCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RmCommandTest.java index d826b4c135..2eb4f22940 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RmCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RmCommandTest.java @@ -46,8 +46,8 @@ import static org.junit.Assert.assertEquals; import java.io.IOException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.lib.RepositoryTestCase; import org.junit.Before; import org.junit.Test; @@ -71,7 +71,7 @@ public class RmCommandTest extends RepositoryTestCase { @Test public void testRemove() throws JGitInternalException, - NoFilepatternException, IllegalStateException, IOException { + IllegalStateException, IOException, GitAPIException { assertEquals("[test.txt, mode:100644, content:Hello world]", indexState(CONTENT)); RmCommand command = git.rm(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java index faca7ea3ab..c9a6048695 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/StatusCommandTest.java @@ -52,13 +52,15 @@ import java.util.Set; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.lib.RepositoryTestCase; import org.junit.Test; public class StatusCommandTest extends RepositoryTestCase { @Test - public void testEmptyStatus() throws IOException { + public void testEmptyStatus() throws NoWorkTreeException, + GitAPIException { Git git = new Git(db); Status stat = git.status().call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java index 7f381e3932..b417b44851 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java @@ -48,15 +48,9 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.util.List; -import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.InvalidTagNameException; import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.NoHeadException; -import org.eclipse.jgit.api.errors.NoMessageException; -import org.eclipse.jgit.api.errors.WrongRepositoryStateException; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; -import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryTestCase; @@ -67,10 +61,7 @@ import org.junit.Test; public class TagCommandTest extends RepositoryTestCase { @Test - public void testTaggingOnHead() throws NoHeadException, NoMessageException, - ConcurrentRefUpdateException, JGitInternalException, - WrongRepositoryStateException, InvalidTagNameException, - MissingObjectException, IncorrectObjectTypeException, IOException { + public void testTaggingOnHead() throws GitAPIException, IOException { Git git = new Git(db); RevCommit commit = git.commit().setMessage("initial commit").call(); Ref tagRef = git.tag().setName("tag").call(); @@ -80,10 +71,7 @@ public class TagCommandTest extends RepositoryTestCase { } @Test - public void testTagging() throws NoHeadException, NoMessageException, - UnmergedPathException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException, - InvalidTagNameException { + public void testTagging() throws GitAPIException, JGitInternalException { Git git = new Git(db); git.commit().setMessage("initial commit").call(); RevCommit commit = git.commit().setMessage("second commit").call(); @@ -93,9 +81,7 @@ public class TagCommandTest extends RepositoryTestCase { } @Test - public void testEmptyTagName() throws NoHeadException, NoMessageException, - UnmergedPathException, ConcurrentRefUpdateException, - JGitInternalException, WrongRepositoryStateException { + public void testEmptyTagName() throws GitAPIException { Git git = new Git(db); git.commit().setMessage("initial commit").call(); try { @@ -108,10 +94,7 @@ public class TagCommandTest extends RepositoryTestCase { } @Test - public void testInvalidTagName() throws NoHeadException, - NoMessageException, UnmergedPathException, - ConcurrentRefUpdateException, JGitInternalException, - WrongRepositoryStateException { + public void testInvalidTagName() throws GitAPIException { Git git = new Git(db); git.commit().setMessage("initial commit").call(); try { @@ -123,10 +106,7 @@ public class TagCommandTest extends RepositoryTestCase { } @Test - public void testFailureOnSignedTags() throws NoHeadException, - NoMessageException, UnmergedPathException, - ConcurrentRefUpdateException, JGitInternalException, - WrongRepositoryStateException, InvalidTagNameException { + public void testFailureOnSignedTags() throws GitAPIException { Git git = new Git(db); git.commit().setMessage("initial commit").call(); try { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java index 65d0418b33..fb9cc2cbfc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java @@ -46,14 +46,8 @@ import java.io.IOException; import java.util.Arrays; import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.errors.CheckoutConflictException; -import org.eclipse.jgit.api.errors.InvalidRefNameException; -import org.eclipse.jgit.api.errors.JGitInternalException; -import org.eclipse.jgit.api.errors.RefAlreadyExistsException; -import org.eclipse.jgit.api.errors.RefNotFoundException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.dircache.InvalidPathException; -import org.eclipse.jgit.errors.IncorrectObjectTypeException; -import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.junit.MockSystemReader; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.util.SystemReader; @@ -338,20 +332,11 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase { * perform the actual test on the second checkout * @param path * to the blob, one or more levels + * @throws GitAPIException * @throws IOException - * @throws RefAlreadyExistsException - * @throws RefNotFoundException - * @throws InvalidRefNameException - * @throws MissingObjectException - * @throws IncorrectObjectTypeException - * @throws CheckoutConflictException - * @throws JGitInternalException */ - private void testMaliciousPath(boolean good, boolean secondCheckout, String... path) - throws IOException, RefAlreadyExistsException, - RefNotFoundException, InvalidRefNameException, - MissingObjectException, IncorrectObjectTypeException, - JGitInternalException, CheckoutConflictException { + private void testMaliciousPath(boolean good, boolean secondCheckout, + String... path) throws GitAPIException, IOException { Git git = new Git(db); ObjectInserter newObjectInserter; newObjectInserter = git.getRepository().newObjectInserter(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java index b7caecc2c2..dde32d7e9f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java @@ -59,7 +59,7 @@ import java.util.TreeSet; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.MergeResult; import org.eclipse.jgit.api.MergeResult.MergeStatus; -import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; @@ -139,7 +139,7 @@ public class IndexDiffTest extends RepositoryTestCase { } @Test - public void testModified() throws IOException, NoFilepatternException { + public void testModified() throws IOException, GitAPIException { writeTrashFile("file2", "file2"); writeTrashFile("dir/file3", "dir/file3"); @@ -291,8 +291,7 @@ public class IndexDiffTest extends RepositoryTestCase { } @Test - public void testUnchangedSimple() throws IOException, - NoFilepatternException { + public void testUnchangedSimple() throws IOException, GitAPIException { writeTrashFile("a.b", "a.b"); writeTrashFile("a.c", "a.c"); writeTrashFile("a=c", "a=c"); @@ -328,11 +327,10 @@ public class IndexDiffTest extends RepositoryTestCase { * used by Git. * * @throws IOException - * @throws NoFilepatternException + * @throws GitAPIException */ @Test - public void testUnchangedComplex() throws IOException, - NoFilepatternException { + public void testUnchangedComplex() throws IOException, GitAPIException { Git git = new Git(db); writeTrashFile("a.b", "a.b"); writeTrashFile("a.c", "a.c"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java index 568cd9e2bc..940a78ac4f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java @@ -53,6 +53,7 @@ import java.text.MessageFormat; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.SubmoduleAddCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; @@ -75,7 +76,7 @@ import org.junit.Test; public class SubmoduleAddTest extends RepositoryTestCase { @Test - public void commandWithNullPath() { + public void commandWithNullPath() throws GitAPIException { try { new SubmoduleAddCommand(db).setURI("uri").call(); fail("Exception not thrown"); @@ -85,7 +86,7 @@ public class SubmoduleAddTest extends RepositoryTestCase { } @Test - public void commandWithEmptyPath() { + public void commandWithEmptyPath() throws GitAPIException { try { new SubmoduleAddCommand(db).setPath("").setURI("uri").call(); fail("Exception not thrown"); @@ -95,7 +96,7 @@ public class SubmoduleAddTest extends RepositoryTestCase { } @Test - public void commandWithNullUri() { + public void commandWithNullUri() throws GitAPIException { try { new SubmoduleAddCommand(db).setPath("sub").call(); fail("Exception not thrown"); @@ -105,7 +106,7 @@ public class SubmoduleAddTest extends RepositoryTestCase { } @Test - public void commandWithEmptyUri() { + public void commandWithEmptyUri() throws GitAPIException { try { new SubmoduleAddCommand(db).setPath("sub").setURI("").call(); fail("Exception not thrown"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java index f0a0750c5c..424ad01fcb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleInitTest.java @@ -53,6 +53,7 @@ import java.io.IOException; import java.util.Collection; import org.eclipse.jgit.api.SubmoduleInitCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; @@ -73,7 +74,7 @@ import org.junit.Test; public class SubmoduleInitTest extends RepositoryTestCase { @Test - public void repositoryWithNoSubmodules() { + public void repositoryWithNoSubmodules() throws GitAPIException { SubmoduleInitCommand command = new SubmoduleInitCommand(db); Collection<String> modules = command.call(); assertNotNull(modules); @@ -82,7 +83,7 @@ public class SubmoduleInitTest extends RepositoryTestCase { @Test public void repositoryWithUninitializedModule() throws IOException, - ConfigInvalidException { + ConfigInvalidException, GitAPIException { final String path = addSubmoduleToIndex(); SubmoduleWalk generator = SubmoduleWalk.forIndex(db); @@ -156,7 +157,7 @@ public class SubmoduleInitTest extends RepositoryTestCase { @Test public void resolveOneLevelHigherRelativeUrl() throws IOException, - ConfigInvalidException { + ConfigInvalidException, GitAPIException { final String path = addSubmoduleToIndex(); String base = "git://server/repo.git"; @@ -197,7 +198,7 @@ public class SubmoduleInitTest extends RepositoryTestCase { @Test public void resolveTwoLevelHigherRelativeUrl() throws IOException, - ConfigInvalidException { + ConfigInvalidException, GitAPIException { final String path = addSubmoduleToIndex(); String base = "git://server/repo.git"; @@ -238,7 +239,7 @@ public class SubmoduleInitTest extends RepositoryTestCase { @Test public void resolveWorkingDirectoryRelativeUrl() throws IOException, - ConfigInvalidException { + GitAPIException, ConfigInvalidException { final String path = addSubmoduleToIndex(); String base = db.getWorkTree().getAbsolutePath(); @@ -281,7 +282,7 @@ public class SubmoduleInitTest extends RepositoryTestCase { @Test public void resolveInvalidParentUrl() throws IOException, - ConfigInvalidException { + ConfigInvalidException, GitAPIException { final String path = addSubmoduleToIndex(); String base = "no_slash"; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java index dc79d84259..6feefdb2d1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java @@ -53,6 +53,7 @@ import java.util.Map.Entry; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.SubmoduleStatusCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; @@ -74,7 +75,7 @@ import org.junit.Test; public class SubmoduleStatusTest extends RepositoryTestCase { @Test - public void repositoryWithNoSubmodules() { + public void repositoryWithNoSubmodules() throws GitAPIException { SubmoduleStatusCommand command = new SubmoduleStatusCommand(db); Map<String, SubmoduleStatus> statuses = command.call(); assertNotNull(statuses); @@ -82,7 +83,8 @@ public class SubmoduleStatusTest extends RepositoryTestCase { } @Test - public void repositoryWithMissingSubmodule() throws IOException { + public void repositoryWithMissingSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -113,7 +115,8 @@ public class SubmoduleStatusTest extends RepositoryTestCase { } @Test - public void repositoryWithUninitializedSubmodule() throws IOException { + public void repositoryWithUninitializedSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -152,7 +155,8 @@ public class SubmoduleStatusTest extends RepositoryTestCase { } @Test - public void repositoryWithNoHeadInSubmodule() throws IOException { + public void repositoryWithNoHeadInSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -202,7 +206,8 @@ public class SubmoduleStatusTest extends RepositoryTestCase { } @Test - public void repositoryWithNoSubmoduleRepository() throws IOException { + public void repositoryWithNoSubmoduleRepository() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -247,7 +252,8 @@ public class SubmoduleStatusTest extends RepositoryTestCase { } @Test - public void repositoryWithInitializedSubmodule() throws IOException { + public void repositoryWithInitializedSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -302,7 +308,7 @@ public class SubmoduleStatusTest extends RepositoryTestCase { @Test public void repositoryWithDifferentRevCheckedOutSubmodule() - throws IOException { + throws IOException, GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java index 4df9077ba0..3f9ad11f1d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleSyncTest.java @@ -53,6 +53,7 @@ import java.util.Map.Entry; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.SubmoduleSyncCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; @@ -73,7 +74,7 @@ import org.junit.Test; public class SubmoduleSyncTest extends RepositoryTestCase { @Test - public void repositoryWithNoSubmodules() { + public void repositoryWithNoSubmodules() throws GitAPIException { SubmoduleSyncCommand command = new SubmoduleSyncCommand(db); Map<String, String> modules = command.call(); assertNotNull(modules); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java index 9bb4a63aab..eb0cf2b0b6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleUpdateTest.java @@ -52,6 +52,7 @@ import java.util.Collection; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.SubmoduleUpdateCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; @@ -73,7 +74,7 @@ import org.junit.Test; public class SubmoduleUpdateTest extends RepositoryTestCase { @Test - public void repositoryWithNoSubmodules() { + public void repositoryWithNoSubmodules() throws GitAPIException { SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db); Collection<String> modules = command.call(); assertNotNull(modules); @@ -125,7 +126,8 @@ public class SubmoduleUpdateTest extends RepositoryTestCase { } @Test - public void repositoryWithUnconfiguredSubmodule() throws IOException { + public void repositoryWithUnconfiguredSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; @@ -159,7 +161,8 @@ public class SubmoduleUpdateTest extends RepositoryTestCase { } @Test - public void repositoryWithInitializedSubmodule() throws IOException { + public void repositoryWithInitializedSubmodule() throws IOException, + GitAPIException { final ObjectId id = ObjectId .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); final String path = "sub"; |