Skip to content

Commit d616e10

Browse files
committed
Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13. See gh-22894
1 parent 47c3930 commit d616e10

File tree

103 files changed

+126
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+126
-70
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@
3030
import org.junit.Before;
3131
import org.junit.Test;
3232

33-
import org.springframework.beans.PropertyEditorRegistrar;
34-
import org.springframework.beans.PropertyEditorRegistry;
3533
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3634
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
3735
import org.springframework.beans.propertyeditors.CustomDateEditor;
38-
import org.springframework.core.io.Resource;
3936
import org.springframework.tests.Assume;
4037
import org.springframework.tests.TestGroup;
4138

spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.util.LinkedMultiValueMap;
4040
import org.springframework.util.MultiValueMap;
4141

42+
import static org.hamcrest.MatcherAssert.assertThat;
4243
import static org.hamcrest.Matchers.*;
4344
import static org.junit.Assert.*;
4445
import static org.springframework.core.CollectionFactory.*;

spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.junit.Test;
2929

30+
import static org.hamcrest.MatcherAssert.assertThat;
3031
import static org.hamcrest.Matchers.*;
3132
import static org.junit.Assert.*;
3233
import static org.springframework.core.GenericTypeResolver.*;

spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.springframework.core.ResolvableType.VariableResolver;
5454
import org.springframework.util.MultiValueMap;
5555

56+
import static org.hamcrest.MatcherAssert.assertThat;
5657
import static org.hamcrest.Matchers.*;
5758
import static org.junit.Assert.*;
5859
import static org.mockito.BDDMockito.any;

spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
import org.junit.Test;
3333

34+
import static org.hamcrest.MatcherAssert.assertThat;
3435
import static org.hamcrest.Matchers.*;
35-
import static org.junit.Assert.*;
3636

3737
/**
3838
* Tests for {@link SerializableTypeWrapper}.

spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.core.annotation.AnnotationUtilsTests.ImplicitAliasesContextConfig;
2929

3030
import static org.hamcrest.CoreMatchers.*;
31+
import static org.hamcrest.MatcherAssert.assertThat;
3132
import static org.junit.Assert.*;
3233

3334
/**

spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Test;
2424

2525
import static org.hamcrest.CoreMatchers.*;
26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.junit.Assert.*;
2728

2829
/**

spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.util.LinkedMultiValueMap;
4343
import org.springframework.util.MultiValueMap;
4444

45+
import static org.hamcrest.MatcherAssert.assertThat;
4546
import static org.hamcrest.Matchers.*;
4647
import static org.junit.Assert.*;
4748

spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.springframework.util.comparator.ComparableComparator;
3131

3232
import static org.hamcrest.CoreMatchers.*;
33-
import static org.junit.Assert.*;
33+
import static org.hamcrest.MatcherAssert.assertThat;
3434

3535
/**
3636
* Tests for {@link ConvertingComparator}.

spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.springframework.util.ClassUtils;
5757
import org.springframework.util.StopWatch;
5858

59+
import static org.hamcrest.MatcherAssert.assertThat;
5960
import static org.hamcrest.Matchers.*;
6061
import static org.junit.Assert.*;
6162

spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
import org.springframework.core.convert.converter.Converter;
2525

26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.hamcrest.Matchers.*;
27-
import static org.junit.Assert.*;
2828

2929
/**
3030
* Tests for {@link ByteBufferConverter}.

spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
import static java.util.Comparator.*;
5353
import static java.util.stream.Collectors.*;
54+
import static org.hamcrest.MatcherAssert.assertThat;
5455
import static org.hamcrest.Matchers.*;
5556
import static org.junit.Assert.*;
5657

spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.util.LinkedMultiValueMap;
3434
import org.springframework.util.MultiValueMap;
3535

36+
import static org.hamcrest.MatcherAssert.assertThat;
3637
import static org.hamcrest.Matchers.*;
3738
import static org.junit.Assert.*;
3839

spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.junit.Test;
2424

2525
import static org.hamcrest.CoreMatchers.*;
26-
import static org.junit.Assert.*;
26+
import static org.hamcrest.MatcherAssert.assertThat;
2727

2828
/**
2929
* Unit tests covering the extensibility of {@link AbstractEnvironment}.

spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Test;
2424

2525
import static org.hamcrest.CoreMatchers.*;
26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.junit.Assert.*;
2728

2829
/**

spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.mock.env.MockPropertySource;
2424

2525
import static org.hamcrest.CoreMatchers.*;
26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.junit.Assert.*;
2728

2829
/**

spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.junit.Test;
2626

2727
import static org.hamcrest.CoreMatchers.*;
28-
import static org.junit.Assert.*;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2929

3030
/**
3131
* Unit tests for {@link PropertySource} implementations.

spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.core.convert.ConverterNotFoundException;
2727
import org.springframework.mock.env.MockPropertySource;
2828

29+
import static org.hamcrest.MatcherAssert.assertThat;
2930
import static org.hamcrest.Matchers.*;
3031
import static org.junit.Assert.*;
3132

spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.junit.Test;
2323

2424
import static org.hamcrest.CoreMatchers.*;
25-
import static org.junit.Assert.*;
25+
import static org.hamcrest.MatcherAssert.assertThat;
2626

2727
public class SimpleCommandLineParserTests {
2828

spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222

2323
import static org.hamcrest.CoreMatchers.*;
24-
import static org.junit.Assert.*;
24+
import static org.hamcrest.MatcherAssert.assertThat;
2525

2626
/**
2727
* Unit tests for {@link SimpleCommandLinePropertySource}.
@@ -122,4 +122,5 @@ public void covertNonOptionArgsToStringArrayAndList() {
122122
assertThat(nonOptionArgsList.get(0), equalTo("noa1"));
123123
assertThat(nonOptionArgsList.get(1), equalTo("noa2"));
124124
}
125+
125126
}

spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.junit.Test;
2626

2727
import static org.hamcrest.CoreMatchers.*;
28-
import static org.junit.Assert.*;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2929

3030
/**
3131
* Unit tests for {@link SystemEnvironmentPropertySource}.

spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.junit.Test;
2525

26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.hamcrest.Matchers.*;
2728
import static org.junit.Assert.*;
2829

spring-core/src/test/java/org/springframework/core/io/ResourceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.util.FileCopyUtils;
3434

3535
import static org.hamcrest.CoreMatchers.*;
36+
import static org.hamcrest.MatcherAssert.assertThat;
3637
import static org.junit.Assert.*;
3738

3839
/**

spring-core/src/test/java/org/springframework/core/io/support/ResourcePropertySourceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.core.io.ClassPathResource;
2626

2727
import static org.hamcrest.CoreMatchers.*;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2829
import static org.junit.Assert.*;
2930

3031
/**

spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.util.ConcurrencyThrottleSupport;
2626

2727
import static org.hamcrest.CoreMatchers.*;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2829
import static org.junit.Assert.*;
2930

3031
/**

spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.junit.Test;
2020

2121
import static org.hamcrest.CoreMatchers.*;
22-
import static org.junit.Assert.*;
22+
import static org.hamcrest.MatcherAssert.assertThat;
2323

2424
/**
2525
* Abstract base class for testing implementations of
@@ -73,4 +73,5 @@ public void againstMemberClass() {
7373
String[] nestedClasses = metadata.getMemberClassNames();
7474
assertThat(nestedClasses, equalTo(new String[]{}));
7575
}
76+
7677
}

spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.stereotype.Component;
4040

4141
import static org.hamcrest.CoreMatchers.*;
42+
import static org.hamcrest.MatcherAssert.assertThat;
4243
import static org.junit.Assert.*;
4344

4445
/**

spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.springframework.tests.TestGroup;
3030

3131
import static org.hamcrest.CoreMatchers.*;
32-
import static org.junit.Assert.*;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3333

3434
/**
3535
* Unit tests for checking the behaviour of {@link CachingMetadataReaderFactory} under

spring-core/src/test/java/org/springframework/tests/AssumeTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import static java.util.stream.Collectors.*;
2727
import static org.hamcrest.CoreMatchers.*;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2829
import static org.junit.Assert.*;
2930
import static org.springframework.tests.Assume.*;
3031
import static org.springframework.tests.TestGroup.*;

spring-core/src/test/java/org/springframework/tests/MockitoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.mockito.internal.util.MockUtil;
2424
import org.mockito.invocation.Invocation;
2525

26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.hamcrest.Matchers.*;
27-
import static org.junit.Assert.*;
2828

2929
/**
3030
* General test utilities for use with {@link Mockito}.

spring-core/src/test/java/org/springframework/tests/TestGroupTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.junit.Test;
2525
import org.junit.rules.ExpectedException;
2626

27+
import static org.hamcrest.MatcherAssert.assertThat;
2728
import static org.hamcrest.Matchers.*;
28-
import static org.junit.Assert.*;
2929

3030
/**
3131
* Tests for {@link TestGroup}.

spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.util.comparator.ComparableComparator;
4242
import org.springframework.util.comparator.NullSafeComparator;
4343

44+
import static org.hamcrest.MatcherAssert.assertThat;
4445
import static org.hamcrest.Matchers.*;
4546
import static org.junit.Assert.*;
4647

spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.rules.ExpectedException;
3030

3131
import static org.hamcrest.CoreMatchers.*;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3233
import static org.junit.Assert.*;
3334
import static org.springframework.util.ObjectUtils.*;
3435

spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.tests.sample.objects.TestObject;
3434

3535
import static org.hamcrest.CoreMatchers.*;
36+
import static org.hamcrest.MatcherAssert.assertThat;
3637
import static org.junit.Assert.*;
3738

3839
/**

spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.junit.Test;
3030
import org.mockito.InOrder;
3131

32+
import static org.hamcrest.MatcherAssert.assertThat;
3233
import static org.hamcrest.Matchers.*;
33-
import static org.junit.Assert.*;
3434
import static org.mockito.BDDMockito.*;
3535

3636
/**

spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222

2323
import static org.hamcrest.CoreMatchers.*;
24-
import static org.junit.Assert.*;
24+
import static org.hamcrest.MatcherAssert.assertThat;
2525

2626
/**
2727
* Tests for {@link BooleanComparator}.

spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222

2323
import static org.hamcrest.CoreMatchers.*;
24-
import static org.junit.Assert.*;
24+
import static org.hamcrest.MatcherAssert.assertThat;
2525

2626
/**
2727
* Tests for {@link InstanceComparator}.

spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.junit.Test;
2626

27+
import static org.hamcrest.MatcherAssert.assertThat;
2728
import static org.hamcrest.Matchers.*;
2829
import static org.junit.Assert.*;
2930
import static org.mockito.Mockito.any;

spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.xml.sax.XMLReader;
3434
import org.xmlunit.util.Predicate;
3535

36-
import static org.junit.Assert.*;
36+
import static org.hamcrest.MatcherAssert.assertThat;
3737
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
3838

3939
/**

spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.xml.sax.InputSource;
2828
import org.xml.sax.XMLReader;
2929

30-
import static org.junit.Assert.*;
30+
import static org.hamcrest.MatcherAssert.assertThat;
3131
import static org.xmlunit.matchers.CompareMatcher.*;
3232

3333
/**

spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.junit.Test;
3131

3232
import static javax.xml.stream.XMLStreamConstants.*;
33+
import static org.hamcrest.MatcherAssert.assertThat;
3334
import static org.junit.Assert.*;
3435
import static org.xmlunit.matchers.CompareMatcher.*;
3536

spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.junit.Test;
2525

2626
import static org.hamcrest.CoreMatchers.*;
27-
import static org.junit.Assert.*;
27+
import static org.hamcrest.MatcherAssert.assertThat;
2828

2929
/**
3030
* @author Arjen Poutsma

spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import java.io.StringReader;
3131
import java.io.StringWriter;
3232

33+
import static org.hamcrest.MatcherAssert.assertThat;
3334
import static org.junit.Assert.assertEquals;
3435
import static org.junit.Assert.assertNull;
35-
import static org.junit.Assert.assertThat;
3636
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
3737

3838
/**

spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
import java.io.StringReader;
3434
import java.io.StringWriter;
3535

36+
import static org.hamcrest.MatcherAssert.assertThat;
3637
import static org.junit.Assert.assertEquals;
3738
import static org.junit.Assert.assertNull;
38-
import static org.junit.Assert.assertThat;
3939
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
4040

4141
/**

0 commit comments

Comments
 (0)