diff options
author | Shawn Pearce <sop@google.com> | 2012-09-16 14:11:30 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2012-09-16 14:11:30 -0400 |
commit | 1a07ddca859de9aedd0dbb1dddb254cd2430f13e (patch) | |
tree | 98b8f9d9c066ded0a49950d07f3e8d3a9921f84f | |
parent | 28adbb350023645a9ca06af53f97d191d692a691 (diff) | |
parent | d92287bcc2745a91490490bcb7145e6ce1d3f9be (diff) | |
download | jgit-1a07ddca859de9aedd0dbb1dddb254cd2430f13e.tar.gz jgit-1a07ddca859de9aedd0dbb1dddb254cd2430f13e.zip |
Merge changes I8449695e,Idecd8018
* changes:
Use assertEquals instead of == for literal primitives
Use assertTrue/False instead of equals with boolean literals
10 files changed, 80 insertions, 76 deletions
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 07387e4fa6..5ded3bce12 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 @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.api; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Set; @@ -88,7 +90,7 @@ public class CleanCommandTest extends RepositoryTestCase { status = git.status().call(); files = status.getUntracked(); - assertTrue(files.size() == 0); + assertEquals(0, files.size()); assertTrue(cleanedFiles.contains("File2.txt")); assertTrue(cleanedFiles.contains("File3.txt")); } @@ -109,9 +111,9 @@ public class CleanCommandTest extends RepositoryTestCase { status = git.status().call(); files = status.getUntracked(); - assertTrue(files.size() == 1); + assertEquals(1, files.size()); assertTrue(cleanedFiles.contains("File3.txt")); - assertTrue(!cleanedFiles.contains("File2.txt")); + assertFalse(cleanedFiles.contains("File2.txt")); } @Test @@ -129,7 +131,7 @@ public class CleanCommandTest extends RepositoryTestCase { status = git.status().call(); files = status.getUntracked(); - assertTrue(files.size() == 2); + assertEquals(2, files.size()); assertTrue(cleanedFiles.contains("File2.txt")); assertTrue(cleanedFiles.contains("File3.txt")); } 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 6424f1c5d3..2eaec1476f 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 @@ -220,7 +220,7 @@ public class CommitAndLogCommandTests extends RepositoryTestCase { RevCommit[] parents = commit.getParents(); assertEquals(parents[0], firstSide); assertEquals(parents[1], second); - assertTrue(parents.length==2); + assertEquals(2, parents.length); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java index 9effe6022d..21ac3ad4eb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java @@ -461,7 +461,7 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(null, result.getConflicts()); - assertTrue(2 == result.getMergedCommits().length); + assertEquals(2, result.getMergedCommits().length); assertEquals(thirdCommit, result.getMergedCommits()[0]); assertEquals(secondCommit, result.getMergedCommits()[1]); @@ -523,7 +523,7 @@ public class MergeCommandTest extends RepositoryTestCase { assertEquals(null, result.getConflicts()); - assertTrue(2 == result.getMergedCommits().length); + assertEquals(2, result.getMergedCommits().length); assertEquals(thirdCommit, result.getMergedCommits()[0]); assertEquals(secondCommit, result.getMergedCommits()[1]); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java index cb34c0e87c..5afb1e8800 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java @@ -43,8 +43,6 @@ package org.eclipse.jgit.api; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.List; import org.eclipse.jgit.lib.RepositoryTestCase; @@ -80,7 +78,7 @@ public class NotesCommandTest extends RepositoryTestCase { @Test public void testListNotes() throws Exception { List<Note> notes = git.notesList().call(); - assertTrue(notes.size() == 1); + assertEquals(1, notes.size()); } @Test @@ -94,7 +92,7 @@ public class NotesCommandTest extends RepositoryTestCase { git.notesRemove().setObjectId(commit2).call(); List<Note> notes = git.notesList().call(); - assertTrue(notes.size() == 1); + assertEquals(1, notes.size()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java index 66943c242e..3553fcf43c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/fnmatch/FileNameMatcherTest.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.fnmatch; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -829,22 +830,22 @@ public class FileNameMatcherTest { final String pattern = "helloworld"; final FileNameMatcher matcher = new FileNameMatcher(pattern, null); matcher.append("helloworld"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); matcher.reset(); matcher.append("hello"); - assertEquals(false, matcher.isMatch()); - assertEquals(true, matcher.canAppendMatch()); + assertFalse(matcher.isMatch()); + assertTrue(matcher.canAppendMatch()); matcher.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); matcher.append("to much"); - assertEquals(false, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); + assertFalse(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); matcher.reset(); matcher.append("helloworld"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); } @Test @@ -853,30 +854,30 @@ public class FileNameMatcherTest { final FileNameMatcher matcher = new FileNameMatcher(pattern, null); matcher.append("hello"); final FileNameMatcher childMatcher = matcher.createMatcherForSuffix(); - assertEquals(false, matcher.isMatch()); - assertEquals(true, matcher.canAppendMatch()); - assertEquals(false, childMatcher.isMatch()); - assertEquals(true, childMatcher.canAppendMatch()); + assertFalse(matcher.isMatch()); + assertTrue(matcher.canAppendMatch()); + assertFalse(childMatcher.isMatch()); + assertTrue(childMatcher.canAppendMatch()); matcher.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(false, childMatcher.isMatch()); - assertEquals(true, childMatcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertFalse(childMatcher.isMatch()); + assertTrue(childMatcher.canAppendMatch()); childMatcher.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(true, childMatcher.isMatch()); - assertEquals(false, childMatcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertTrue(childMatcher.isMatch()); + assertFalse(childMatcher.canAppendMatch()); childMatcher.reset(); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(false, childMatcher.isMatch()); - assertEquals(true, childMatcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertFalse(childMatcher.isMatch()); + assertTrue(childMatcher.canAppendMatch()); childMatcher.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(true, childMatcher.isMatch()); - assertEquals(false, childMatcher.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertTrue(childMatcher.isMatch()); + assertFalse(childMatcher.canAppendMatch()); } @Test @@ -885,29 +886,29 @@ public class FileNameMatcherTest { final FileNameMatcher matcher = new FileNameMatcher(pattern, null); matcher.append("hello"); final FileNameMatcher copy = new FileNameMatcher(matcher); - assertEquals(false, matcher.isMatch()); - assertEquals(true, matcher.canAppendMatch()); - assertEquals(false, copy.isMatch()); - assertEquals(true, copy.canAppendMatch()); + assertFalse(matcher.isMatch()); + assertTrue(matcher.canAppendMatch()); + assertFalse(copy.isMatch()); + assertTrue(copy.canAppendMatch()); matcher.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(false, copy.isMatch()); - assertEquals(true, copy.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertFalse(copy.isMatch()); + assertTrue(copy.canAppendMatch()); copy.append("world"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(true, copy.isMatch()); - assertEquals(false, copy.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertTrue(copy.isMatch()); + assertFalse(copy.canAppendMatch()); copy.reset(); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(false, copy.isMatch()); - assertEquals(true, copy.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertFalse(copy.isMatch()); + assertTrue(copy.canAppendMatch()); copy.append("helloworld"); - assertEquals(true, matcher.isMatch()); - assertEquals(false, matcher.canAppendMatch()); - assertEquals(true, copy.isMatch()); - assertEquals(false, copy.canAppendMatch()); + assertTrue(matcher.isMatch()); + assertFalse(matcher.canAppendMatch()); + assertTrue(copy.isMatch()); + assertFalse(copy.canAppendMatch()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java index 8027f980d6..dd7d335c81 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java @@ -123,7 +123,7 @@ public class T0002_TreeTest extends SampleDataRepositoryTestCase { assertTrue("no name", t.getName() == null); assertTrue("no nameUTF8", t.getNameUTF8() == null); assertTrue("has entries array", t.members() != null); - assertTrue("entries is empty", t.members().length == 0); + assertEquals("entries is empty", 0, t.members().length); assertEquals("full name is empty", "", t.getFullName()); assertTrue("no id", t.getId() == null); assertTrue("database is r", t.getRepository() == db); @@ -184,7 +184,7 @@ public class T0002_TreeTest extends SampleDataRepositoryTestCase { final TreeEntry[] i = t.members(); assertTrue("iterator is not empty", i.length > 0); assertTrue("iterator returns file", i[0] == f); - assertTrue("iterator is empty", i.length == 1); + assertEquals("iterator is empty", 1, i.length); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java index 95860d63f6..1eebb5002d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevFlagSetTest.java @@ -86,7 +86,7 @@ public class RevFlagSetTest extends RevWalkTestCase { public void testAddTwo() { final RevFlag flag1 = rw.newFlag("flag_1"); final RevFlag flag2 = rw.newFlag("flag_2"); - assertTrue((flag1.mask & flag2.mask) == 0); + assertEquals(0, (flag1.mask & flag2.mask)); final RevFlagSet set = new RevFlagSet(); assertTrue(set.add(flag1)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java index 965a21ce05..f262d01ea9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackWriterTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.storage.file; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -134,9 +135,9 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { @Test public void testContructor() throws IOException { writer = new PackWriter(config, db.newObjectReader()); - assertEquals(false, writer.isDeltaBaseAsOffset()); - assertEquals(true, config.isReuseDeltas()); - assertEquals(true, config.isReuseObjects()); + assertFalse(writer.isDeltaBaseAsOffset()); + assertTrue(config.isReuseDeltas()); + assertTrue(config.isReuseObjects()); assertEquals(0, writer.getObjectCount()); } @@ -148,14 +149,14 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { config.setReuseDeltas(false); config.setReuseObjects(false); config.setDeltaBaseAsOffset(false); - assertEquals(false, config.isReuseDeltas()); - assertEquals(false, config.isReuseObjects()); - assertEquals(false, config.isDeltaBaseAsOffset()); + assertFalse(config.isReuseDeltas()); + assertFalse(config.isReuseObjects()); + assertFalse(config.isDeltaBaseAsOffset()); writer = new PackWriter(config, db.newObjectReader()); writer.setDeltaBaseAsOffset(true); - assertEquals(true, writer.isDeltaBaseAsOffset()); - assertEquals(false, config.isDeltaBaseAsOffset()); + assertTrue(writer.isDeltaBaseAsOffset()); + assertFalse(config.isDeltaBaseAsOffset()); } /** diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java index 2a9bb7a56e..12c634909f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_BasicTest.java @@ -399,7 +399,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { try { assertEquals(0x78, xis.readUInt8()); assertEquals(0x9c, xis.readUInt8()); - assertTrue(0x789c % 31 == 0); + assertEquals(0, 0x789c % 31); } finally { xis.close(); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java index c079234593..cb527c1712 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java @@ -44,8 +44,10 @@ package org.eclipse.jgit.transport; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileOutputStream; @@ -228,7 +230,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { public void testAlias_BatchModeDefault() throws Exception { final Host h = osc.lookup("orcz"); assertNotNull(h); - assertEquals(false, h.isBatchMode()); + assertFalse(h.isBatchMode()); } @Test @@ -236,7 +238,7 @@ public class OpenSshConfigTest extends RepositoryTestCase { config("Host orcz\n" + "\tBatchMode yes\n"); final Host h = osc.lookup("orcz"); assertNotNull(h); - assertEquals(true, h.isBatchMode()); + assertTrue(h.isBatchMode()); } @Test @@ -245,6 +247,6 @@ public class OpenSshConfigTest extends RepositoryTestCase { + "\tBatchMode yes\n"); final Host h = osc.lookup("orcz"); assertNotNull(h); - assertEquals(true, h.isBatchMode()); + assertTrue(h.isBatchMode()); } } |