You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/06/09 16:49:04 UTC
[19/50] [abbrv] [text] Update tests from JUnit 4 to 5. Closes #79.
Update tests from JUnit 4 to 5. Closes #79.
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/49db4cb3
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/49db4cb3
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/49db4cb3
Branch: refs/heads/release
Commit: 49db4cb38baa24348023258924e63e9dac786f00
Parents: 6f06de9
Author: Pascal Schumacher <pa...@apache.org>
Authored: Sun Apr 8 09:42:14 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sun Apr 8 09:42:14 2018 -0600
----------------------------------------------------------------------
pom.xml | 32 +-
.../commons/text/AlphabetConverterTest.java | 87 +-
.../org/apache/commons/text/CaseUtilsTest.java | 2 +-
.../commons/text/CharacterPredicatesTest.java | 2 +-
.../commons/text/CompositeFormatTest.java | 8 +-
.../commons/text/ExtendedMessageFormatTest.java | 126 +-
.../commons/text/FormattableUtilsTest.java | 14 +-
.../commons/text/RandomStringGeneratorTest.java | 68 +-
.../text/StrBuilderAppendInsertTest.java | 2 +-
.../org/apache/commons/text/StrBuilderTest.java | 111 +-
.../org/apache/commons/text/StrLookupTest.java | 14 +-
.../org/apache/commons/text/StrMatcherTest.java | 2 +-
.../apache/commons/text/StrSubstitutorTest.java | 1664 +++++++++---------
.../apache/commons/text/StrTokenizerTest.java | 79 +-
.../commons/text/StringEscapeUtilsTest.java | 187 +-
.../commons/text/StringSubstitutorTest.java | 39 +-
...titutorWithInterpolatorStringLookupTest.java | 146 +-
.../commons/text/StringTokenizerTest.java | 79 +-
.../text/TextStringBuilderAppendInsertTest.java | 2 +-
.../commons/text/TextStringBuilderTest.java | 111 +-
.../org/apache/commons/text/WordUtilsTest.java | 15 +-
.../text/diff/ReplacementsFinderTest.java | 60 +-
.../text/diff/StringsComparatorTest.java | 10 +-
.../text/lookup/DateStringLookupTest.java | 100 +-
.../EnvironmentVariableStringLookupTest.java | 74 +-
.../lookup/InterpolatorStringLookupTest.java | 196 +--
.../lookup/JavaPlatformStringLookupTest.java | 63 +-
.../text/lookup/LocalHostStringLookupTest.java | 92 +-
.../text/lookup/MapStringLookupTest.java | 74 +-
.../text/lookup/NullStringLookupTest.java | 60 +-
.../lookup/ResourceBundleStringLookupTest.java | 70 +-
.../lookup/SystemPropertyStringLookupTest.java | 62 +-
.../commons/text/matcher/StringMatcherTest.java | 2 +-
.../matcher/StringSubstitutorGetSetTest.java | 18 +-
.../text/similarity/CosineDistanceTest.java | 6 +-
.../text/similarity/CosineSimilarityTest.java | 21 +-
.../commons/text/similarity/FuzzyScoreTest.java | 27 +-
.../text/similarity/HammingDistanceTest.java | 19 +-
.../text/similarity/JaccardDistanceTest.java | 56 +-
.../text/similarity/JaccardSimilarityTest.java | 56 +-
.../similarity/JaroWinklerDistanceTest.java | 29 +-
.../LevenshteinDetailedDistanceTest.java | 37 +-
.../similarity/LevenshteinDistanceTest.java | 27 +-
.../text/similarity/LevenshteinResultsTest.java | 2 +-
.../LongestCommonSubsequenceDistanceTest.java | 19 +-
.../LongestCommonSubsequenceTest.java | 49 +-
.../ParameterizedEditDistanceFromTest.java | 84 +-
.../ParameterizedLevenshteinDistanceTest.java | 121 +-
.../ParameterizedSimilarityScoreFromTest.java | 54 +-
.../similarity/SimilarityScoreFromTest.java | 7 +-
.../text/similarity/StringMetricFromTest.java | 18 +-
.../text/translate/AggregateTranslatorTest.java | 2 +-
.../text/translate/CodePointTranslatorTest.java | 2 +-
.../text/translate/CsvTranslatorsTest.java | 2 +-
.../text/translate/EntityArraysTest.java | 2 +-
.../text/translate/JavaUnicodeEscaperTest.java | 2 +-
.../text/translate/LookupTranslatorTest.java | 7 +-
.../translate/NumericEntityEscaperTest.java | 2 +-
.../translate/NumericEntityUnescaperTest.java | 2 +-
.../text/translate/OctalUnescaperTest.java | 2 +-
.../translate/SinglePassTranslatorTest.java | 15 +-
.../text/translate/UnicodeEscaperTest.java | 2 +-
.../text/translate/UnicodeUnescaperTest.java | 2 +-
.../UnicodeUnpairedSurrogateRemoverTest.java | 2 +-
64 files changed, 2185 insertions(+), 2162 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8f872f9..241330e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,9 @@
<commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/text/</commons.distSvnStagingUrl>
<commons.release.isDistModule>true</commons.release.isDistModule>
+ <junit.version>5.1.0</junit.version>
+ <junit.platform.version>1.1.0</junit.platform.version>
+
<checkstyle.plugin.version>3.0.0</checkstyle.plugin.version>
<checkstyle.version>8.9</checkstyle.version>
</properties>
@@ -60,15 +63,21 @@
</dependency>
<!-- testing -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <version>1.3</version>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -99,6 +108,17 @@
</pluginManagement>
<plugins>
<plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.19</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-surefire-provider</artifactId>
+ <version>${junit.platform.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/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 7eb8887..1ce32a7 100644
--- a/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
+++ b/src/test/java/org/apache/commons/text/AlphabetConverterTest.java
@@ -22,11 +22,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Unit tests for {@link AlphabetConverter}.
@@ -55,14 +55,11 @@ public class AlphabetConverterTest {
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};
private static Integer[] doNotEncodeCodepoints = {32, 97, 98, 99}; // space, a, b, c
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
- public void encodeFailureTest() throws UnsupportedEncodingException {
- thrown.expect(UnsupportedEncodingException.class);
- thrown.expectMessage("Couldn't find encoding for '3'");
- test(binary, numbers, empty, "3");
+ public void encodeFailureTest() {
+ assertThatThrownBy(() -> {
+ test(binary, numbers, empty, "3");
+ }).isInstanceOf(UnsupportedEncodingException.class).hasMessage("Couldn't find encoding for '3' in 3");
}
@Test
@@ -117,23 +114,21 @@ public class AlphabetConverterTest {
@Test
public void unexpectedEndwhileDecodingTest() throws UnsupportedEncodingException {
final String toDecode = "00d01d0";
-
- thrown.expect(UnsupportedEncodingException.class);
- thrown.expectMessage("Unexpected end of string while decoding " + toDecode);
-
- final AlphabetConverter ac = createJavadocExample();
- ac.decode(toDecode);
+ assertThatThrownBy(() -> {
+ final AlphabetConverter ac = createJavadocExample();
+ ac.decode(toDecode);
+ }).isInstanceOf(UnsupportedEncodingException.class).hasMessage(
+ "Unexpected end of string while decoding " + toDecode);
}
@Test
public void unexpectedStringWhileDecodingTest() throws UnsupportedEncodingException {
final String toDecode = "00XX";
-
- thrown.expect(UnsupportedEncodingException.class);
- thrown.expectMessage("Unexpected string without decoding (XX) in " + toDecode);
-
- final AlphabetConverter ac = createJavadocExample();
- ac.decode(toDecode);
+ assertThatThrownBy(() -> {
+ final AlphabetConverter ac = createJavadocExample();
+ ac.decode(toDecode);
+ }).isInstanceOf(UnsupportedEncodingException.class).hasMessage(
+ "Unexpected string without decoding (XX) in " + toDecode);
}
/*
@@ -156,39 +151,37 @@ public class AlphabetConverterTest {
@Test
public void noEncodingLettersTest() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(
+ assertThatThrownBy(() -> {
+ AlphabetConverter.createConverterFromChars(englishAndNumbers, numbers, numbers);
+ }).isInstanceOf(IllegalArgumentException.class).hasMessage(
"Must have at least two encoding characters (excluding those in the 'do not encode' list), but has 0");
-
- AlphabetConverter.createConverterFromChars(englishAndNumbers, numbers, numbers);
}
@Test
public void onlyOneEncodingLettersTest() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(
- "Must have at least two encoding characters (excluding those in the 'do not encode' list), but has 1");
-
- final Character[] numbersPlusUnderscore = Arrays.copyOf(numbers, numbers.length + 1);
- numbersPlusUnderscore[numbersPlusUnderscore.length - 1] = '_';
+ assertThatThrownBy(() -> {
+ final Character[] numbersPlusUnderscore = Arrays.copyOf(numbers, numbers.length + 1);
+ numbersPlusUnderscore[numbersPlusUnderscore.length - 1] = '_';
- AlphabetConverter.createConverterFromChars(englishAndNumbers, numbersPlusUnderscore, numbers);
+ AlphabetConverter.createConverterFromChars(englishAndNumbers, numbersPlusUnderscore, numbers);
+ }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ "Must have at least two encoding characters (excluding those in the 'do not encode' list), but has 1");
}
@Test
public void missingDoNotEncodeLettersFromEncodingTest() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Can not use 'do not encode' list because encoding alphabet does not contain");
-
- AlphabetConverter.createConverterFromChars(englishAndNumbers, lowerCaseEnglish, numbers);
+ assertThatThrownBy(() -> {
+ AlphabetConverter.createConverterFromChars(englishAndNumbers, lowerCaseEnglish, numbers);
+ }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ "Can not use 'do not encode' list because encoding alphabet does not contain '0'");
}
@Test
public void missingDoNotEncodeLettersFromOriginalTest() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Can not use 'do not encode' list because original alphabet does not contain");
-
- AlphabetConverter.createConverterFromChars(lowerCaseEnglish, englishAndNumbers, numbers);
+ assertThatThrownBy(() -> {
+ AlphabetConverter.createConverterFromChars(lowerCaseEnglish, englishAndNumbers, numbers);
+ }).isInstanceOf(IllegalArgumentException.class).hasMessage(
+ "Can not use 'do not encode' list because original alphabet does not contain '0'");
}
private void test(final Character[] originalChars, final Character[] encodingChars,
@@ -229,13 +222,15 @@ public class AlphabetConverterTest {
}
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCreateConverterFromCharsWithNullAndNull() {
- final Character[] characterArray = new Character[2];
- characterArray[0] = '$';
- characterArray[1] = characterArray[0];
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final Character[] characterArray = new Character[2];
+ characterArray[0] = '$';
+ characterArray[1] = characterArray[0];
- AlphabetConverter.createConverterFromChars(characterArray, null, null);
+ AlphabetConverter.createConverterFromChars(characterArray, null, null);
+ });
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/CaseUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/CaseUtilsTest.java b/src/test/java/org/apache/commons/text/CaseUtilsTest.java
index 33ee577..c3f4353 100644
--- a/src/test/java/org/apache/commons/text/CaseUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/CaseUtilsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java b/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java
index e16ac13..53879e4 100644
--- a/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java
+++ b/src/test/java/org/apache/commons/text/CharacterPredicatesTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/CompositeFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/CompositeFormatTest.java b/src/test/java/org/apache/commons/text/CompositeFormatTest.java
index 0130f9b..24b3586 100644
--- a/src/test/java/org/apache/commons/text/CompositeFormatTest.java
+++ b/src/test/java/org/apache/commons/text/CompositeFormatTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.text.FieldPosition;
import java.text.Format;
@@ -25,7 +25,7 @@ import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Locale;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link CompositeFormat}.
@@ -70,8 +70,8 @@ public class CompositeFormatTest {
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
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index 8770bc4..0563826 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -16,9 +16,11 @@
*/
package org.apache.commons.text;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+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;
@@ -34,8 +36,8 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test case for {@link ExtendedMessageFormat}.
@@ -44,7 +46,7 @@ public class ExtendedMessageFormatTest {
private final Map<String, FormatFactory> registry = new HashMap<>();
- @Before
+ @BeforeEach
public void setUp() {
registry.put("lower", new LowerCaseFormatFactory());
registry.put("upper", new UpperCaseFormatFactory());
@@ -57,7 +59,7 @@ public class ExtendedMessageFormatTest {
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(pattern, emf.toPattern(), "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"}));
@@ -152,8 +154,8 @@ public class ExtendedMessageFormatTest {
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));
}
}
@@ -278,8 +280,8 @@ public class ExtendedMessageFormatTest {
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");
}
}
@@ -290,11 +292,11 @@ public class ExtendedMessageFormatTest {
public void testBuiltInNumberFormat() {
final Object[] args = new Object[] {Double.valueOf("6543.21")};
final Locale[] availableLocales = NumberFormat.getAvailableLocales();
- checkBuiltInFormat("1: {0,number}", args, availableLocales);
- checkBuiltInFormat("2: {0,number,integer}", args, availableLocales);
- checkBuiltInFormat("3: {0,number,currency}", args, availableLocales);
- checkBuiltInFormat("4: {0,number,percent}", args, availableLocales);
- checkBuiltInFormat("5: {0,number,00000.000}", args, availableLocales);
+ checkBuiltInFormat("1: {0,number}", args, availableLocales);
+ checkBuiltInFormat("2: {0,number,integer}", args, availableLocales);
+ checkBuiltInFormat("3: {0,number,currency}", args, availableLocales);
+ checkBuiltInFormat("4: {0,number,percent}", args, availableLocales);
+ checkBuiltInFormat("5: {0,number,00000.000}", args, availableLocales);
}
/**
@@ -313,35 +315,35 @@ public class ExtendedMessageFormatTest {
ExtendedMessageFormat other = null;
// Same object
- assertTrue("same, equals()", emf.equals(emf));
- assertTrue("same, hashcode()", emf.hashCode() == emf.hashCode());
+ assertTrue(emf.equals(emf), "same, equals()");
+ assertEquals(emf.hashCode(), emf.hashCode(), "same, hashcode()");
- assertFalse("null, equals", emf.equals(null));
+ assertFalse(emf.equals(null), "null, equals");
// 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
}
/**
@@ -393,8 +395,8 @@ public class ExtendedMessageFormatTest {
} 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());
}
/**
@@ -412,53 +414,71 @@ public class ExtendedMessageFormatTest {
return result;
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testSetFormatIsUnsupported() {
- final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
- emf.setFormat(0, new LowerCaseFormat());
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
+ emf.setFormat(0, new LowerCaseFormat());
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testSetFormatByArgumentIndexIsUnsupported() {
- final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
- emf.setFormatByArgumentIndex(0, new LowerCaseFormat());
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
+ emf.setFormatByArgumentIndex(0, new LowerCaseFormat());
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testSetFormatsIsUnsupported() {
- final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
- emf.setFormats(new Format[]{new LowerCaseFormat(), new UpperCaseFormat()});
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
+ emf.setFormats(new Format[] {new LowerCaseFormat(), new UpperCaseFormat()});
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testSetFormatsByArgumentIndex() {
- final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
- emf.setFormatsByArgumentIndex(new Format[]{new LowerCaseFormat(), new UpperCaseFormat()});
+ assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> {
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat("");
+ emf.setFormatsByArgumentIndex(new Format[] {new LowerCaseFormat(), new UpperCaseFormat()});
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionOne() {
- new ExtendedMessageFormat("agdXdkR;T1{9 ^,LzXf?", new HashMap<String, FormatFactory>());
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new ExtendedMessageFormat("agdXdkR;T1{9 ^,LzXf?", new HashMap<String, FormatFactory>());
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionTwo() {
- new ExtendedMessageFormat("a5XdkR;T1{9 ,LzXf?", new HashMap<String, FormatFactory>());
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new ExtendedMessageFormat("a5XdkR;T1{9 ,LzXf?", new HashMap<String, FormatFactory>());
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionThree() {
- new ExtendedMessageFormat("9jLh_D9{ ", new HashMap<String, FormatFactory>());
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new ExtendedMessageFormat("9jLh_D9{ ", new HashMap<String, FormatFactory>());
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionFour() {
- new ExtendedMessageFormat("RD,nXhM{}{", new HashMap<String, FormatFactory>());
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new ExtendedMessageFormat("RD,nXhM{}{", new HashMap<String, FormatFactory>());
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateExtendedMessageFormatTakingTwoArgumentsThrowsIllegalArgumentExceptionFive() {
- new ExtendedMessageFormat("j/[_D9{0,\"&'+0o", new HashMap<String, FormatFactory>());
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new ExtendedMessageFormat("j/[_D9{0,\"&'+0o", new HashMap<String, FormatFactory>());
+ });
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/FormattableUtilsTest.java b/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
index 7741523..273cea1 100644
--- a/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
+++ b/src/test/java/org/apache/commons/text/FormattableUtilsTest.java
@@ -18,11 +18,13 @@ package org.apache.commons.text;
import static java.util.FormattableFlags.LEFT_JUSTIFY;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import java.util.Formattable;
import java.util.Formatter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests {@link FormattableUtils}.
@@ -107,9 +109,11 @@ public class FormattableUtilsTest {
.isEqualTo("+* ");
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIllegalEllipsis() {
- FormattableUtils.append("foo", new Formatter(), 0, -1, 1, "xx");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ FormattableUtils.append("foo", new Formatter(), 0, -1, 1, "xx");
+ });
}
@Test
@@ -146,9 +150,9 @@ public class FormattableUtilsTest {
.isEqualTo("+*___");
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testAppendWithNullFormatterAndIntsThrowsNullPointerException() {
- FormattableUtils.append("", null, 0, 0, 0, '}');
+ assertThatNullPointerException().isThrownBy(() -> FormattableUtils.append("", null, 0, 0, 0, '}'));
}
static class SimplestFormattable implements Formattable {
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
index f6c40b1..7805b89 100644
--- a/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
+++ b/src/test/java/org/apache/commons/text/RandomStringGeneratorTest.java
@@ -16,14 +16,12 @@
*/
package org.apache.commons.text;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatNullPointerException;
import static org.assertj.core.api.Assertions.fail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests for {@link RandomStringGenerator}
@@ -44,22 +42,28 @@ public class RandomStringGeneratorTest {
}
};
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testInvalidLength() {
- final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
- generator.generate(-1);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
+ generator.generate(-1);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGenerateMinMaxLengthInvalidLength() {
- final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
- generator.generate(-1, 0);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
+ generator.generate(-1, 0);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGenerateMinMaxLengthMinGreaterThanMax() {
- final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
- generator.generate(1, 0);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
+ generator.generate(1, 0);
+ });
}
private static int codePointLength(final String s) {
@@ -80,17 +84,21 @@ public class RandomStringGeneratorTest {
final int maxLength = 3;
final RandomStringGenerator generator = new RandomStringGenerator.Builder().build();
final String str = generator.generate(minLength, maxLength);
- assertThat(codePointLength(str), allOf(greaterThanOrEqualTo(0), lessThanOrEqualTo(3)));
+ assertThat(codePointLength(str)).isBetween(0, 3);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadMinimumCodePoint() {
- new RandomStringGenerator.Builder().withinRange(-1, 1);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new RandomStringGenerator.Builder().withinRange(-1, 1);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadMaximumCodePoint() {
- new RandomStringGenerator.Builder().withinRange(0, Character.MAX_CODE_POINT + 1);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new RandomStringGenerator.Builder().withinRange(0, Character.MAX_CODE_POINT + 1);
+ });
}
@Test
@@ -216,9 +224,11 @@ public class RandomStringGeneratorTest {
} while (i < str.length());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadMinAndMax() {
- new RandomStringGenerator.Builder().withinRange(2, 1);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new RandomStringGenerator.Builder().withinRange(2, 1);
+ });
}
@Test
@@ -279,13 +289,15 @@ public class RandomStringGeneratorTest {
}
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testGenerateTakingIntThrowsNullPointerException() {
- final RandomStringGenerator.Builder randomStringGeneratorBuilder = new RandomStringGenerator.Builder();
- final CharacterPredicate[] characterPredicateArray = new CharacterPredicate[2];
- randomStringGeneratorBuilder.filteredBy(characterPredicateArray);
- final RandomStringGenerator randomStringGenerator = randomStringGeneratorBuilder.build();
-
- randomStringGenerator.generate(18);
+ assertThatNullPointerException().isThrownBy(() -> {
+ final RandomStringGenerator.Builder randomStringGeneratorBuilder = new RandomStringGenerator.Builder();
+ final CharacterPredicate[] characterPredicateArray = new CharacterPredicate[2];
+ randomStringGeneratorBuilder.filteredBy(characterPredicateArray);
+ final RandomStringGenerator randomStringGenerator = randomStringGeneratorBuilder.build();
+
+ randomStringGenerator.generate(18);
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/StrBuilderAppendInsertTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/text/StrBuilderAppendInsertTest.java
index e1cfad4..416e0ed 100644
--- a/src/test/java/org/apache/commons/text/StrBuilderAppendInsertTest.java
+++ b/src/test/java/org/apache/commons/text/StrBuilderAppendInsertTest.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link StrBuilder}.
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/StrBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrBuilderTest.java b/src/test/java/org/apache/commons/text/StrBuilderTest.java
index 528588a..a7fafe2 100644
--- a/src/test/java/org/apache/commons/text/StrBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/StrBuilderTest.java
@@ -17,14 +17,15 @@
package org.apache.commons.text;
-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.assertj.core.api.Assertions.assertThatExceptionOfType;
+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;
@@ -36,7 +37,7 @@ import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link StrBuilder}.
@@ -482,13 +483,13 @@ public class StrBuilderTest {
assertEquals(0, sb.toCharArray().length);
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
@@ -498,19 +499,19 @@ public class StrBuilderTest {
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);
@@ -1045,7 +1046,7 @@ public class StrBuilderTest {
sb = new StrBuilder("aaxaaaayaa");
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb.length(), -1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
assertEquals("aaxaaaayaa", sb.toString());
@@ -1053,7 +1054,7 @@ public class StrBuilderTest {
sb = new StrBuilder("aaxaaaayaa");
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb.length(), -1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
assertEquals("aaxaaaayaa", sb.toString());
@@ -1108,7 +1109,7 @@ public class StrBuilderTest {
sb = new StrBuilder("aaxaaaayaa");
try {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
assertEquals("aaxaaaayaa", sb.toString());
@@ -1216,28 +1217,28 @@ public class StrBuilderTest {
// Start index is negative
try {
sb.subSequence(-1, 5);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
// End index is negative
try {
sb.subSequence(2, -1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
// End index greater than length()
try {
sb.subSequence(2, sb.length() + 1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
// Start index greater then end index
try {
sb.subSequence(3, 2);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
@@ -1257,13 +1258,13 @@ public class StrBuilderTest {
assertEquals("hello goodbye".substring(0), sb.substring(0));
try {
sb.substring(-1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
try {
sb.substring(15);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
@@ -1282,13 +1283,13 @@ public class StrBuilderTest {
try {
sb.substring(-1, 5);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
try {
sb.substring(15, 20);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException e) {
}
}
@@ -1765,27 +1766,27 @@ public class StrBuilderTest {
array = new char[3];
try {
reader.read(array, -1, 0);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
try {
reader.read(array, 0, -1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
try {
reader.read(array, 100, 1);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
try {
reader.read(array, 0, 100);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
try {
reader.read(array, Integer.MAX_VALUE, Integer.MAX_VALUE);
- fail();
+ fail("Exception expected!");
} catch (final IndexOutOfBoundsException ex) {
}
@@ -1957,8 +1958,8 @@ public class StrBuilderTest {
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");
}
// -----------------------------------------------------------------------
@@ -1966,14 +1967,14 @@ public class StrBuilderTest {
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
@@ -2122,27 +2123,33 @@ public class StrBuilderTest {
assertEquals("c" + System.lineSeparator(), sb1.appendln(ch).toString());
}
- @Test(expected = StringIndexOutOfBoundsException.class)
+ @Test
public void testAppendTakingTwoIntsWithZeroThrowsStringIndexOutOfBoundsException() {
- final Charset charset = Charset.defaultCharset();
- final ByteBuffer byteBuffer = charset.encode("end < start");
- final CharBuffer charBuffer = charset.decode(byteBuffer);
+ assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> {
+ final Charset charset = Charset.defaultCharset();
+ final ByteBuffer byteBuffer = charset.encode("end < start");
+ final CharBuffer charBuffer = charset.decode(byteBuffer);
- new StrBuilder(630).append(charBuffer, 0, 630);
+ new StrBuilder(630).append(charBuffer, 0, 630);
+ });
}
- @Test(expected = StringIndexOutOfBoundsException.class)
+ @Test
public void testAppendTakingTwoIntsWithIndexOutOfBoundsThrowsStringIndexOutOfBoundsExceptionTwo() {
- final Charset charset = Charset.defaultCharset();
- final ByteBuffer byteBuffer = charset.encode("asdf");
- final CharBuffer charBuffer = charset.decode(byteBuffer);
+ assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> {
+ final Charset charset = Charset.defaultCharset();
+ final ByteBuffer byteBuffer = charset.encode("asdf");
+ final CharBuffer charBuffer = charset.decode(byteBuffer);
- new StrBuilder().append(charBuffer, 933, 654);
+ new StrBuilder().append(charBuffer, 933, 654);
+ });
}
- @Test(expected = StringIndexOutOfBoundsException.class)
+ @Test
public void testDeleteCharAtWithNegative() {
- new StrBuilder().deleteCharAt((-1258));
+ assertThatExceptionOfType(StringIndexOutOfBoundsException.class).isThrownBy(() -> {
+ new StrBuilder().deleteCharAt((-1258));
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/StrLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrLookupTest.java b/src/test/java/org/apache/commons/text/StrLookupTest.java
index 62330e7..c765b5a 100644
--- a/src/test/java/org/apache/commons/text/StrLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StrLookupTest.java
@@ -16,16 +16,16 @@
*/
package org.apache.commons.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 java.util.ResourceBundle;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test class for {@link StrLookup}.
@@ -50,7 +50,7 @@ public class StrLookupTest {
assertNull(StrLookup.systemPropertiesLookup().lookup("other"));
try {
StrLookup.systemPropertiesLookup().lookup(null);
- fail();
+ fail("Exception expected!");
} catch (final NullPointerException ex) {
// expected
}
@@ -72,7 +72,7 @@ public class StrLookupTest {
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);
}
@@ -91,7 +91,7 @@ public class StrLookupTest {
final StrLookup<String> 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);
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/StrMatcherTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/StrMatcherTest.java b/src/test/java/org/apache/commons/text/StrMatcherTest.java
index 22278f8..f35647f 100644
--- a/src/test/java/org/apache/commons/text/StrMatcherTest.java
+++ b/src/test/java/org/apache/commons/text/StrMatcherTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.text;
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link StrMatcher}.