Browse Source

Fix integer boxing eclipse warning

There was this warning because private assertEquals(Object, Object)
method was shadowing JUnit assertEquals methods.

Change-Id: I889bfe1d8c48210d9a42147a523c4829c5b5d1e3
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
stable-4.1
Hugo Arès 9 years ago
parent
commit
61e1645e04
  1. 37
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java

37
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java

@ -43,6 +43,7 @@
package org.eclipse.jgit.pgm; package org.eclipse.jgit.pgm;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import java.io.File; import java.io.File;
@ -59,7 +60,6 @@ import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.FileTreeIterator.FileEntry; import org.eclipse.jgit.treewalk.FileTreeIterator.FileEntry;
import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.util.FileUtils; import org.eclipse.jgit.util.FileUtils;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class CheckoutTest extends CLIRepositoryTestCase { public class CheckoutTest extends CLIRepositoryTestCase {
@ -68,7 +68,8 @@ public class CheckoutTest extends CLIRepositoryTestCase {
public void testCheckoutSelf() throws Exception { public void testCheckoutSelf() throws Exception {
new Git(db).commit().setMessage("initial commit").call(); new Git(db).commit().setMessage("initial commit").call();
assertEquals("Already on 'master'", execute("git checkout master")); assertStringArrayEquals("Already on 'master'",
execute("git checkout master"));
} }
@Test @Test
@ -76,20 +77,21 @@ public class CheckoutTest extends CLIRepositoryTestCase {
new Git(db).commit().setMessage("initial commit").call(); new Git(db).commit().setMessage("initial commit").call();
new Git(db).branchCreate().setName("side").call(); new Git(db).branchCreate().setName("side").call();
assertEquals("Switched to branch 'side'", execute("git checkout side")); assertStringArrayEquals("Switched to branch 'side'",
execute("git checkout side"));
} }
@Test @Test
public void testCheckoutNewBranch() throws Exception { public void testCheckoutNewBranch() throws Exception {
new Git(db).commit().setMessage("initial commit").call(); new Git(db).commit().setMessage("initial commit").call();
assertEquals("Switched to a new branch 'side'", assertStringArrayEquals("Switched to a new branch 'side'",
execute("git checkout -b side")); execute("git checkout -b side"));
} }
@Test @Test
public void testCheckoutNonExistingBranch() throws Exception { public void testCheckoutNonExistingBranch() throws Exception {
assertEquals( assertStringArrayEquals(
"error: pathspec 'side' did not match any file(s) known to git.", "error: pathspec 'side' did not match any file(s) known to git.",
execute("git checkout side")); execute("git checkout side"));
} }
@ -98,19 +100,20 @@ public class CheckoutTest extends CLIRepositoryTestCase {
public void testCheckoutNewBranchThatAlreadyExists() throws Exception { public void testCheckoutNewBranchThatAlreadyExists() throws Exception {
new Git(db).commit().setMessage("initial commit").call(); new Git(db).commit().setMessage("initial commit").call();
assertEquals("fatal: A branch named 'master' already exists.", assertStringArrayEquals(
"fatal: A branch named 'master' already exists.",
execute("git checkout -b master")); execute("git checkout -b master"));
} }
@Test @Test
public void testCheckoutNewBranchOnBranchToBeBorn() throws Exception { public void testCheckoutNewBranchOnBranchToBeBorn() throws Exception {
assertEquals("fatal: You are on a branch yet to be born", assertStringArrayEquals("fatal: You are on a branch yet to be born",
execute("git checkout -b side")); execute("git checkout -b side"));
} }
@Test @Test
public void testCheckoutUnresolvedHead() throws Exception { public void testCheckoutUnresolvedHead() throws Exception {
assertEquals( assertStringArrayEquals(
"error: pathspec 'HEAD' did not match any file(s) known to git.", "error: pathspec 'HEAD' did not match any file(s) known to git.",
execute("git checkout HEAD")); execute("git checkout HEAD"));
} }
@ -119,7 +122,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
public void testCheckoutHead() throws Exception { public void testCheckoutHead() throws Exception {
new Git(db).commit().setMessage("initial commit").call(); new Git(db).commit().setMessage("initial commit").call();
assertEquals("", execute("git checkout HEAD")); assertStringArrayEquals("", execute("git checkout HEAD"));
} }
@Test @Test
@ -139,10 +142,10 @@ public class CheckoutTest extends CLIRepositoryTestCase {
git.add().addFilepattern(".").call(); git.add().addFilepattern(".").call();
String[] execute = execute("git checkout branch_1"); String[] execute = execute("git checkout branch_1");
Assert.assertEquals( assertEquals(
"error: Your local changes to the following files would be overwritten by checkout:", "error: Your local changes to the following files would be overwritten by checkout:",
execute[0]); execute[0]);
Assert.assertEquals("\ta", execute[1]); assertEquals("\ta", execute[1]);
} }
/** /**
@ -193,7 +196,7 @@ public class CheckoutTest extends CLIRepositoryTestCase {
Git git = new Git(db); Git git = new Git(db);
git.commit().setMessage("initial commit").call(); git.commit().setMessage("initial commit").call();
assertEquals("Switched to a new branch 'new_branch'", assertStringArrayEquals("Switched to a new branch 'new_branch'",
execute("git checkout --orphan new_branch")); execute("git checkout --orphan new_branch"));
assertEquals("refs/heads/new_branch", db.getRef("HEAD").getTarget().getName()); assertEquals("refs/heads/new_branch", db.getRef("HEAD").getTarget().getName());
RevCommit commit = git.commit().setMessage("orphan commit").call(); RevCommit commit = git.commit().setMessage("orphan commit").call();
@ -553,17 +556,13 @@ public class CheckoutTest extends CLIRepositoryTestCase {
// assertEquals("a/c", exception.getConflictingPaths().get(1)); // assertEquals("a/c", exception.getConflictingPaths().get(1));
} }
static private void assertEquals(Object expected, Object actual) { static private void assertStringArrayEquals(String expected, String[] actual) {
Assert.assertEquals(expected, actual);
}
static private void assertEquals(String expected, String[] actual) {
// if there is more than one line, ignore last one if empty // if there is more than one line, ignore last one if empty
Assert.assertEquals( assertEquals(
1, 1,
actual.length > 1 && actual[actual.length - 1].equals("") ? actual.length - 1 actual.length > 1 && actual[actual.length - 1].equals("") ? actual.length - 1
: actual.length); : actual.length);
Assert.assertEquals(expected, actual[0]); assertEquals(expected, actual[0]);
} }
@Test @Test

Loading…
Cancel
Save