diff --git a/pom.xml b/pom.xml
index 2188899..bf2cdb8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,9 @@
true
UTF-8
UTF-8
+ 5.8.2
+ 3.21.0
+ 2.17.2
6.0.0-SNAPSHOT
@@ -123,6 +126,13 @@
pom
import
+
+ org.junit
+ junit-bom
+ ${junit-jupiter.version}
+ pom
+ import
+
@@ -135,26 +145,45 @@
org.springframework
spring-core
-
true
- junit
- junit
- 4.13.1
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+ org.junit.platform
+ junit-platform-launcher
+ test
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
test
org.apache.logging.log4j
log4j-core
- 2.17.1
+ ${log4j.version}
test
org.apache.logging.log4j
log4j-jcl
- 2.17.1
+ ${log4j.version}
test
diff --git a/src/test/java/org/springframework/classify/BackToBackPatternClassifierTests.java b/src/test/java/org/springframework/classify/BackToBackPatternClassifierTests.java
index 9e34ae9..58e1bf9 100644
--- a/src/test/java/org/springframework/classify/BackToBackPatternClassifierTests.java
+++ b/src/test/java/org/springframework/classify/BackToBackPatternClassifierTests.java
@@ -15,16 +15,18 @@
*/
package org.springframework.classify;
-import static org.junit.Assert.assertEquals;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import org.springframework.classify.annotation.Classifier;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
/**
* @author Dave Syer
*
@@ -35,16 +37,16 @@ public class BackToBackPatternClassifierTests {
private Map map;
- @Before
+ @BeforeEach
public void createMap() {
map = new HashMap<>();
map.put("foo", "bar");
map.put("*", "spam");
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testNoClassifiers() {
- classifier.classify("foo");
+ assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> classifier.classify("foo"));
}
@Test
@@ -52,7 +54,7 @@ public class BackToBackPatternClassifierTests {
classifier = new BackToBackPatternClassifier<>(
new PatternMatchingClassifier<>(Collections.singletonMap("oof", "bucket")),
new PatternMatchingClassifier<>(map));
- assertEquals("spam", classifier.classify("oof"));
+ assertThat(classifier.classify("oof")).isEqualTo("spam");
}
@Test
@@ -64,7 +66,7 @@ public class BackToBackPatternClassifierTests {
}
});
classifier.setMatcherMap(map);
- assertEquals("spam", classifier.classify("oof"));
+ assertThat(classifier.classify("oof")).isEqualTo("spam");
}
@Test
@@ -72,7 +74,7 @@ public class BackToBackPatternClassifierTests {
classifier = new BackToBackPatternClassifier<>();
classifier.setRouterDelegate(new RouterDelegate());
classifier.setMatcherMap(map);
- assertEquals("spam", classifier.classify("oof"));
+ assertThat(classifier.classify("oof")).isEqualTo("spam");
}
@SuppressWarnings("serial")
diff --git a/src/test/java/org/springframework/classify/BinaryExceptionClassifierBuilderTests.java b/src/test/java/org/springframework/classify/BinaryExceptionClassifierBuilderTests.java
index 4263497..a263829 100644
--- a/src/test/java/org/springframework/classify/BinaryExceptionClassifierBuilderTests.java
+++ b/src/test/java/org/springframework/classify/BinaryExceptionClassifierBuilderTests.java
@@ -21,10 +21,13 @@ import java.io.IOException;
import java.io.StreamCorruptedException;
import java.util.concurrent.TimeoutException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import org.springframework.retry.support.RetryTemplate;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+
/**
* @author Aleksandr Shamukov
*/
@@ -37,11 +40,11 @@ public class BinaryExceptionClassifierBuilderTests {
BinaryExceptionClassifier classifier = BinaryExceptionClassifier.builder().retryOn(IOException.class)
.retryOn(TimeoutException.class).build();
- Assert.assertTrue(classifier.classify(new IOException()));
+ assertThat(classifier.classify(new IOException())).isTrue();
// should not retry due to traverseCauses=fasle
- Assert.assertFalse(classifier.classify(new RuntimeException(new IOException())));
- Assert.assertTrue(classifier.classify(new StreamCorruptedException()));
- Assert.assertFalse(classifier.classify(new OutOfMemoryError()));
+ assertThat(classifier.classify(new RuntimeException(new IOException()))).isFalse();
+ assertThat(classifier.classify(new StreamCorruptedException())).isTrue();
+ assertThat(classifier.classify(new OutOfMemoryError())).isFalse();
}
@Test
@@ -49,13 +52,13 @@ public class BinaryExceptionClassifierBuilderTests {
BinaryExceptionClassifier classifier = BinaryExceptionClassifier.builder().retryOn(IOException.class)
.retryOn(TimeoutException.class).traversingCauses().build();
- Assert.assertTrue(classifier.classify(new IOException()));
+ assertThat(classifier.classify(new IOException())).isTrue();
// should retry due to traverseCauses=true
- Assert.assertTrue(classifier.classify(new RuntimeException(new IOException())));
- Assert.assertTrue(classifier.classify(new StreamCorruptedException()));
+ assertThat(classifier.classify(new RuntimeException(new IOException()))).isTrue();
+ assertThat(classifier.classify(new StreamCorruptedException())).isTrue();
// should retry due to FileNotFoundException is a subclass of TimeoutException
- Assert.assertTrue(classifier.classify(new FileNotFoundException()));
- Assert.assertFalse(classifier.classify(new RuntimeException()));
+ assertThat(classifier.classify(new FileNotFoundException())).isTrue();
+ assertThat(classifier.classify(new RuntimeException())).isFalse();
}
@Test
@@ -64,16 +67,17 @@ public class BinaryExceptionClassifierBuilderTests {
.notRetryOn(InterruptedException.class).traversingCauses().build();
// should not retry due to OutOfMemoryError is a subclass of Error
- Assert.assertFalse(classifier.classify(new OutOfMemoryError()));
- Assert.assertFalse(classifier.classify(new InterruptedException()));
- Assert.assertTrue(classifier.classify(new Throwable()));
+ assertThat(classifier.classify(new OutOfMemoryError())).isFalse();
+ assertThat(classifier.classify(new InterruptedException())).isFalse();
+ assertThat(classifier.classify(new Throwable())).isTrue();
// should retry due to traverseCauses=true
- Assert.assertFalse(classifier.classify(new RuntimeException(new InterruptedException())));
+ assertThat(classifier.classify(new RuntimeException(new InterruptedException()))).isFalse();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testFailOnNotationMix() {
- BinaryExceptionClassifier.builder().retryOn(IOException.class).notRetryOn(OutOfMemoryError.class);
+ assertThatIllegalArgumentException().isThrownBy(() -> BinaryExceptionClassifier.builder()
+ .retryOn(IOException.class).notRetryOn(OutOfMemoryError.class));
}
}
diff --git a/src/test/java/org/springframework/classify/BinaryExceptionClassifierTests.java b/src/test/java/org/springframework/classify/BinaryExceptionClassifierTests.java
index 799370e..305aa37 100644
--- a/src/test/java/org/springframework/classify/BinaryExceptionClassifierTests.java
+++ b/src/test/java/org/springframework/classify/BinaryExceptionClassifierTests.java
@@ -16,48 +16,47 @@
package org.springframework.classify;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.DirectFieldAccessor;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class BinaryExceptionClassifierTests {
BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(false);
@Test
public void testClassifyNullIsDefault() {
- assertFalse(classifier.classify(null));
+ assertThat(classifier.classify(null)).isFalse();
}
@Test
public void testFalseIsDefault() {
- assertFalse(classifier.getDefault());
+ assertThat(classifier.getDefault()).isFalse();
}
@Test
public void testDefaultProvided() {
classifier = new BinaryExceptionClassifier(true);
- assertTrue(classifier.getDefault());
+ assertThat(classifier.getDefault()).isTrue();
}
@Test
public void testClassifyRandomException() {
- assertFalse(classifier.classify(new IllegalStateException("foo")));
+ assertThat(classifier.classify(new IllegalStateException("foo"))).isFalse();
}
@Test
public void testClassifyExactMatch() {
Collection> set = Collections
.>singleton(IllegalStateException.class);
- assertTrue(new BinaryExceptionClassifier(set).classify(new IllegalStateException("Foo")));
+ assertThat(new BinaryExceptionClassifier(set).classify(new IllegalStateException("Foo"))).isTrue();
}
@Test
@@ -66,7 +65,7 @@ public class BinaryExceptionClassifierTests {
.>singleton(IllegalStateException.class);
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(set);
binaryExceptionClassifier.setTraverseCauses(true);
- assertTrue(binaryExceptionClassifier.classify(new RuntimeException(new IllegalStateException("Foo"))));
+ assertThat(binaryExceptionClassifier.classify(new RuntimeException(new IllegalStateException("Foo")))).isTrue();
}
@Test
@@ -75,7 +74,7 @@ public class BinaryExceptionClassifierTests {
.>singleton(IllegalStateException.class);
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(set);
binaryExceptionClassifier.setTraverseCauses(true);
- assertTrue(binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo"))));
+ assertThat(binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo")))).isTrue();
}
@Test
@@ -85,24 +84,25 @@ public class BinaryExceptionClassifierTests {
map.put(BarException.class, false);
BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(map, true);
binaryExceptionClassifier.setTraverseCauses(true);
- assertTrue(
- binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo", new BarException()))));
- assertTrue(((Map, ?>) new DirectFieldAccessor(binaryExceptionClassifier).getPropertyValue("classified"))
- .containsKey(FooException.class));
+ assertThat(
+ binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo", new BarException()))))
+ .isTrue();
+ assertThat(((Map, ?>) new DirectFieldAccessor(binaryExceptionClassifier).getPropertyValue("classified"))
+ .containsKey(FooException.class)).isTrue();
}
@Test
public void testTypesProvidedInConstructor() {
classifier = new BinaryExceptionClassifier(
Collections.>singleton(IllegalStateException.class));
- assertTrue(classifier.classify(new IllegalStateException("Foo")));
+ assertThat(classifier.classify(new IllegalStateException("Foo"))).isTrue();
}
@Test
public void testTypesProvidedInConstructorWithNonDefault() {
classifier = new BinaryExceptionClassifier(
Collections.>singleton(IllegalStateException.class), false);
- assertFalse(classifier.classify(new IllegalStateException("Foo")));
+ assertThat(classifier.classify(new IllegalStateException("Foo"))).isFalse();
}
@Test
@@ -110,7 +110,8 @@ public class BinaryExceptionClassifierTests {
classifier = new BinaryExceptionClassifier(
Collections.>singleton(IllegalStateException.class), false);
classifier.setTraverseCauses(true);
- assertFalse(classifier.classify(new RuntimeException(new RuntimeException(new IllegalStateException("Foo")))));
+ assertThat(classifier.classify(new RuntimeException(new RuntimeException(new IllegalStateException("Foo")))))
+ .isFalse();
}
@SuppressWarnings("serial")
diff --git a/src/test/java/org/springframework/classify/ClassifierAdapterTests.java b/src/test/java/org/springframework/classify/ClassifierAdapterTests.java
index d9f2306..87e9535 100644
--- a/src/test/java/org/springframework/classify/ClassifierAdapterTests.java
+++ b/src/test/java/org/springframework/classify/ClassifierAdapterTests.java
@@ -15,14 +15,17 @@
*/
package org.springframework.classify;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.classify.annotation.Classifier;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* @author Dave Syer
+ * @author Gary Russell
*
*/
public class ClassifierAdapterTests {
@@ -42,12 +45,12 @@ public class ClassifierAdapterTests {
throw new UnsupportedOperationException("Not allowed");
}
});
- assertEquals(23, adapter.classify("23").intValue());
+ assertThat(adapter.classify("23").intValue()).isEqualTo(23);
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testClassifierAdapterObjectWithNoAnnotation() {
- adapter = new ClassifierAdapter<>(new Object() {
+ assertThatIllegalStateException().isThrownBy(() -> new ClassifierAdapter<>(new Object() {
@SuppressWarnings("unused")
public Integer getValue(String key) {
return Integer.parseInt(key);
@@ -57,8 +60,7 @@ public class ClassifierAdapterTests {
public Integer getAnother(String key) {
throw new UnsupportedOperationException("Not allowed");
}
- });
- assertEquals(23, adapter.classify("23").intValue());
+ }));
}
@Test
@@ -78,14 +80,14 @@ public class ClassifierAdapterTests {
return "foo";
}
});
- assertEquals(23, adapter.classify("23").intValue());
+ assertThat(adapter.classify("23").intValue()).isEqualTo(23);
}
@SuppressWarnings({ "serial" })
@Test
public void testClassifierAdapterClassifier() {
adapter = new ClassifierAdapter<>(Integer::valueOf);
- assertEquals(23, adapter.classify("23").intValue());
+ assertThat(adapter.classify("23").intValue()).isEqualTo(23);
}
@Test
@@ -96,10 +98,10 @@ public class ClassifierAdapterTests {
return Integer.parseInt(key);
}
});
- assertEquals(23, adapter.classify("23").intValue());
+ assertThat(adapter.classify("23").intValue()).isEqualTo(23);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testClassifyWithWrongType() {
adapter.setDelegate(new Object() {
@Classifier
@@ -107,14 +109,13 @@ public class ClassifierAdapterTests {
return key.toString();
}
});
- assertEquals(23, adapter.classify("23").intValue());
+ assertThatIllegalArgumentException().isThrownBy(() -> adapter.classify("23"));
}
- @SuppressWarnings("serial")
@Test
public void testClassifyWithClassifier() {
adapter.setDelegate(Integer::valueOf);
- assertEquals(23, adapter.classify("23").intValue());
+ assertThat(adapter.classify("23").intValue()).isEqualTo(23);
}
}
diff --git a/src/test/java/org/springframework/classify/ClassifierSupportTests.java b/src/test/java/org/springframework/classify/ClassifierSupportTests.java
index 9a5fbff..e500d0c 100644
--- a/src/test/java/org/springframework/classify/ClassifierSupportTests.java
+++ b/src/test/java/org/springframework/classify/ClassifierSupportTests.java
@@ -16,22 +16,22 @@
package org.springframework.classify;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
public class ClassifierSupportTests {
@Test
public void testClassifyNullIsDefault() {
ClassifierSupport classifier = new ClassifierSupport<>("foo");
- assertEquals(classifier.classify(null), "foo");
+ assertThat(classifier.classify(null)).isEqualTo("foo");
}
@Test
public void testClassifyRandomException() {
ClassifierSupport classifier = new ClassifierSupport<>("foo");
- assertEquals(classifier.classify(new IllegalStateException("Foo")), classifier.classify(null));
+ assertThat(classifier.classify(new IllegalStateException("Foo"))).isEqualTo(classifier.classify(null));
}
}
diff --git a/src/test/java/org/springframework/classify/PatternMatchingClassifierTests.java b/src/test/java/org/springframework/classify/PatternMatchingClassifierTests.java
index 83b44e0..b3e7fde 100644
--- a/src/test/java/org/springframework/classify/PatternMatchingClassifierTests.java
+++ b/src/test/java/org/springframework/classify/PatternMatchingClassifierTests.java
@@ -15,14 +15,13 @@
*/
package org.springframework.classify;
-import static org.junit.Assert.*;
-
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.classify.PatternMatchingClassifier;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
@@ -34,7 +33,7 @@ public class PatternMatchingClassifierTests {
private Map map;
- @Before
+ @BeforeEach
public void createMap() {
map = new HashMap<>();
map.put("foo", "bar");
@@ -44,15 +43,15 @@ public class PatternMatchingClassifierTests {
@Test
public void testSetPatternMap() {
classifier.setPatternMap(map);
- assertEquals("bar", classifier.classify("foo"));
- assertEquals("spam", classifier.classify("bucket"));
+ assertThat(classifier.classify("foo")).isEqualTo("bar");
+ assertThat(classifier.classify("bucket")).isEqualTo("spam");
}
@Test
public void testCreateFromMap() {
classifier = new PatternMatchingClassifier<>(map);
- assertEquals("bar", classifier.classify("foo"));
- assertEquals("spam", classifier.classify("bucket"));
+ assertThat(classifier.classify("foo")).isEqualTo("bar");
+ assertThat(classifier.classify("bucket")).isEqualTo("spam");
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/springframework/classify/SubclassClassifierTests.java b/src/test/java/org/springframework/classify/SubclassClassifierTests.java
index ca1da63..0f97bdc 100644
--- a/src/test/java/org/springframework/classify/SubclassClassifierTests.java
+++ b/src/test/java/org/springframework/classify/SubclassClassifierTests.java
@@ -19,9 +19,9 @@ package org.springframework.classify;
import java.util.Collections;
import java.util.function.Supplier;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class SubclassClassifierTests {
@@ -29,14 +29,14 @@ public class SubclassClassifierTests {
public void testClassifyInterface() {
SubclassClassifier