diff --git a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java index f3b6cf765..ec2f0403d 100644 --- a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java @@ -17,9 +17,9 @@ package org.apache.commons.lang3.text; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.text.FieldPosition; import java.text.Format; @@ -71,8 +71,8 @@ public Object parseObject(final String source, final ParsePosition pos) { composite.parseObject("", null); composite.format(new Object(), new StringBuffer(), null); - assertEquals( "Parser get method incorrectly implemented", parser, composite.getParser() ); - assertEquals( "Formatter get method incorrectly implemented", formatter, composite.getFormatter() ); + assertEquals(parser, composite.getParser(), "Parser get method incorrectly implemented"); + assertEquals(formatter, composite.getFormatter(), "Formatter get method incorrectly implemented"); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java index 823c34730..6185f3bde 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -16,12 +16,12 @@ */ package org.apache.commons.lang3.text; -import org.junit.Test; -import org.junit.Before; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.text.DateFormat; import java.text.FieldPosition; @@ -47,7 +47,7 @@ public class ExtendedMessageFormatTest { private final Map registry = new HashMap<>(); - @Before + @BeforeEach public void setUp() throws Exception { registry.put("lower", new LowerCaseFormatFactory()); registry.put("upper", new UpperCaseFormatFactory()); @@ -60,12 +60,12 @@ public void setUp() throws Exception { public void testExtendedFormats() { final String pattern = "Lower: {0,lower} Upper: {1,upper}"; final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry); - assertEquals("TOPATTERN", pattern, emf.toPattern()); - assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"foo", "bar"})); - assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"Foo", "Bar"})); - assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"FOO", "BAR"})); - assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"FOO", "bar"})); - assertEquals("Lower: foo Upper: BAR", emf.format(new Object[] {"foo", "BAR"})); + assertEquals(pattern, emf.toPattern(), "TOPATTERN"); + assertEquals(emf.format(new Object[] {"foo", "bar"}), "Lower: foo Upper: BAR"); + assertEquals(emf.format(new Object[] {"Foo", "Bar"}), "Lower: foo Upper: BAR"); + assertEquals(emf.format(new Object[] {"FOO", "BAR"}), "Lower: foo Upper: BAR"); + assertEquals(emf.format(new Object[] {"FOO", "bar"}), "Lower: foo Upper: BAR"); + assertEquals(emf.format(new Object[] {"foo", "BAR"}), "Lower: foo Upper: BAR"); } /** @@ -143,8 +143,8 @@ public void testExtendedAndBuiltInFormats() { expected.append(df.format(args[1])); expected.append(" Salary: "); expected.append(nf.format(args[2])); - assertEquals("pattern comparison for locale " + locale, expectedPattern, emf.toPattern()); - assertEquals(String.valueOf(locale), expected.toString(), emf.format(args)); + assertEquals(expectedPattern, emf.toPattern(), "pattern comparison for locale " + locale); + assertEquals(expected.toString(), emf.format(args), String.valueOf(locale)); } } @@ -268,8 +268,8 @@ public void testOverriddenBuiltinFormat() { final MessageFormat dateDefault = createMessageFormat("{0,date}", locale); final String pattern = "{0,date,short}"; final ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, dateRegistry); - assertEquals("overridden date,short format", dateDefault.format(args), dateShort.format(args)); - assertEquals("overridden date,short pattern", pattern, dateShort.toPattern()); + assertEquals(dateDefault.format(args), dateShort.format(args), "overridden date,short format"); + assertEquals(pattern, dateShort.toPattern(), "overridden date,short pattern"); } } @@ -301,33 +301,33 @@ public void testEqualsHashcode() { ExtendedMessageFormat other = null; // Same object - assertTrue("same, equals()", emf.equals(emf)); - assertTrue("same, hashcode()", emf.hashCode() == emf.hashCode()); + assertTrue(emf.equals(emf), "same, equals()"); + assertTrue(emf.hashCode() == emf.hashCode(), "same, hashcode()"); // Equal Object other = new ExtendedMessageFormat(pattern, Locale.US, fmtRegistry); - assertTrue("equal, equals()", emf.equals(other)); - assertTrue("equal, hashcode()", emf.hashCode() == other.hashCode()); + assertTrue(emf.equals(other), "equal, equals()"); + assertTrue(emf.hashCode() == other.hashCode(), "equal, hashcode()"); // Different Class other = new OtherExtendedMessageFormat(pattern, Locale.US, fmtRegistry); - assertFalse("class, equals()", emf.equals(other)); - assertTrue("class, hashcode()", emf.hashCode() == other.hashCode()); // same hashcode + assertFalse(emf.equals(other), "class, equals()"); + assertTrue(emf.hashCode() == other.hashCode(), "class, hashcode()"); // same hashcode // Different pattern other = new ExtendedMessageFormat("X" + pattern, Locale.US, fmtRegistry); - assertFalse("pattern, equals()", emf.equals(other)); - assertFalse("pattern, hashcode()", emf.hashCode() == other.hashCode()); + assertFalse(emf.equals(other), "pattern, equals()"); + assertFalse(emf.hashCode() == other.hashCode(), "pattern, hashcode()"); // Different registry other = new ExtendedMessageFormat(pattern, Locale.US, otherRegitry); - assertFalse("registry, equals()", emf.equals(other)); - assertFalse("registry, hashcode()", emf.hashCode() == other.hashCode()); + assertFalse(emf.equals(other), "registry, equals()"); + assertFalse(emf.hashCode() == other.hashCode(), "registry, hashcode()"); // Different Locale other = new ExtendedMessageFormat(pattern, Locale.FRANCE, fmtRegistry); - assertFalse("locale, equals()", emf.equals(other)); - assertTrue("locale, hashcode()", emf.hashCode() == other.hashCode()); // same hashcode + assertFalse(emf.equals(other), "locale, equals()"); + assertTrue(emf.hashCode() == other.hashCode(), "locale, hashcode()"); // same hashcode } /** @@ -376,8 +376,8 @@ private void checkBuiltInFormat(final String pattern, final Map regis } else { emf = new ExtendedMessageFormat(pattern, locale); } - assertEquals("format " + buffer.toString(), mf.format(args), emf.format(args)); - assertEquals("toPattern " + buffer.toString(), mf.toPattern(), emf.toPattern()); + assertEquals(mf.format(args), emf.format(args), "format " + buffer.toString()); + assertEquals(mf.toPattern(), emf.toPattern(), "toPattern " + buffer.toString()); } /** diff --git a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java index 1c88fd4c7..139403684 100644 --- a/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/FormattableUtilsTest.java @@ -17,11 +17,12 @@ package org.apache.commons.lang3.text; import static java.util.FormattableFlags.LEFT_JUSTIFY; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.Formatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit tests {@link FormattableUtils}. @@ -83,9 +84,9 @@ public void testEllipsis() { assertEquals("+* ", FormattableUtils.append("foo", new Formatter(), LEFT_JUSTIFY, 5, 2, "+*").toString()); } - @Test(expected=IllegalArgumentException.class) + @Test public void testIllegalEllipsis() { - FormattableUtils.append("foo", new Formatter(), 0, -1, 1, "xx"); + assertThrows(IllegalArgumentException.class, () -> FormattableUtils.append("foo", new Formatter(), 0, -1, 1, "xx")); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java index 60d99376f..8421bd45b 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java @@ -17,10 +17,10 @@ package org.apache.commons.lang3.text; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.text.DecimalFormatSymbols; import java.util.Arrays; diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index a17782d5e..c8d4d16f2 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -17,16 +17,16 @@ package org.apache.commons.lang3.text; -import org.junit.Test; +import org.junit.jupiter.api.Test; -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.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.Reader; @@ -479,13 +479,13 @@ public void testToCharArray() { assertEquals(ArrayUtils.EMPTY_CHAR_ARRAY, sb.toCharArray()); char[] a = sb.toCharArray(); - assertNotNull("toCharArray() result is null", a); - assertEquals("toCharArray() result is too large", 0, a.length); + assertNotNull(a, "toCharArray() result is null"); + assertEquals(0, a.length, "toCharArray() result is too large"); sb.append("junit"); a = sb.toCharArray(); - assertEquals("toCharArray() result incorrect length", 5, a.length); - assertTrue("toCharArray() result does not match", Arrays.equals("junit".toCharArray(), a)); + assertEquals(5, a.length, "toCharArray() result incorrect length"); + assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray() result does not match"); } @Test @@ -495,19 +495,19 @@ public void testToCharArrayIntInt() { sb.append("junit"); char[] a = sb.toCharArray(0, 20); // too large test - assertEquals("toCharArray(int,int) result incorrect length", 5, a.length); - assertTrue("toCharArray(int,int) result does not match", Arrays.equals("junit".toCharArray(), a)); + assertEquals(5, a.length, "toCharArray(int,int) result incorrect length"); + assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray(int,int) result does not match"); a = sb.toCharArray(0, 4); - assertEquals("toCharArray(int,int) result incorrect length", 4, a.length); - assertTrue("toCharArray(int,int) result does not match", Arrays.equals("juni".toCharArray(), a)); + assertEquals(4, a.length, "toCharArray(int,int) result incorrect length"); + assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match"); a = sb.toCharArray(0, 4); - assertEquals("toCharArray(int,int) result incorrect length", 4, a.length); - assertTrue("toCharArray(int,int) result does not match", Arrays.equals("juni".toCharArray(), a)); + assertEquals(4, a.length, "toCharArray(int,int) result incorrect length"); + assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match"); a = sb.toCharArray(0, 1); - assertNotNull("toCharArray(int,int) result is null", a); + assertNotNull(a, "toCharArray(int,int) result is null"); try { sb.toCharArray(-1, 5); @@ -1927,8 +1927,8 @@ public void testIndexOfLang294() { public void testLang295() { final StrBuilder sb = new StrBuilder("onetwothree"); sb.deleteFirst("three"); - assertFalse( "The contains(char) method is looking beyond the end of the string", sb.contains('h')); - assertEquals( "The indexOf(char) method is looking beyond the end of the string", -1, sb.indexOf('h')); + assertFalse(sb.contains('h'), "The contains(char) method is looking beyond the end of the string"); + assertEquals(-1, sb.indexOf('h'), "The indexOf(char) method is looking beyond the end of the string"); } //----------------------------------------------------------------------- @@ -1936,14 +1936,14 @@ public void testLang295() { public void testLang412Right() { final StrBuilder sb = new StrBuilder(); sb.appendFixedWidthPadRight(null, 10, '*'); - assertEquals( "Failed to invoke appendFixedWidthPadRight correctly", "**********", sb.toString()); + assertEquals("**********", sb.toString(), "Failed to invoke appendFixedWidthPadRight correctly"); } @Test public void testLang412Left() { final StrBuilder sb = new StrBuilder(); sb.appendFixedWidthPadLeft(null, 10, '*'); - assertEquals( "Failed to invoke appendFixedWidthPadLeft correctly", "**********", sb.toString()); + assertEquals("**********", sb.toString(), "Failed to invoke appendFixedWidthPadLeft correctly"); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java index 47a2d58d1..f6eacb7a0 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrLookupTest.java @@ -17,15 +17,15 @@ package org.apache.commons.lang3.text; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test class for StrLookup. @@ -70,7 +70,7 @@ public void testSystemPropertiesLookupReplacedProperties() { newProps.setProperty(osName, newOsName); System.setProperties(newProps); try { - assertEquals("Changed properties not detected", newOsName, sysLookup.lookup(osName)); + assertEquals(newOsName, sysLookup.lookup(osName), "Changed properties not detected"); } finally { System.setProperties(oldProperties); } @@ -89,7 +89,7 @@ public void testSystemPropertiesLookupUpdatedProperty() { final StrLookup sysLookup = StrLookup.systemPropertiesLookup(); System.setProperty(osName, newOsName); try { - assertEquals("Changed properties not detected", newOsName, sysLookup.lookup(osName)); + assertEquals(newOsName, sysLookup.lookup(osName), "Changed properties not detected"); } finally { System.setProperty(osName, oldOs); } diff --git a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java index 24dd953ab..f940ac2e7 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java @@ -17,11 +17,11 @@ package org.apache.commons.lang3.text; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit tests for {@link org.apache.commons.lang3.text.StrMatcher}. diff --git a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java index 78c550044..bd402650b 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrSubstitutorTest.java @@ -17,21 +17,21 @@ package org.apache.commons.lang3.text; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.HashMap; import java.util.Map; import java.util.Properties; import org.apache.commons.lang3.mutable.MutableObject; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test class for StrSubstitutor. @@ -41,14 +41,14 @@ public class StrSubstitutorTest { private Map values; - @Before + @BeforeEach public void setUp() throws Exception { values = new HashMap<>(); values.put("animal", "quick brown fox"); values.put("target", "lazy dog"); } - @After + @AfterEach public void tearDown() throws Exception { values = null; } @@ -308,18 +308,18 @@ public void testReplaceInVariable() { final StrSubstitutor sub = new StrSubstitutor(values); sub.setEnableSubstitutionInVariables(true); assertEquals( - "Wrong result (1)", "The mouse jumps over the lazy dog.", - sub.replace("The ${animal.${species}} jumps over the ${target}.")); + sub.replace("The ${animal.${species}} jumps over the ${target}."), + "Wrong result (1)"); values.put("species", "1"); assertEquals( - "Wrong result (2)", "The fox jumps over the lazy dog.", - sub.replace("The ${animal.${species}} jumps over the ${target}.")); + sub.replace("The ${animal.${species}} jumps over the ${target}."), + "Wrong result (2)"); assertEquals( - "Wrong result (3)", "The fox jumps over the lazy dog.", - sub.replace("The ${unknown.animal.${unknown.species:-1}:-fox} jumps over the ${unknown.target:-lazy dog}.")); + sub.replace("The ${unknown.animal.${unknown.species:-1}:-fox} jumps over the ${unknown.target:-lazy dog}."), + "Wrong result (3)"); } /** @@ -332,13 +332,13 @@ public void testReplaceInVariableDisabled() { values.put("species", "2"); final StrSubstitutor sub = new StrSubstitutor(values); assertEquals( - "Wrong result (1)", "The ${animal.${species}} jumps over the lazy dog.", - sub.replace("The ${animal.${species}} jumps over the ${target}.")); + sub.replace("The ${animal.${species}} jumps over the ${target}."), + "Wrong result (1)"); assertEquals( - "Wrong result (2)", "The ${animal.${species:-1}} jumps over the lazy dog.", - sub.replace("The ${animal.${species:-1}} jumps over the ${target}.")); + sub.replace("The ${animal.${species:-1}} jumps over the ${target}."), + "Wrong result (2)"); } /** @@ -354,13 +354,13 @@ public void testReplaceInVariableRecursive() { final StrSubstitutor sub = new StrSubstitutor(values); sub.setEnableSubstitutionInVariables(true); assertEquals( - "Wrong result (1)", "The white mouse jumps over the lazy dog.", - sub.replace("The ${animal.${species.${color}}} jumps over the ${target}.")); + sub.replace("The ${animal.${species.${color}}} jumps over the ${target}."), + "Wrong result (1)"); assertEquals( - "Wrong result (2)", "The brown fox jumps over the lazy dog.", - sub.replace("The ${animal.${species.${unknownColor:-brown}}} jumps over the ${target}.")); + sub.replace("The ${animal.${species.${unknownColor:-brown}}} jumps over the ${target}."), + "Wrong result (2)"); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java index 7ee0ae864..9c7d15da3 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java @@ -17,13 +17,13 @@ package org.apache.commons.lang3.text; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Arrays; import java.util.Collections; @@ -61,10 +61,10 @@ public void test1() { final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -82,10 +82,10 @@ public void test2() { final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -103,10 +103,10 @@ public void test3() { final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -124,10 +124,10 @@ public void test4() { final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -146,10 +146,10 @@ public void test5() { final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null,}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -180,13 +180,13 @@ public void test6() { prevCount++; } - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); - assertTrue("could not cycle through entire token list" + " using the 'hasNext' and 'next' methods", - nextCount == expected.length); + assertTrue(nextCount == expected.length, + "could not cycle through entire token list" + " using the 'hasNext' and 'next' methods"); - assertTrue("could not cycle through entire token list" + " using the 'hasPrevious' and 'previous' methods", - prevCount == expected.length); + assertTrue(prevCount == expected.length, + "could not cycle through entire token list" + " using the 'hasPrevious' and 'previous' methods"); } @@ -203,10 +203,10 @@ public void test7() { final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } @@ -224,10 +224,10 @@ public void test8() { final String expected[] = new String[]{"a", "b", "c", "d e", "f",}; - assertEquals(ArrayUtils.toString(tokens), expected.length, tokens.length); + assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens)); for (int i = 0; i < expected.length; i++) { - assertEquals("token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'", - expected[i], tokens[i]); + assertEquals(expected[i], tokens[i], + "token[" + i + "] was '" + tokens[i] + "' but was expected to be '" + expected[i] + "'"); } } diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java index d99a97b1d..6d1749252 100644 --- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java @@ -16,16 +16,16 @@ */ package org.apache.commons.lang3.text; -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 static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit tests for WordUtils class. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java index 7cb65f88d..41610e5f3 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java @@ -17,12 +17,12 @@ package org.apache.commons.lang3.text.translate; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit tests for {@link org.apache.commons.lang3.text.translate.EntityArrays}. @@ -42,8 +42,8 @@ public void testHTML40_EXTENDED_ESCAPE(){ final Set col1 = new HashSet<>(); final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE(); for(int i =0; i