]> source.dussan.org Git - jgit.git/commitdiff
Replace deprecated junit assertion methods with hamcrest 64/156364/2
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 21 Jan 2020 16:50:57 +0000 (17:50 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Jan 2020 17:16:17 +0000 (18:16 +0100)
Change-Id: Icebe8071eeefbc13d3bdbc231c568209cdc26195
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 files changed:
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffEntryTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPackRefsTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackInserterTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/reftable/ReftableTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportHttpTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackReachabilityTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackRefSortingForReachabilityTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/LRUMapTest.java

index 7b1428849ac508badc27a5be5b7f8e1c7a5c31c6..96657761cf461d26919da294dff25faeaeb1db8f 100644 (file)
 
 package org.eclipse.jgit.http.test;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 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.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
index 3886c159585581fd5a06ac17264f4945fa37a1ae..f8c7dae7df4c760545e05da160b93105d045fc8a 100644 (file)
@@ -13,9 +13,9 @@ import static org.eclipse.jgit.diff.DiffEntry.DEV_NULL;
 import static org.eclipse.jgit.util.FileUtils.delete;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -26,8 +26,8 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType;
 import org.eclipse.jgit.dircache.DirCache;
 import org.eclipse.jgit.dircache.DirCacheEditor;
 import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit;
-import org.eclipse.jgit.internal.storage.file.FileRepository;
 import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
 import org.eclipse.jgit.junit.JGitTestUtil;
 import org.eclipse.jgit.junit.RepositoryTestCase;
 import org.eclipse.jgit.lib.FileMode;
index 74f1aea6fc6965a506dcc4c3a1c1a9987155041c..8baa3cc3413744165fcb516a27edc93902d345fa 100644 (file)
 
 package org.eclipse.jgit.internal.storage.file;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.lessThanOrEqualTo;
 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.assertSame;
-import static org.junit.Assert.assertThat;
 
 import java.io.File;
 import java.io.IOException;
index 8e438bc0e042c0f13e523fc08c204dcafcf52a37..8c56480fe14053a5c2f2661841bcb4df0ae18df4 100644 (file)
@@ -45,15 +45,14 @@ package org.eclipse.jgit.internal.storage.file;
 
 import static java.util.Comparator.comparing;
 import static java.util.stream.Collectors.toList;
-
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.lessThan;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
index 65c48ad895755f05414996bd31c7e84ce52b693c..009914b35c452f97eb9582920df5444dcf5aa822 100644 (file)
@@ -16,12 +16,12 @@ import static org.eclipse.jgit.lib.Constants.R_HEADS;
 import static org.eclipse.jgit.lib.Ref.Storage.NEW;
 import static org.eclipse.jgit.lib.Ref.Storage.PACKED;
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
 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.assertSame;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
index 5a7a034ad0ecb249044f963f7544b6434c07f06b..6c8c3ba61b6cec1af24b4eb1caded3f7958f4721 100644 (file)
@@ -9,6 +9,10 @@
  */
 package org.eclipse.jgit.internal.transport.http;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
@@ -27,10 +31,8 @@ import java.util.Set;
 import java.util.regex.Pattern;
 
 import org.eclipse.jgit.internal.storage.file.LockFile;
-import org.eclipse.jgit.internal.transport.http.NetscapeCookieFile;
 import org.eclipse.jgit.util.http.HttpCookiesMatcher;
 import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -81,11 +83,10 @@ public class NetscapeCookieFileTest {
                cookie = new HttpCookie("key3", "valueFromSet2");
                cookiesExpectedMergedSet.add(cookie);
 
-               Assert.assertThat(
-                               NetscapeCookieFile.mergeCookies(cookieSet1, cookieSet2),
+               assertThat(NetscapeCookieFile.mergeCookies(cookieSet1, cookieSet2),
                                HttpCookiesMatcher.containsInOrder(cookiesExpectedMergedSet));
 
-               Assert.assertThat(NetscapeCookieFile.mergeCookies(cookieSet1, null),
+               assertThat(NetscapeCookieFile.mergeCookies(cookieSet1, null),
                                HttpCookiesMatcher.containsInOrder(cookieSet1));
        }
 
@@ -110,8 +111,7 @@ public class NetscapeCookieFileTest {
                String expectedExpiration = String
                                .valueOf(creationDate.getTime() + (cookie.getMaxAge() * 1000));
 
-               Assert.assertThat(
-                               Files.readAllLines(tmpFile, StandardCharsets.US_ASCII),
+               assertThat(Files.readAllLines(tmpFile, StandardCharsets.US_ASCII),
                                CoreMatchers
                                                .equalTo(Arrays.asList("mydomain.com\tTRUE\t/\tTRUE\t"
                                                                + expectedExpiration + "\tkey2\tvalue")));
@@ -136,8 +136,7 @@ public class NetscapeCookieFileTest {
                String expectedExpiration = String
                                .valueOf(creationDate.getTime() + (cookie.getMaxAge() * 1000));
 
-               Assert.assertThat(
-                               Files.readAllLines(tmpFile, StandardCharsets.US_ASCII),
+               assertThat(Files.readAllLines(tmpFile, StandardCharsets.US_ASCII),
                                CoreMatchers.equalTo(
                                                Arrays.asList("domain.com\tTRUE\t/my/path\tFALSE\t"
                                                                + expectedExpiration + "\tkey2\tvalue2")));
@@ -154,7 +153,7 @@ public class NetscapeCookieFileTest {
                // now imitate another process/thread holding the lock file
                LockFile lockFile = new LockFile(tmpFile.toFile());
                try {
-                       Assert.assertTrue("Could not acquire lock", lockFile.lock());
+                       assertTrue("Could not acquire lock", lockFile.lock());
                        cookieFile.write(baseUrl);
                } finally {
                        lockFile.unlock();
@@ -184,7 +183,7 @@ public class NetscapeCookieFileTest {
                List<String> lines = Files.readAllLines(tmpFile,
                                StandardCharsets.US_ASCII);
 
-               Assert.assertEquals("Expected 3 lines", 3, lines.size());
+               assertEquals("Expected 3 lines", 3, lines.size());
                assertStringMatchesPatternWithInexactNumber(lines.get(0),
                                "some-domain1\tTRUE\t/some/path1\tFALSE\t(\\d*)\tkey1\tvalueFromSimple2",
                                JAN_01_2030_NOON, 1000);
@@ -202,12 +201,12 @@ public class NetscapeCookieFileTest {
                        long delta) {
                java.util.regex.Matcher matcher = Pattern.compile(pattern)
                                .matcher(string);
-               Assert.assertTrue("Given string '" + string + "' does not match '"
-                               + pattern + "'", matcher.matches());
+               assertTrue("Given string '" + string + "' does not match '" + pattern
+                               + "'", matcher.matches());
                // extract numeric value
                Long actualNumericValue = Long.decode(matcher.group(1));
 
-               Assert.assertTrue(
+               assertTrue(
                                "Value is supposed to be close to " + expectedNumericValue
                                                + " but is " + actualNumericValue + ".",
                                Math.abs(expectedNumericValue - actualNumericValue) <= delta);
@@ -238,8 +237,7 @@ public class NetscapeCookieFileTest {
                }
                Set<HttpCookie> actualCookies = new NetscapeCookieFile(tmpFile,
                                creationDate).getCookies(true);
-               Assert.assertThat(actualCookies,
-                               HttpCookiesMatcher.containsInOrder(cookies));
+               assertThat(actualCookies, HttpCookiesMatcher.containsInOrder(cookies));
        }
 
        @Test
@@ -259,8 +257,7 @@ public class NetscapeCookieFileTest {
                        NetscapeCookieFile.write(writer, cookies, baseUrl, creationDate);
                }
                // compare original file with newly written one, they should not differ
-               Assert.assertEquals(Files.readAllLines(tmpFile),
-                               Files.readAllLines(tmpFile2));
+               assertEquals(Files.readAllLines(tmpFile), Files.readAllLines(tmpFile2));
        }
 
        @Test
@@ -289,8 +286,7 @@ public class NetscapeCookieFileTest {
 
                Set<HttpCookie> actualCookies = new NetscapeCookieFile(tmpFile, creationDate)
                                .getCookies(true);
-               Assert.assertThat(actualCookies,
-                               HttpCookiesMatcher.containsInOrder(cookies));
+               assertThat(actualCookies, HttpCookiesMatcher.containsInOrder(cookies));
        }
 
        @Test
index 32dc7eb122602b2df77a4b89db253c67a243f493..cec69c49981b133fa3fce99286f7b03f5e602364 100644 (file)
 package org.eclipse.jgit.lib;
 
 import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
index b55c91f34fcaddfb82e4e58416c48ff5db2e648c..965a2faf8ee51553fc430a28ec80ec0ece3fcc3c 100644 (file)
@@ -10,8 +10,8 @@
 package org.eclipse.jgit.transport;
 
 import static org.eclipse.jgit.transport.ObjectIdMatcher.hasOnlyObjectIds;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
index e16b84fec62945a82a1e1ed01b868be1f199d63c..f9300cd0fc83ab1f1670619255823052ce1b5cb1 100644 (file)
@@ -9,12 +9,12 @@
  */
 package org.eclipse.jgit.transport;
 
+import static org.eclipse.jgit.transport.ObjectIdMatcher.hasOnlyObjectIds;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasItems;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.eclipse.jgit.transport.ObjectIdMatcher.hasOnlyObjectIds;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
index 7fe5b5981dbb60d0e829cfdd37f6beddb929b65f..b84b6b2e0b0d490459741935371adcce35be5a2f 100644 (file)
@@ -9,6 +9,8 @@
  */
 package org.eclipse.jgit.transport;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.HttpCookie;
@@ -120,7 +122,7 @@ public class TransportHttpTest extends SampleDataRepositoryTestCase {
                        cookie.setMaxAge(1234);
                        expectedCookies.add(cookie);
 
-                       Assert.assertThat(
+                       assertThat(
                                        new NetscapeCookieFile(cookieFile.toPath())
                                                        .getCookies(true),
                                        HttpCookiesMatcher.containsInOrder(expectedCookies, 5));
index d113eabd89f5e4a436524deb9242f46dc6e90661..8b4c05b802a85057805e8dc2900f2ba3d76e1dbf 100644 (file)
@@ -9,9 +9,9 @@
  */
 package org.eclipse.jgit.transport;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
index 99fe214cd1e7cee7ef3b291f88dd06e36c1abe2e..37c87057dd4f3e70a4ca30b0b0d0b752abbe77b6 100644 (file)
@@ -10,8 +10,8 @@
 
 package org.eclipse.jgit.transport;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertThat;
 
 import java.util.List;
 import java.util.stream.Collectors;
index 052cb14bf5ee41e9dba879d5e36f5cbd7fe83513..ea86563da8b68e48e1c4ec550e9d8442414cc431 100644 (file)
@@ -1,5 +1,6 @@
 package org.eclipse.jgit.transport;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasItems;
@@ -8,7 +9,6 @@ import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
index f6dd9adc08fd99c537df5b6f0497b5e9d4b070e6..c9fd0c9b1c3dc3619a10d6f6f022774566cc9d6b 100644 (file)
@@ -9,11 +9,12 @@
  */
 package org.eclipse.jgit.util;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 import org.hamcrest.collection.IsIterableContainingInOrder;
-import org.junit.Assert;
 import org.junit.Test;
 
 public class LRUMapTest {
@@ -38,8 +39,7 @@ public class LRUMapTest {
                expectedMap.put(0, 0);
                expectedMap.put(3, 3);
 
-               Assert.assertThat(map.entrySet(),
-                               IsIterableContainingInOrder
-                                               .contains(expectedMap.entrySet().toArray()));
+               assertThat(map.entrySet(), IsIterableContainingInOrder
+                               .contains(expectedMap.entrySet().toArray()));
        }
 }