summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2013-12-10 11:06:10 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2013-12-11 23:27:36 +0100
commitea04d2329d1283a3155ff26cfda7c46253f68854 (patch)
tree208a07979282c836f2378df5fe14bf10f9ae1044 /org.eclipse.jgit.test
parent3a063a0ed451f3141163745aa57e4102755cc5ef (diff)
downloadjgit-ea04d2329d1283a3155ff26cfda7c46253f68854.tar.gz
jgit-ea04d2329d1283a3155ff26cfda7c46253f68854.zip
Don't use API exception in RebaseTodoLine
This came up while testing the proposed buck build for jgit. With buck we can introduce smaller modules to allow for more concurrency during build and to better control inner structure of jgit. Trying to put the porcelain API into a different module than lower level implementation classes failed since RebaseTodoLine used a porcelain API exception causing a dependency cycle on the proposed modules. Using an exception defined on the same abstraction level fixes this problem. Change-Id: I26a5353e1a8fc23e67d8ce61309bd964f7665bcb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java150
1 files changed, 114 insertions, 36 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
index cfeba135ca..a728cd2461 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
@@ -64,13 +64,13 @@ import org.eclipse.jgit.api.RebaseCommand.InteractiveHandler;
import org.eclipse.jgit.api.RebaseCommand.Operation;
import org.eclipse.jgit.api.RebaseResult.Status;
import org.eclipse.jgit.api.errors.InvalidRebaseStepException;
-import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.errors.AmbiguousObjectException;
+import org.eclipse.jgit.errors.IllegalTodoFileModification;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.junit.RepositoryTestCase;
@@ -1953,8 +1953,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res2 = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.COMMENT); // delete
- // RevCommit c4
+ try {
+ // delete RevCommit c4
+ steps.get(0).setAction(Action.COMMENT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2083,7 +2087,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
new RebaseTodoLine("This is a invalid comment");
fail("Constructing a comment line with invalid comment string should fail, but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
RebaseTodoLine validCommentLine = new RebaseTodoLine(
@@ -2098,7 +2102,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
assertEquals(null, actionLineToBeChanged.getComment());
}
@@ -2107,7 +2111,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
try {
actionLineToBeChanged.setComment("invalid comment");
fail("Setting a invalid comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
// setting comment failed, but was successfully set before,
// therefore it may not be altered since then
@@ -2124,7 +2128,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
actionLineToBeChanged.setComment("line1 \n\r line2");
actionLineToBeChanged.setComment("\n\r");
fail("Setting a multiline comment string should fail but doesn't");
- } catch (JGitInternalException e) {
+ } catch (IllegalArgumentException e) {
// expected
}
// Try setting valid comments
@@ -2176,9 +2180,15 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
+
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
+
public String modifyCommitMessage(String commit) {
return "rewritten commit message";
}
@@ -2218,7 +2228,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
RebaseResult res = git.rebase().setUpstream("HEAD~2")
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2278,7 +2292,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2353,8 +2371,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.SQUASH);
- steps.get(2).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.SQUASH);
+ steps.get(2).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2430,8 +2452,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
- steps.get(2).setAction(Action.SQUASH);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ steps.get(2).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2500,7 +2526,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2544,7 +2574,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2579,7 +2613,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2607,7 +2645,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2634,7 +2676,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2673,7 +2719,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.EDIT);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2711,7 +2761,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2724,7 +2778,11 @@ public class RebaseCommandTest extends RepositoryTestCase {
public void prepareSteps(List<RebaseTodoLine> steps) {
steps.remove(0);
- steps.get(0).setAction(Action.REWORD);
+ try {
+ steps.get(0).setAction(Action.REWORD);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2765,9 +2823,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2779,9 +2841,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
result = git.rebase().runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.SQUASH);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.SQUASH);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2823,9 +2889,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2837,9 +2907,13 @@ public class RebaseCommandTest extends RepositoryTestCase {
result = git.rebase().runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.PICK);
- steps.remove(1);
- steps.get(1).setAction(Action.FIXUP);
+ try {
+ steps.get(0).setAction(Action.PICK);
+ steps.remove(1);
+ steps.get(1).setAction(Action.FIXUP);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {
@@ -2886,8 +2960,12 @@ public class RebaseCommandTest extends RepositoryTestCase {
.runInteractively(new InteractiveHandler() {
public void prepareSteps(List<RebaseTodoLine> steps) {
- steps.get(0).setAction(Action.EDIT);
- steps.get(1).setAction(Action.PICK);
+ try {
+ steps.get(0).setAction(Action.EDIT);
+ steps.get(1).setAction(Action.PICK);
+ } catch (IllegalTodoFileModification e) {
+ fail("unexpected exception: " + e);
+ }
}
public String modifyCommitMessage(String commit) {