commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject [text] always use static imports for assertion methods
Date Sun, 15 Oct 2017 09:34:04 GMT
Repository: commons-text
Updated Branches:
  refs/heads/master 51645b4f0 -> 8f7d0494d


always use static imports for assertion methods


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/8f7d0494
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/8f7d0494
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/8f7d0494

Branch: refs/heads/master
Commit: 8f7d0494d19a54b1606d0d7779ff4754c3d66b23
Parents: 51645b4
Author: Pascal Schumacher <pascalschumacher@gmx.net>
Authored: Sun Oct 15 11:33:54 2017 +0200
Committer: Pascal Schumacher <pascalschumacher@gmx.net>
Committed: Sun Oct 15 11:33:54 2017 +0200

----------------------------------------------------------------------
 .../commons/text/AlphabetConverterTest.java     | 32 ++++++++++----------
 .../text/diff/StringsComparatorTest.java        | 10 +++---
 .../text/translate/CodePointTranslatorTest.java |  4 +--
 3 files changed, 24 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/8f7d0494/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
index bd55a9d..2f4c8a1 100644
--- a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
+++ b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
@@ -22,13 +22,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -94,11 +94,11 @@ public class AlphabetConverterTest {
     public void javadocExampleTest() throws UnsupportedEncodingException {
         final AlphabetConverter ac = createJavadocExample();
         
-        Assert.assertEquals("00", ac.encode("a"));
-        Assert.assertEquals("01", ac.encode("b"));
-        Assert.assertEquals("0d", ac.encode("c"));
-        Assert.assertEquals("d", ac.encode("d"));
-        Assert.assertEquals("00010dd", ac.encode("abcd"));
+        assertEquals("00", ac.encode("a"));
+        assertEquals("01", ac.encode("b"));
+        assertEquals("0d", ac.encode("c"));
+        assertEquals("d", ac.encode("d"));
+        assertEquals("00010dd", ac.encode("abcd"));
     }
 
     @Test
@@ -130,13 +130,13 @@ public class AlphabetConverterTest {
     public void unicodeTest() throws UnsupportedEncodingException {
         final AlphabetConverter ac = AlphabetConverter.createConverter(unicode, lower_case_english_codepoints,
doNotEncodePoints);
         
-        Assert.assertEquals(2, ac.getEncodedCharLength());
+        assertEquals(2, ac.getEncodedCharLength());
         
         final String original = "\u8a43\u8a45 \u8dce ab \u8dc3 c \u8983";
         final String encoded = ac.encode(original);
         final String decoded = ac.decode(encoded);
         
-        Assert.assertEquals("Encoded '" + original + "' into '" + encoded + "', but decoded
into '" + decoded + "'", original, decoded);
+        assertEquals("Encoded '" + original + "' into '" + encoded + "', but decoded into
'" + decoded + "'", original, decoded);
     }
 
     @Test
@@ -180,11 +180,11 @@ public class AlphabetConverterTest {
         
         final AlphabetConverter reconstructedAlphabetConverter = AlphabetConverter.createConverterFromMap(ac.getOriginalToEncoded());
         
-        Assert.assertEquals(ac, reconstructedAlphabetConverter);
-        Assert.assertEquals(ac.hashCode(), reconstructedAlphabetConverter.hashCode());
-        Assert.assertEquals(ac.toString(), reconstructedAlphabetConverter.toString());
-        Assert.assertNull(ac.encode(null)); // test null conversions
-        Assert.assertEquals("", ac.encode("")); // test empty conversion
+        assertEquals(ac, reconstructedAlphabetConverter);
+        assertEquals(ac.hashCode(), reconstructedAlphabetConverter.hashCode());
+        assertEquals(ac.toString(), reconstructedAlphabetConverter.toString());
+        assertNull(ac.encode(null)); // test null conversions
+        assertEquals("", ac.encode("")); // test empty conversion
 
         // test all the trial strings
         for (final String s : strings) {
@@ -193,7 +193,7 @@ public class AlphabetConverterTest {
             // test that only encoding chars are used
             final List<Character> originalEncodingChars = Arrays.asList(encodingChars);
             for (int i = 0; i < encoded.length(); i++) {
-                Assert.assertTrue(originalEncodingChars.contains(encoded.charAt(i)));
+                assertTrue(originalEncodingChars.contains(encoded.charAt(i)));
             }
 
             final String decoded = ac.decode(encoded);
@@ -201,10 +201,10 @@ public class AlphabetConverterTest {
             // test that only the original alphabet is used after decoding
             final List<Character> originalCharsList = Arrays.asList(originalChars);
             for (int i = 0; i < decoded.length(); i++) {
-                Assert.assertTrue(originalCharsList.contains(decoded.charAt(i)));
+                assertTrue(originalCharsList.contains(decoded.charAt(i)));
             }
             
-            Assert.assertEquals("Encoded '" + s + "' into '" + encoded + "', but decoded
into '" + decoded + "'", s, decoded);
+            assertEquals("Encoded '" + s + "' into '" + encoded + "', but decoded into '"
+ decoded + "'", s, decoded);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-text/blob/8f7d0494/src/test/java/org/apache/commons/text/diff/StringsComparatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/diff/StringsComparatorTest.java b/src/test/java/org/apache/commons/text/diff/StringsComparatorTest.java
index ddf0f2f..bd91a21 100644
--- a/src/test/java/org/apache/commons/text/diff/StringsComparatorTest.java
+++ b/src/test/java/org/apache/commons/text/diff/StringsComparatorTest.java
@@ -19,9 +19,11 @@ import java.util.Arrays;
 import java.util.List;
 
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
 /**
  * Tests for the StringsComparator.
  */
@@ -34,14 +36,14 @@ public class StringsComparatorTest {
     public void testLength() {
         for (int i = 0; i < before.size(); ++i) {
             final StringsComparator comparator =  new StringsComparator(before.get(i), after.get(i));
-            Assert.assertEquals(length[i], comparator.getScript().getModifications());
+            assertEquals(length[i], comparator.getScript().getModifications());
         }
     }
     @Test
     public void testLongestCommonSubsequence() {
         for (int i = 0; i < before.size(); ++i) {
             final StringsComparator comparator =  new StringsComparator(before.get(i), after.get(i));
-            Assert.assertEquals(lcs[i], comparator.getScript().getLCSLength());
+            assertEquals(lcs[i], comparator.getScript().getLCSLength());
         }
     }
     @Test
@@ -49,7 +51,7 @@ public class StringsComparatorTest {
         for (int i = 0; i < before.size(); ++i) {
             final ExecutionVisitor<Character> ev = new ExecutionVisitor<>();
             new StringsComparator(before.get(i), after.get(i)).getScript().visit(ev);
-            Assert.assertEquals(after.get(i), ev.getString());
+            assertEquals(after.get(i), ev.getString());
         }
     }
     private class ExecutionVisitor<T> implements CommandVisitor<T> {

http://git-wip-us.apache.org/repos/asf/commons-text/blob/8f7d0494/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
b/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
index c3ebefa..3d90bb5 100644
--- a/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
@@ -16,13 +16,13 @@
  */
 package org.apache.commons.text.translate;
 
-import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.io.PipedReader;
 import java.io.PipedWriter;
 
+import static org.junit.Assert.assertEquals;
 
 public class CodePointTranslatorTest {
 
@@ -34,7 +34,7 @@ public class CodePointTranslatorTest {
     final PipedReader pipedReader = new PipedReader();
     final PipedWriter pipedWriter = new PipedWriter(pipedReader);
 
-    Assert.assertEquals(1, numericEntityEscaper.translate(string, 0, pipedWriter));
+    assertEquals(1, numericEntityEscaper.translate(string, 0, pipedWriter));
   }
 
 }
\ No newline at end of file


Mime
View raw message