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:01 UTC
[16/50] [abbrv] [text] Update tests from JUnit 4 to 5. Closes #79.
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/lookup/MapStringLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/lookup/MapStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/MapStringLookupTest.java
index 5e7d1b7..7ff7d58 100644
--- a/src/test/java/org/apache/commons/text/lookup/MapStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/MapStringLookupTest.java
@@ -1,37 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class MapStringLookupTest {
-
- @Test
- public void testOne() {
- final String key = "key";
- final String value = "value";
- final Map<String, String> map = new HashMap<>();
- map.put(key, value);
- Assert.assertEquals(value, MapStringLookup.on(map).lookup(key));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class MapStringLookupTest {
+
+ @Test
+ public void testOne() {
+ final String key = "key";
+ final String value = "value";
+ final Map<String, String> map = new HashMap<>();
+ map.put(key, value);
+ Assertions.assertEquals(value, MapStringLookup.on(map).lookup(key));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
index 2efde17..361d97b 100644
--- a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
@@ -1,30 +1,30 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class NullStringLookupTest {
-
- @Test
- public void test() {
- Assert.assertEquals(null, NullStringLookup.INSTANCE.lookup("EverythingIsNull"));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class NullStringLookupTest {
+
+ @Test
+ public void test() {
+ Assertions.assertEquals(null, NullStringLookup.INSTANCE.lookup("EverythingIsNull"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
index a9357da..37415b5 100644
--- a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
@@ -1,35 +1,35 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import java.util.ResourceBundle;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ResourceBundleStringLookupTest {
-
- @Test
- public void testOne() {
- final String bundleName = "testResourceBundleLookup";
- final String bundleKey = "key";
- Assert.assertEquals(ResourceBundle.getBundle(bundleName).getString(bundleKey),
- ResourceBundleStringLookup.INSTANCE.lookup(bundleName + ":" + bundleKey));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import java.util.ResourceBundle;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class ResourceBundleStringLookupTest {
+
+ @Test
+ public void testOne() {
+ final String bundleName = "testResourceBundleLookup";
+ final String bundleKey = "key";
+ Assertions.assertEquals(ResourceBundle.getBundle(bundleName).getString(bundleKey),
+ ResourceBundleStringLookup.INSTANCE.lookup(bundleName + ":" + bundleKey));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
index 4bfd9c8..2a93f85 100644
--- a/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
@@ -1,31 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.commons.text.lookup;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SystemPropertyStringLookupTest {
-
- @Test
- public void testUserName() {
- final String key = "user.name";
- Assert.assertEquals(System.getProperty(key), SystemPropertyStringLookup.INSTANCE.lookup(key));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.commons.text.lookup;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class SystemPropertyStringLookupTest {
+
+ @Test
+ public void testUserName() {
+ final String key = "user.name";
+ Assertions.assertEquals(System.getProperty(key), SystemPropertyStringLookup.INSTANCE.lookup(key));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/matcher/StringMatcherTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/matcher/StringMatcherTest.java b/src/test/java/org/apache/commons/text/matcher/StringMatcherTest.java
index 6dcd792..e4d4902 100644
--- a/src/test/java/org/apache/commons/text/matcher/StringMatcherTest.java
+++ b/src/test/java/org/apache/commons/text/matcher/StringMatcherTest.java
@@ -18,7 +18,7 @@ package org.apache.commons.text.matcher;
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link StringMatcher}.
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/matcher/StringSubstitutorGetSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/matcher/StringSubstitutorGetSetTest.java b/src/test/java/org/apache/commons/text/matcher/StringSubstitutorGetSetTest.java
index 733c853..cee1caa 100644
--- a/src/test/java/org/apache/commons/text/matcher/StringSubstitutorGetSetTest.java
+++ b/src/test/java/org/apache/commons/text/matcher/StringSubstitutorGetSetTest.java
@@ -17,13 +17,13 @@
package org.apache.commons.text.matcher;
-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.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 org.apache.commons.text.StringSubstitutor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test class for {@link StringSubstitutor}.
@@ -44,7 +44,7 @@ public class StringSubstitutorGetSetTest {
assertTrue(sub.getVariablePrefixMatcher() instanceof AbstractStringMatcher.StringMatcher);
try {
sub.setVariablePrefix((String) null);
- fail();
+ fail("Exception expected!");
} catch (final IllegalArgumentException ex) {
// expected
}
@@ -55,7 +55,7 @@ public class StringSubstitutorGetSetTest {
assertSame(matcher, sub.getVariablePrefixMatcher());
try {
sub.setVariablePrefixMatcher((StringMatcher) null);
- fail();
+ fail("Exception expected!");
} catch (final IllegalArgumentException ex) {
// expected
}
@@ -76,7 +76,7 @@ public class StringSubstitutorGetSetTest {
assertTrue(sub.getVariableSuffixMatcher() instanceof AbstractStringMatcher.StringMatcher);
try {
sub.setVariableSuffix((String) null);
- fail();
+ fail("Exception expected!");
} catch (final IllegalArgumentException ex) {
// expected
}
@@ -87,7 +87,7 @@ public class StringSubstitutorGetSetTest {
assertSame(matcher, sub.getVariableSuffixMatcher());
try {
sub.setVariableSuffixMatcher((StringMatcher) null);
- fail();
+ fail("Exception expected!");
} catch (final IllegalArgumentException ex) {
// expected
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
index 51f7194..62a7619 100644
--- a/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/CosineDistanceTest.java
@@ -21,8 +21,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link CosineSimilarity}.
@@ -37,7 +37,7 @@ public class CosineDistanceTest {
/**
* Creates the cosine distance object used throughout the tests.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() {
cosineDistance = new CosineDistance();
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/CosineSimilarityTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/CosineSimilarityTest.java b/src/test/java/org/apache/commons/text/similarity/CosineSimilarityTest.java
index 235d2e3..c229cb5 100644
--- a/src/test/java/org/apache/commons/text/similarity/CosineSimilarityTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/CosineSimilarityTest.java
@@ -17,11 +17,12 @@
package org.apache.commons.text.similarity;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.within;
@@ -38,17 +39,21 @@ public class CosineSimilarityTest {
assertThat(cosineSimilarity.cosineSimilarity(hashMap, hashMapTwo)).isEqualTo(0.0, within(0.01));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCosineSimilarityThrowsIllegalArgumentException() {
- final CosineSimilarity cosineSimilarity = new CosineSimilarity();
- final Map<CharSequence, Integer> map = new HashMap<>();
- cosineSimilarity.cosineSimilarity(map, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final CosineSimilarity cosineSimilarity = new CosineSimilarity();
+ final Map<CharSequence, Integer> map = new HashMap<>();
+ cosineSimilarity.cosineSimilarity(map, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testCosineSimilarityWithNull() {
- final CosineSimilarity cosineSimilarity = new CosineSimilarity();
- cosineSimilarity.cosineSimilarity(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final CosineSimilarity cosineSimilarity = new CosineSimilarity();
+ cosineSimilarity.cosineSimilarity(null, null);
+ });
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java b/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
index a6ca81f..53042eb 100644
--- a/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/FuzzyScoreTest.java
@@ -17,10 +17,11 @@
package org.apache.commons.text.similarity;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import java.util.Locale;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link FuzzyScore}.
@@ -40,24 +41,32 @@ public class FuzzyScoreTest {
assertThat(ENGLISH_SCORE.fuzzyScore("Apache Software Foundation", "asf")).isEqualTo(3);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetFuzzyScore_StringNullLocale() {
- ENGLISH_SCORE.fuzzyScore("not null", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ ENGLISH_SCORE.fuzzyScore("not null", null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetFuzzyScore_NullStringLocale() {
- ENGLISH_SCORE.fuzzyScore(null, "not null");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ ENGLISH_SCORE.fuzzyScore(null, "not null");
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetFuzzyScore_NullNullLocale() {
- ENGLISH_SCORE.fuzzyScore(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ ENGLISH_SCORE.fuzzyScore(null, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testMissingLocale() {
- new FuzzyScore((Locale) null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ new FuzzyScore((Locale) null);
+ });
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
index 6ce2314..edad76a 100644
--- a/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/HammingDistanceTest.java
@@ -17,9 +17,10 @@
package org.apache.commons.text.similarity;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link HammingDistance}.
@@ -28,7 +29,7 @@ public class HammingDistanceTest {
private static HammingDistance distance;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
distance = new HammingDistance();
}
@@ -45,14 +46,18 @@ public class HammingDistanceTest {
assertThat(distance.apply("ATCG", "ACCC")).isEqualTo(2);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testHammingDistance_nullLeftValue() {
- distance.apply(null, "");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ distance.apply(null, "");
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testHammingDistance_nullRightValue() {
- distance.apply("", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ distance.apply("", null);
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
index c8e5c61..56d4909 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaccardDistanceTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.text.similarity;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link JaccardDistance}.
@@ -28,41 +29,48 @@ public class JaccardDistanceTest {
private static JaccardDistance classBeingTested;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
classBeingTested = new JaccardDistance();
}
@Test
public void testGettingJaccardDistance() {
- assertEquals(1.00d, classBeingTested.apply("", ""), 0.0d);
- assertEquals(1.00d, classBeingTested.apply("left", ""), 0.0d);
- assertEquals(1.00d, classBeingTested.apply("", "right"), 0.0d);
- assertEquals(0.25d, classBeingTested.apply("frog", "fog"), 0.0d);
- assertEquals(1.00d, classBeingTested.apply("fly", "ant"), 0.0d);
- assertEquals(0.78d, classBeingTested.apply("elephant", "hippo"), 0.0d);
- assertEquals(0.36d, classBeingTested.apply("ABC Corporation", "ABC Corp"), 0.0d);
- assertEquals(0.24d, classBeingTested.apply("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
- assertEquals(0.11d,
- classBeingTested.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
- assertEquals(0.10d, classBeingTested.apply("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
- assertEquals(0.87d, classBeingTested.apply("left", "right"), 0.0d);
- assertEquals(0.87d, classBeingTested.apply("leettteft", "ritttght"), 0.0d);
- assertEquals(0.0d, classBeingTested.apply("the same string", "the same string"), 0.0d);
+ assertEquals(1.00d, classBeingTested.apply("", ""), 0.00000000000000000001d);
+ assertEquals(1.00d, classBeingTested.apply("left", ""), 0.00000000000000000001d);
+ assertEquals(1.00d, classBeingTested.apply("", "right"), 0.00000000000000000001d);
+ assertEquals(0.25d, classBeingTested.apply("frog", "fog"), 0.00000000000000000001d);
+ assertEquals(1.00d, classBeingTested.apply("fly", "ant"), 0.00000000000000000001d);
+ assertEquals(0.78d, classBeingTested.apply("elephant", "hippo"), 0.00000000000000000001d);
+ assertEquals(0.36d, classBeingTested.apply("ABC Corporation", "ABC Corp"), 0.00000000000000000001d);
+ assertEquals(0.24d, classBeingTested.apply("D N H Enterprises Inc", "D & H Enterprises, Inc."),
+ 0.00000000000000000001d);
+ assertEquals(0.11d, classBeingTested.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"),
+ 0.00000000000000000001d);
+ assertEquals(0.10d, classBeingTested.apply("PENNSYLVANIA", "PENNCISYLVNIA"), 0.00000000000000000001d);
+ assertEquals(0.87d, classBeingTested.apply("left", "right"), 0.00000000000000000001d);
+ assertEquals(0.87d, classBeingTested.apply("leettteft", "ritttght"), 0.00000000000000000001d);
+ assertEquals(0.0d, classBeingTested.apply("the same string", "the same string"), 0.00000000000000000001d);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardDistanceNullNull() {
- classBeingTested.apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(null, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardDistanceStringNull() {
- classBeingTested.apply(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(" ", null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardDistanceNullString() {
- classBeingTested.apply(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(null, "right");
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java b/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
index 6bbbd2f..c96d6d3 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaccardSimilarityTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.text.similarity;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link JaccardSimilarity}.
@@ -28,41 +29,48 @@ public class JaccardSimilarityTest {
private static JaccardSimilarity classBeingTested;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
classBeingTested = new JaccardSimilarity();
}
@Test
public void testGettingJaccardSimilarity() {
- assertEquals(0.00d, classBeingTested.apply("", ""), 0.0d);
- assertEquals(0.00d, classBeingTested.apply("left", ""), 0.0d);
- assertEquals(0.00d, classBeingTested.apply("", "right"), 0.0d);
- assertEquals(0.75d, classBeingTested.apply("frog", "fog"), 0.0d);
- assertEquals(0.00d, classBeingTested.apply("fly", "ant"), 0.0d);
- assertEquals(0.22d, classBeingTested.apply("elephant", "hippo"), 0.0d);
- assertEquals(0.64d, classBeingTested.apply("ABC Corporation", "ABC Corp"), 0.0d);
- assertEquals(0.76d, classBeingTested.apply("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
- assertEquals(0.89d,
- classBeingTested.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
- assertEquals(0.9d, classBeingTested.apply("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
- assertEquals(0.13d, classBeingTested.apply("left", "right"), 0.0d);
- assertEquals(0.13d, classBeingTested.apply("leettteft", "ritttght"), 0.0d);
- assertEquals(1.0d, classBeingTested.apply("the same string", "the same string"), 0.0d);
+ assertEquals(0.00d, classBeingTested.apply("", ""), 0.00000000000000000001d);
+ assertEquals(0.00d, classBeingTested.apply("left", ""), 0.00000000000000000001d);
+ assertEquals(0.00d, classBeingTested.apply("", "right"), 0.00000000000000000001d);
+ assertEquals(0.75d, classBeingTested.apply("frog", "fog"), 0.00000000000000000001d);
+ assertEquals(0.00d, classBeingTested.apply("fly", "ant"), 0.00000000000000000001d);
+ assertEquals(0.22d, classBeingTested.apply("elephant", "hippo"), 0.00000000000000000001d);
+ assertEquals(0.64d, classBeingTested.apply("ABC Corporation", "ABC Corp"), 0.00000000000000000001d);
+ assertEquals(0.76d, classBeingTested.apply("D N H Enterprises Inc", "D & H Enterprises, Inc."),
+ 0.00000000000000000001d);
+ assertEquals(0.89d, classBeingTested.apply("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"),
+ 0.00000000000000000001d);
+ assertEquals(0.9d, classBeingTested.apply("PENNSYLVANIA", "PENNCISYLVNIA"), 0.00000000000000000001d);
+ assertEquals(0.13d, classBeingTested.apply("left", "right"), 0.00000000000000000001d);
+ assertEquals(0.13d, classBeingTested.apply("leettteft", "ritttght"), 0.00000000000000000001d);
+ assertEquals(1.0d, classBeingTested.apply("the same string", "the same string"), 0.00000000000000000001d);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardSimilarityNullNull() {
- classBeingTested.apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(null, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardSimilarityStringNull() {
- classBeingTested.apply(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(" ", null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingJaccardSimilarityNullString() {
- classBeingTested.apply(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ classBeingTested.apply(null, "right");
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
index 1c94e7f..d51135e 100644
--- a/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/JaroWinklerDistanceTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.text.similarity;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link JaroWinklerDistance}.
@@ -28,7 +29,7 @@ public class JaroWinklerDistanceTest {
private static JaroWinklerDistance distance;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
distance = new JaroWinklerDistance();
}
@@ -36,7 +37,7 @@ public class JaroWinklerDistanceTest {
@Test
public void testGetJaroWinklerDistance_StringString() {
assertEquals(0.92499d, distance.apply("frog", "fog"), 0.00001d);
- assertEquals(0.0d, distance.apply("fly", "ant"), 0.0d);
+ assertEquals(0.0d, distance.apply("fly", "ant"), 0.00000000000000000001d);
assertEquals(0.44166d, distance.apply("elephant", "hippo"), 0.00001d);
assertEquals(0.92740d, distance.apply("ABC Corporation", "ABC Corp"), 0.00001d);
assertEquals(0.94580d, distance.apply("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.00001d);
@@ -46,19 +47,25 @@ public class JaroWinklerDistanceTest {
assertEquals(0.996598d, distance.apply("/opt/software1", "/opt/software2"), 0.00001d);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetJaroWinklerDistance_NullNull() {
- distance.apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ distance.apply(null, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetJaroWinklerDistance_StringNull() {
- distance.apply(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ distance.apply(" ", null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetJaroWinklerDistance_NullString() {
- distance.apply(null, "clear");
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ distance.apply(null, "clear");
+ });
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/LevenshteinDetailedDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/LevenshteinDetailedDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/LevenshteinDetailedDistanceTest.java
index 1d1c2ca..1641cbb 100644
--- a/src/test/java/org/apache/commons/text/similarity/LevenshteinDetailedDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/LevenshteinDetailedDistanceTest.java
@@ -17,9 +17,10 @@
package org.apache.commons.text.similarity;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import org.apache.commons.text.TextStringBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LevenshteinDetailedDistanceTest {
@@ -137,14 +138,14 @@ public class LevenshteinDetailedDistanceTest {
assertThat(expectedResult.toString()).isEqualTo(actualResult.toString());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDetailedDistance_NullString() {
- UNLIMITED_DISTANCE.apply("a", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply("a", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDetailedDistance_StringNull() {
- UNLIMITED_DISTANCE.apply(null, "a");
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply(null, "a"));
}
@Test
@@ -386,19 +387,19 @@ public class LevenshteinDetailedDistanceTest {
assertThat(result.getSubstituteCount()).isEqualTo(1);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDetailedDistance_NullStringInt() {
- UNLIMITED_DISTANCE.apply(null, "a");
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply(null, "a"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDetailedDistance_StringNullInt() {
- UNLIMITED_DISTANCE.apply("a", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply("a", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testConstructorWithNegativeThreshold() {
- new LevenshteinDetailedDistance(-1);
+ assertThatIllegalArgumentException().isThrownBy(() -> new LevenshteinDetailedDistance(-1));
}
@Test
@@ -436,17 +437,19 @@ public class LevenshteinDetailedDistanceTest {
assertThat(levenshteinResults.getDistance()).isEqualTo(-1);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testApplyThrowsIllegalArgumentExceptionAndCreatesLevenshteinDetailedDistanceTakingInteger() {
- final LevenshteinDetailedDistance levenshteinDetailedDistance = new LevenshteinDetailedDistance(0);
- final CharSequence charSequence = new TextStringBuilder();
+ assertThatIllegalArgumentException().isThrownBy(() -> {
+ final LevenshteinDetailedDistance levenshteinDetailedDistance = new LevenshteinDetailedDistance(0);
+ final CharSequence charSequence = new TextStringBuilder();
- levenshteinDetailedDistance.apply(charSequence, null);
+ levenshteinDetailedDistance.apply(charSequence, null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testApplyWithNull() {
- new LevenshteinDetailedDistance(0).apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> new LevenshteinDetailedDistance(0).apply(null, null));
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/LevenshteinDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/LevenshteinDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/LevenshteinDistanceTest.java
index 3696810..45ee27e 100644
--- a/src/test/java/org/apache/commons/text/similarity/LevenshteinDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/LevenshteinDistanceTest.java
@@ -16,9 +16,10 @@
*/
package org.apache.commons.text.similarity;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit tests for {@link LevenshteinDistance}.
@@ -41,14 +42,14 @@ public class LevenshteinDistanceTest {
assertThat(UNLIMITED_DISTANCE.apply("hello", "hallo")).isEqualTo(1);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDistance_NullString() {
- UNLIMITED_DISTANCE.apply("a", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply("a", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDistance_StringNull() {
- UNLIMITED_DISTANCE.apply(null, "a");
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply(null, "a"));
}
@Test
@@ -115,24 +116,24 @@ public class LevenshteinDistanceTest {
assertThat(new LevenshteinDistance(Integer.MAX_VALUE).apply("hello", "hallo")).isEqualTo(1);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDistance_NullStringInt() {
- UNLIMITED_DISTANCE.apply(null, "a");
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply(null, "a"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGetLevenshteinDistance_StringNullInt() {
- UNLIMITED_DISTANCE.apply("a", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> UNLIMITED_DISTANCE.apply("a", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testConstructorWithNegativeThreshold() {
- new LevenshteinDistance(-1);
+ assertThatIllegalArgumentException().isThrownBy(() -> new LevenshteinDistance(-1));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testApplyThrowsIllegalArgumentExceptionAndCreatesLevenshteinDistanceTakingInteger() {
- new LevenshteinDistance(0).apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> new LevenshteinDistance(0).apply(null, null));
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/LevenshteinResultsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/LevenshteinResultsTest.java b/src/test/java/org/apache/commons/text/similarity/LevenshteinResultsTest.java
index 8417b6f..3c113c6 100644
--- a/src/test/java/org/apache/commons/text/similarity/LevenshteinResultsTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/LevenshteinResultsTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text.similarity;
-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/similarity/LongestCommonSubsequenceDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistanceTest.java
index 5345bdd..b0a8977 100644
--- a/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceDistanceTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.text.similarity;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit tests for {@link LongestCommonSubsequenceDistance}.
@@ -28,7 +29,7 @@ public class LongestCommonSubsequenceDistanceTest {
private static LongestCommonSubsequenceDistance subject;
- @BeforeClass
+ @BeforeAll
public static void setup() {
subject = new LongestCommonSubsequenceDistance();
}
@@ -50,19 +51,19 @@ public class LongestCommonSubsequenceDistanceTest {
assertThat(subject.apply("the same string", "the same string")).isEqualTo(0);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceDistanceNullNull() {
- subject.apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceDistanceStringNull() {
- subject.apply(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(" ", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceDistanceNullString() {
- subject.apply(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(null, "right"));
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceTest.java b/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceTest.java
index 7aace1f..19b73a4 100644
--- a/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/LongestCommonSubsequenceTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.text.similarity;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit tests for {@link LongestCommonSubsequence}.
@@ -28,7 +29,7 @@ public class LongestCommonSubsequenceTest {
private static LongestCommonSubsequence subject;
- @BeforeClass
+ @BeforeAll
public static void setup() {
subject = new LongestCommonSubsequence();
}
@@ -50,19 +51,19 @@ public class LongestCommonSubsequenceTest {
assertThat(subject.apply("the same string", "the same string")).isEqualTo(15);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceApplyNullNull() {
- subject.apply(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceApplyStringNull() {
- subject.apply(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(" ", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceApplyNullString() {
- subject.apply(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.apply(null, "right"));
}
@Test
@@ -84,19 +85,19 @@ public class LongestCommonSubsequenceTest {
assertThat(subject.longestCommonSubsequence("the same string", "the same string")).isEqualTo("the same string");
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceNullNull() {
- subject.longestCommonSubsequence(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.longestCommonSubsequence(null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceStringNull() {
- subject.longestCommonSubsequence(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.longestCommonSubsequence(" ", null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testGettingLongestCommonSubsequenceNullString() {
- subject.longestCommonSubsequence(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.longestCommonSubsequence(null, "right"));
}
@Test
@@ -119,21 +120,21 @@ public class LongestCommonSubsequenceTest {
assertThat(subject.logestCommonSubsequence("the same string", "the same string")).isEqualTo("the same string");
}
- @Test(expected = IllegalArgumentException.class)
- @Deprecated
+ @Test
+ @SuppressWarnings("deprecation")
public void testGettingLogestCommonSubsequenceNullNull() {
- subject.logestCommonSubsequence(null, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.logestCommonSubsequence(null, null));
}
- @Test(expected = IllegalArgumentException.class)
- @Deprecated
+ @Test
+ @SuppressWarnings("deprecation")
public void testGettingLogestCommonSubsequenceStringNull() {
- subject.logestCommonSubsequence(" ", null);
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.logestCommonSubsequence(" ", null));
}
- @Test(expected = IllegalArgumentException.class)
- @Deprecated
+ @Test
+ @SuppressWarnings("deprecation")
public void testGettingLogestCommonSubsequenceNullString() {
- subject.logestCommonSubsequence(null, "right");
+ assertThatIllegalArgumentException().isThrownBy(() -> subject.logestCommonSubsequence(null, "right"));
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/ParameterizedEditDistanceFromTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/ParameterizedEditDistanceFromTest.java b/src/test/java/org/apache/commons/text/similarity/ParameterizedEditDistanceFromTest.java
index 8e0582e..721439b 100644
--- a/src/test/java/org/apache/commons/text/similarity/ParameterizedEditDistanceFromTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/ParameterizedEditDistanceFromTest.java
@@ -16,75 +16,53 @@
*/
package org.apache.commons.text.similarity;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
-import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
/**
* Unit tests for {@link EditDistanceFrom}.
*
* @param <R> The {@link EditDistance} return type.
*/
-@RunWith(Parameterized.class)
public class ParameterizedEditDistanceFromTest<R> {
- private final EditDistance<R> editDistance;
- private final CharSequence left;
- private final CharSequence right;
- private final R distance;
-
- public ParameterizedEditDistanceFromTest(
- final EditDistance<R> editDistance,
- final CharSequence left, final CharSequence right,
- final R distance) {
-
- this.editDistance = editDistance;
- this.left = left;
- this.right = right;
- this.distance = distance;
- }
-
- @Parameters
- public static Iterable<Object[]> parameters() {
- return Arrays.asList(new Object[][] {
-
- {new HammingDistance(), "Sam I am.", "Ham I am.", 1},
- {new HammingDistance(), "Japtheth, Ham, Shem", "Japtheth, HAM, Shem", 2},
- {new HammingDistance(), "Hamming", "Hamming", 0},
-
- {new LevenshteinDistance(), "Apache", "a patchy", 4},
- {new LevenshteinDistance(), "go", "no go", 3},
- {new LevenshteinDistance(), "go", "go", 0},
+ public static Stream<Arguments> parameters() {
+ return Stream.of(
+ Arguments.of(new HammingDistance(), "Sam I am.", "Ham I am.", 1),
+ Arguments.of(new HammingDistance(), "Japtheth, Ham, Shem", "Japtheth, HAM, Shem", 2),
+ Arguments.of(new HammingDistance(), "Hamming", "Hamming", 0),
- {new LevenshteinDistance(4), "Apache", "a patchy", 4},
- {new LevenshteinDistance(4), "go", "no go", 3},
- {new LevenshteinDistance(0), "go", "go", 0},
+ Arguments.of(new LevenshteinDistance(), "Apache", "a patchy", 4),
+ Arguments.of(new LevenshteinDistance(), "go", "no go", 3),
+ Arguments.of(new LevenshteinDistance(), "go", "go", 0),
- {
- new EditDistance<Boolean>() {
- @Override
- public Boolean apply(final CharSequence left, final CharSequence right) {
- return left == right || (left != null && left.equals(right));
- }
- },
- "Bob's your uncle.",
- "Every good boy does fine.",
- false
- }
+ Arguments.of(new LevenshteinDistance(4), "Apache", "a patchy", 4),
+ Arguments.of(new LevenshteinDistance(4), "go", "no go", 3),
+ Arguments.of(new LevenshteinDistance(0), "go", "go", 0),
- });
+ Arguments.of(
+ new EditDistance<Boolean>() {
+ @Override
+ public Boolean apply(final CharSequence left, final CharSequence right) {
+ return left == right || (left != null && left.equals(right));
+ }
+ },
+ "Bob's your uncle.",
+ "Every good boy does fine.",
+ false));
}
- @Test
- public void test() {
+ @ParameterizedTest
+ @MethodSource("parameters")
+ public void test(EditDistance<R> editDistance, CharSequence left, CharSequence right, R distance) {
final EditDistanceFrom<R> editDistanceFrom = new EditDistanceFrom<>(editDistance, left);
- assertThat(editDistanceFrom.apply(right), equalTo(distance));
+ assertThat(editDistanceFrom.apply(right)).isEqualTo(distance);
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/ParameterizedLevenshteinDistanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/ParameterizedLevenshteinDistanceTest.java b/src/test/java/org/apache/commons/text/similarity/ParameterizedLevenshteinDistanceTest.java
index 0310171..3189ca3 100644
--- a/src/test/java/org/apache/commons/text/similarity/ParameterizedLevenshteinDistanceTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/ParameterizedLevenshteinDistanceTest.java
@@ -16,109 +16,88 @@
*/
package org.apache.commons.text.similarity;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
-import java.util.Arrays;
+import java.util.stream.Stream;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Unit tests for {@link LevenshteinDistance}.
*/
-@RunWith(Parameterized.class)
public class ParameterizedLevenshteinDistanceTest {
- private final Integer distance;
- private final CharSequence left;
- private final CharSequence right;
- private final Integer threshold;
-
- public ParameterizedLevenshteinDistanceTest(
- final Integer threshold,
- final CharSequence left, final CharSequence right,
- final Integer distance) {
-
- this.threshold = threshold;
- this.left = left;
- this.right = right;
- this.distance = distance;
- }
-
- @Parameters
- public static Iterable<Object[]> parameters() {
- return Arrays.asList(new Object[][] {
-
+ public static Stream<Arguments> parameters() {
+ return Stream.of(
/* empty strings */
- {0, "", "", 0},
- {8, "aaapppp", "", 7},
- {7, "aaapppp", "", 7},
- {6, "aaapppp", "", -1},
+ Arguments.of(0, "", "", 0),
+ Arguments.of(8, "aaapppp", "", 7),
+ Arguments.of(7, "aaapppp", "", 7),
+ Arguments.of(6, "aaapppp", "", -1),
/* unequal strings, zero threshold */
- {0, "b", "a", -1},
- {0, "a", "b", -1},
+ Arguments.of(0, "b", "a", -1),
+ Arguments.of(0, "a", "b", -1),
/* equal strings */
- {0, "aa", "aa", 0},
- {2, "aa", "aa", 0},
+ Arguments.of(0, "aa", "aa", 0),
+ Arguments.of(2, "aa", "aa", 0),
/* same length */
- {2, "aaa", "bbb", -1},
- {3, "aaa", "bbb", 3},
+ Arguments.of(2, "aaa", "bbb", -1),
+ Arguments.of(3, "aaa", "bbb", 3),
/* big stripe */
- {10, "aaaaaa", "b", 6},
+ Arguments.of(10, "aaaaaa", "b", 6),
/* distance less than threshold */
- {8, "aaapppp", "b", 7},
- {4, "a", "bbb", 3},
+ Arguments.of(8, "aaapppp", "b", 7),
+ Arguments.of(4, "a", "bbb", 3),
/* distance equal to threshold */
- {7, "aaapppp", "b", 7},
- {3, "a", "bbb", 3},
+ Arguments.of(7, "aaapppp", "b", 7),
+ Arguments.of(3, "a", "bbb", 3),
/* distance greater than threshold */
- {2, "a", "bbb", -1},
- {2, "bbb", "a", -1},
- {6, "aaapppp", "b", -1},
+ Arguments.of(2, "a", "bbb", -1),
+ Arguments.of(2, "bbb", "a", -1),
+ Arguments.of(6, "aaapppp", "b", -1),
/* stripe runs off array, strings not similar */
- {1, "a", "bbb", -1},
- {1, "bbb", "a", -1},
+ Arguments.of(1, "a", "bbb", -1),
+ Arguments.of(1, "bbb", "a", -1),
/* stripe runs off array, strings are similar */
- {1, "12345", "1234567", -1},
- {1, "1234567", "12345", -1},
+ Arguments.of(1, "12345", "1234567", -1),
+ Arguments.of(1, "1234567", "12345", -1),
/* old getLevenshteinDistance test cases */
- {1, "frog", "fog", 1},
- {3, "fly", "ant", 3},
- {7, "elephant", "hippo", 7},
- {6, "elephant", "hippo", -1},
- {7, "hippo", "elephant", 7},
- {6, "hippo", "elephant", -1},
- {8, "hippo", "zzzzzzzz", 8},
- {8, "zzzzzzzz", "hippo", 8},
- {1, "hello", "hallo", 1},
-
- {Integer.MAX_VALUE, "frog", "fog", 1},
- {Integer.MAX_VALUE, "fly", "ant", 3},
- {Integer.MAX_VALUE, "elephant", "hippo", 7},
- {Integer.MAX_VALUE, "hippo", "elephant", 7},
- {Integer.MAX_VALUE, "hippo", "zzzzzzzz", 8},
- {Integer.MAX_VALUE, "zzzzzzzz", "hippo", 8},
- {Integer.MAX_VALUE, "hello", "hallo", 1}
- });
+ Arguments.of(1, "frog", "fog", 1),
+ Arguments.of(3, "fly", "ant", 3),
+ Arguments.of(7, "elephant", "hippo", 7),
+ Arguments.of(6, "elephant", "hippo", -1),
+ Arguments.of(7, "hippo", "elephant", 7),
+ Arguments.of(6, "hippo", "elephant", -1),
+ Arguments.of(8, "hippo", "zzzzzzzz", 8),
+ Arguments.of(8, "zzzzzzzz", "hippo", 8),
+ Arguments.of(1, "hello", "hallo", 1),
+
+ Arguments.of(Integer.MAX_VALUE, "frog", "fog", 1),
+ Arguments.of(Integer.MAX_VALUE, "fly", "ant", 3),
+ Arguments.of(Integer.MAX_VALUE, "elephant", "hippo", 7),
+ Arguments.of(Integer.MAX_VALUE, "hippo", "elephant", 7),
+ Arguments.of(Integer.MAX_VALUE, "hippo", "zzzzzzzz", 8),
+ Arguments.of(Integer.MAX_VALUE, "zzzzzzzz", "hippo", 8),
+ Arguments.of(Integer.MAX_VALUE, "hello", "hallo", 1));
}
- @Test
- public void test() {
+ @ParameterizedTest
+ @MethodSource("parameters")
+ public void test(Integer threshold, CharSequence left, CharSequence right, Integer distance) {
final LevenshteinDistance metric = new LevenshteinDistance(threshold);
- assertThat(metric.apply(left, right), equalTo(distance));
+ assertThat(metric.apply(left, right)).isEqualTo(distance);
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/ParameterizedSimilarityScoreFromTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/ParameterizedSimilarityScoreFromTest.java b/src/test/java/org/apache/commons/text/similarity/ParameterizedSimilarityScoreFromTest.java
index 030cae6..9e30bed 100644
--- a/src/test/java/org/apache/commons/text/similarity/ParameterizedSimilarityScoreFromTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/ParameterizedSimilarityScoreFromTest.java
@@ -16,49 +16,28 @@
*/
package org.apache.commons.text.similarity;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import static org.assertj.core.api.Assertions.assertThat;
-import java.util.Arrays;
+import java.util.stream.Stream;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
/**
* Unit tests for {@link SimilarityScoreFrom}.
*
* @param <R> The {@link SimilarityScore} return type.
*/
-@RunWith(Parameterized.class)
public class ParameterizedSimilarityScoreFromTest<R> {
- private final SimilarityScore<R> similarityScore;
- private final CharSequence left;
- private final CharSequence right;
- private final R distance;
+ public static Stream<Arguments> parameters() {
+ return Stream.of(
+ Arguments.of(new LevenshteinDistance(), "elephant", "hippo", 7),
+ Arguments.of(new LevenshteinDistance(), "hippo", "elephant", 7),
+ Arguments.of(new LevenshteinDistance(), "hippo", "zzzzzzzz", 8),
- public ParameterizedSimilarityScoreFromTest(
- final SimilarityScore<R> similarityScore,
- final CharSequence left, final CharSequence right,
- final R distance) {
-
- this.similarityScore = similarityScore;
- this.left = left;
- this.right = right;
- this.distance = distance;
- }
-
- @Parameters
- public static Iterable<Object[]> parameters() {
- return Arrays.asList(new Object[][] {
-
- {new LevenshteinDistance(), "elephant", "hippo", 7},
- {new LevenshteinDistance(), "hippo", "elephant", 7},
- {new LevenshteinDistance(), "hippo", "zzzzzzzz", 8},
-
- {
+ Arguments.of(
new SimilarityScore<Boolean>() {
@Override
public Boolean apply(final CharSequence left, final CharSequence right) {
@@ -68,14 +47,13 @@ public class ParameterizedSimilarityScoreFromTest<R> {
"Bob's your uncle.",
"Every good boy does fine.",
false
- }
-
- });
+ ));
}
- @Test
- public void test() {
+ @ParameterizedTest
+ @MethodSource("parameters")
+ public void test(SimilarityScore<R> similarityScore, CharSequence left, CharSequence right, R distance) {
final SimilarityScoreFrom<R> similarityScoreFrom = new SimilarityScoreFrom<>(similarityScore, left);
- assertThat(similarityScoreFrom.apply(right), equalTo(distance));
+ assertThat(similarityScoreFrom.apply(right)).isEqualTo(distance);
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/SimilarityScoreFromTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/SimilarityScoreFromTest.java b/src/test/java/org/apache/commons/text/similarity/SimilarityScoreFromTest.java
index 1c8468a..59ad8d0 100644
--- a/src/test/java/org/apache/commons/text/similarity/SimilarityScoreFromTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/SimilarityScoreFromTest.java
@@ -18,14 +18,15 @@
package org.apache.commons.text.similarity;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SimilarityScoreFromTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailsToCreateSimilarityScoreFromThrowsIllegalArgumentException() {
- new SimilarityScoreFrom<>(null, "");
+ assertThatIllegalArgumentException().isThrownBy(() -> new SimilarityScoreFrom<>(null, ""));
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/similarity/StringMetricFromTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/similarity/StringMetricFromTest.java b/src/test/java/org/apache/commons/text/similarity/StringMetricFromTest.java
index 96a54eb..34609f7 100644
--- a/src/test/java/org/apache/commons/text/similarity/StringMetricFromTest.java
+++ b/src/test/java/org/apache/commons/text/similarity/StringMetricFromTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.commons.text.similarity;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link EditDistanceFrom}.
@@ -34,8 +34,8 @@ public class StringMetricFromTest {
final Integer distance = 4;
final EditDistanceFrom<Integer> metricFrom = new EditDistanceFrom<>(metric, left);
- assertThat(metricFrom.apply(right), equalTo(distance));
- assertThat(metricFrom.apply(right), equalTo(metric.apply(left, right)));
+ assertThat(metricFrom.apply(right)).isEqualTo(distance);
+ assertThat(metricFrom.apply(right)).isEqualTo(metric.apply(left, right));
}
@Test
@@ -54,13 +54,13 @@ public class StringMetricFromTest {
mostSimilar = test;
}
}
- assertThat(mostSimilar, equalTo("a patchy"));
- assertThat(shortestDistance, equalTo(4));
+ assertThat(mostSimilar).isEqualTo("a patchy");
+ assertThat(shortestDistance).isEqualTo(4);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testMissingMetric() {
- new EditDistanceFrom<Number>(null, "no go");
+ assertThatIllegalArgumentException().isThrownBy(() -> new EditDistanceFrom<Number>(null, "no go"));
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/AggregateTranslatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/AggregateTranslatorTest.java b/src/test/java/org/apache/commons/text/translate/AggregateTranslatorTest.java
index 55d9c3f..fba9516 100644
--- a/src/test/java/org/apache/commons/text/translate/AggregateTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/AggregateTranslatorTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/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 6995f67..3adbc8e 100644
--- a/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/CodePointTranslatorTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.PipedReader;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java b/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java
index 231a8d6..ab7393f 100644
--- a/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java
+++ b/src/test/java/org/apache/commons/text/translate/CsvTranslatorsTest.java
@@ -23,7 +23,7 @@ import java.io.StringWriter;
import java.io.Writer;
import org.apache.commons.lang3.CharUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CsvTranslatorsTest {
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
index 9140a48..49528d0 100644
--- a/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
+++ b/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.FileReader;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/JavaUnicodeEscaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/JavaUnicodeEscaperTest.java b/src/test/java/org/apache/commons/text/translate/JavaUnicodeEscaperTest.java
index 88ad32f..6f547a3 100644
--- a/src/test/java/org/apache/commons/text/translate/JavaUnicodeEscaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/JavaUnicodeEscaperTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
index 77b671f..868ea40 100644
--- a/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Unit tests for {@link LookupTranslator}.
@@ -55,9 +56,9 @@ public class LookupTranslatorTest {
assertThat(out.toString()).as("Incorrect value").isEqualTo("two");
}
- @Test(expected = InvalidParameterException.class)
+ @Test
public void testFailsToCreateLookupTranslatorThrowsInvalidParameterException() {
- new LookupTranslator(null);
+ assertThatExceptionOfType(InvalidParameterException.class).isThrownBy(() -> new LookupTranslator(null));
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/NumericEntityEscaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/NumericEntityEscaperTest.java b/src/test/java/org/apache/commons/text/translate/NumericEntityEscaperTest.java
index 160795a..121136a 100644
--- a/src/test/java/org/apache/commons/text/translate/NumericEntityEscaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/NumericEntityEscaperTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-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/translate/NumericEntityUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/NumericEntityUnescaperTest.java b/src/test/java/org/apache/commons/text/translate/NumericEntityUnescaperTest.java
index 08665a2..341cd63 100644
--- a/src/test/java/org/apache/commons/text/translate/NumericEntityUnescaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/NumericEntityUnescaperTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/OctalUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/OctalUnescaperTest.java b/src/test/java/org/apache/commons/text/translate/OctalUnescaperTest.java
index 2d6efd3..8e4462f 100644
--- a/src/test/java/org/apache/commons/text/translate/OctalUnescaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/OctalUnescaperTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-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/translate/SinglePassTranslatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/SinglePassTranslatorTest.java b/src/test/java/org/apache/commons/text/translate/SinglePassTranslatorTest.java
index 081dc13..82b0ce2 100644
--- a/src/test/java/org/apache/commons/text/translate/SinglePassTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/SinglePassTranslatorTest.java
@@ -16,14 +16,15 @@
*/
package org.apache.commons.text.translate;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit test for {@link SinglePassTranslator}
@@ -38,7 +39,7 @@ public class SinglePassTranslatorTest {
private StringWriter out;
- @Before
+ @BeforeEach
public void before() {
out = new StringWriter();
}
@@ -50,14 +51,14 @@ public class SinglePassTranslatorTest {
assertThat(dummyTranslator.translate("abcdefg", 0, out)).isEqualTo(7);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void indexIsValidated() throws Exception {
- dummyTranslator.translate("abc", 1, out);
+ assertThatIllegalArgumentException().isThrownBy(() -> dummyTranslator.translate("abc", 1, out));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testTranslateThrowsIllegalArgumentException() throws IOException {
- dummyTranslator.translate("(,Fk", 647, null);
+ assertThatIllegalArgumentException().isThrownBy(() -> dummyTranslator.translate("(,Fk", 647, null));
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/UnicodeEscaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/UnicodeEscaperTest.java b/src/test/java/org/apache/commons/text/translate/UnicodeEscaperTest.java
index c4026c9..8f4bfe1 100644
--- a/src/test/java/org/apache/commons/text/translate/UnicodeEscaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/UnicodeEscaperTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-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/translate/UnicodeUnescaperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/UnicodeUnescaperTest.java b/src/test/java/org/apache/commons/text/translate/UnicodeUnescaperTest.java
index 472a21c..c209fa7 100644
--- a/src/test/java/org/apache/commons/text/translate/UnicodeUnescaperTest.java
+++ b/src/test/java/org/apache/commons/text/translate/UnicodeUnescaperTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
http://git-wip-us.apache.org/repos/asf/commons-text/blob/49db4cb3/src/test/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemoverTest.java b/src/test/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
index 7eacb57..3ba4a6d 100644
--- a/src/test/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
+++ b/src/test/java/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemoverTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.text.translate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.CharArrayWriter;
import java.io.IOException;