Skip to content

Commit c79fdfb

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 d437963 commit c79fdfb

File tree

102 files changed

+108
-57
lines changed

Some content is hidden

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

102 files changed

+108
-57
lines changed

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.springframework.util.ObjectUtils;
6060

6161
import static org.hamcrest.Matchers.*;
62+
import static org.hamcrest.MatcherAssert.assertThat;
6263
import static org.junit.Assert.*;
6364

6465
/**

spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.tests.sample.beans.TestBean;
4444

4545
import static org.hamcrest.CoreMatchers.*;
46+
import static org.hamcrest.MatcherAssert.assertThat;
4647
import static org.junit.Assert.*;
4748

4849
/**

spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.util.SerializationTestUtils;
3636

3737
import static org.hamcrest.Matchers.*;
38+
import static org.hamcrest.MatcherAssert.assertThat;
3839
import static org.junit.Assert.*;
3940
import static org.mockito.BDDMockito.*;
4041

spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import static org.hamcrest.CoreMatchers.notNullValue;
6565
import static org.hamcrest.CoreMatchers.nullValue;
6666
import static org.hamcrest.Matchers.equalTo;
67+
import static org.hamcrest.MatcherAssert.assertThat;
6768
import static org.junit.Assert.*;
6869

6970
/**

spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.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.Matchers.*;
26+
import static org.hamcrest.MatcherAssert.assertThat;
2627
import static org.junit.Assert.*;
2728

2829
/**

spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.tests.sample.beans.TestBean;
2727

2828
import static org.hamcrest.CoreMatchers.*;
29+
import static org.hamcrest.MatcherAssert.assertThat;
2930
import static org.junit.Assert.*;
3031

3132
/**

spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.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
* Unit tests for {@link ExtendedBeanInfoTests}.

spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java

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

3030
import static org.hamcrest.CoreMatchers.equalTo;
3131
import static org.hamcrest.CoreMatchers.is;
32+
import static org.hamcrest.MatcherAssert.assertThat;
3233
import static org.hamcrest.Matchers.*;
3334
import static org.junit.Assert.*;
3435

spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java

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

2323
import static org.hamcrest.CoreMatchers.*;
24+
import static org.hamcrest.MatcherAssert.assertThat;
2425
import static org.junit.Assert.*;
2526

2627
/**

spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java

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

1919
import org.junit.Test;
2020

21+
import static org.hamcrest.MatcherAssert.assertThat;
2122
import static org.hamcrest.Matchers.*;
22-
import static org.junit.Assert.*;
2323

2424
/**
2525
* Tests for {@link PropertyMatches}.

spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.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 Chris Beams

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
import org.springframework.util.StringValueResolver;
104104

105105
import static org.hamcrest.Matchers.*;
106+
import static org.hamcrest.MatcherAssert.assertThat;
106107
import static org.junit.Assert.*;
107108
import static org.mockito.BDDMockito.*;
108109

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

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

2828
import static org.hamcrest.CoreMatchers.*;
29+
import static org.hamcrest.MatcherAssert.assertThat;
2930
import static org.junit.Assert.*;
3031

3132
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.beans.factory.support.RootBeanDefinition;
2525

2626
import static org.hamcrest.CoreMatchers.*;
27+
import static org.hamcrest.MatcherAssert.assertThat;
2728
import static org.junit.Assert.*;
2829
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
2930

spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.springframework.core.io.ByteArrayResource;
3030
import org.springframework.core.io.ClassPathResource;
3131

32+
import static org.hamcrest.MatcherAssert.assertThat;
3233
import static org.hamcrest.Matchers.*;
33-
import static org.junit.Assert.*;
3434
import static org.springframework.beans.factory.config.YamlProcessor.*;
3535

3636
/**

spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
2828

2929
import static org.hamcrest.CoreMatchers.*;
30-
import static org.junit.Assert.*;
30+
import static org.hamcrest.MatcherAssert.assertThat;
3131

3232
/**
3333
* Unit tests for SPR-8954, in which a custom {@link InstantiationAwareBeanPostProcessor}

spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.tests.sample.beans.TestBean;
2424

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

2829
/**

spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java

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

2626
import static org.hamcrest.CoreMatchers.is;
2727
import static org.hamcrest.CoreMatchers.not;
28+
import static org.hamcrest.MatcherAssert.assertThat;
2829
import static org.hamcrest.Matchers.hasItems;
29-
import static org.junit.Assert.*;
3030

3131
/**
3232
* Tests for propagating enclosing beans element defaults to nested beans elements.

spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.core.io.Resource;
1010

1111
import static org.hamcrest.CoreMatchers.*;
12-
import static org.junit.Assert.*;
12+
import static org.hamcrest.MatcherAssert.assertThat;
1313

1414
/**
1515
* Tests for new nested beans element support in Spring XML

spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.core.io.ClassPathResource;
2929

3030
import static org.hamcrest.CoreMatchers.*;
31-
import static org.junit.Assert.*;
31+
import static org.hamcrest.MatcherAssert.assertThat;
3232

3333
/**
3434
* Tests various combinations of profile declarations against various profile

spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.junit.Before;
3131
import org.junit.Rule;
3232
import org.junit.Test;
33-
import org.junit.rules.ExpectedException;
3433
import org.junit.rules.TemporaryFolder;
3534

3635
import org.springframework.context.index.sample.AbstractController;
@@ -61,8 +60,8 @@
6160
import org.springframework.stereotype.Component;
6261
import org.springframework.util.ClassUtils;
6362

63+
import static org.hamcrest.MatcherAssert.assertThat;
6464
import static org.hamcrest.Matchers.*;
65-
import static org.junit.Assert.*;
6665
import static org.springframework.context.index.processor.Metadata.*;
6766

6867
/**
@@ -78,9 +77,6 @@ public class CandidateComponentsIndexerTests {
7877
@Rule
7978
public TemporaryFolder temporaryFolder = new TemporaryFolder();
8079

81-
@Rule
82-
public ExpectedException thrown = ExpectedException.none();
83-
8480

8581
@Before
8682
public void createCompiler() throws IOException {

spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java

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

2525
import org.junit.Test;
2626

27+
import static org.hamcrest.MatcherAssert.assertThat;
2728
import static org.hamcrest.Matchers.*;
28-
import static org.junit.Assert.*;
2929
import static org.springframework.context.index.processor.Metadata.*;
3030

3131
/**

spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.cache.Cache;
2424
import org.springframework.cache.CacheManager;
2525

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

spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java

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

5757
import static java.lang.annotation.ElementType.*;
5858
import static java.lang.annotation.RetentionPolicy.*;
59+
import static org.hamcrest.MatcherAssert.assertThat;
5960
import static org.hamcrest.core.Is.*;
6061
import static org.hamcrest.core.StringContains.*;
6162
import static org.junit.Assert.*;

spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.springframework.validation.ObjectError;
5353
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
5454

55+
import static org.hamcrest.MatcherAssert.assertThat;
5556
import static org.hamcrest.Matchers.*;
5657
import static org.junit.Assert.*;
5758

spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.tests.sample.beans.TestBean;
3838

3939
import static org.hamcrest.CoreMatchers.*;
40+
import static org.hamcrest.MatcherAssert.assertThat;
4041
import static org.junit.Assert.*;
4142

4243
/**

spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java

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

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

2828
/**
2929
* Integration test for Objenesis proxy creation.

spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.springframework.util.SerializationTestUtils;
6363

6464
import static org.hamcrest.CoreMatchers.*;
65+
import static org.hamcrest.MatcherAssert.assertThat;
6566
import static org.junit.Assert.*;
6667

6768
/**

spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import org.springframework.util.StopWatch;
6969

7070
import static org.hamcrest.CoreMatchers.*;
71+
import static org.hamcrest.MatcherAssert.assertThat;
7172
import static org.junit.Assert.*;
7273

7374
/**

spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.junit.Test;
2727
import org.junit.rules.ExpectedException;
2828

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

spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.core.annotation.AliasFor;
3737

3838
import static org.hamcrest.CoreMatchers.*;
39+
import static org.hamcrest.MatcherAssert.assertThat;
3940
import static org.junit.Assert.*;
4041

4142
/**

spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.context.ConfigurableApplicationContext;
3232

3333
import static org.hamcrest.Matchers.*;
34+
import static org.hamcrest.MatcherAssert.assertThat;
3435
import static org.junit.Assert.*;
3536

3637
/**

spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.expression.spel.standard.SpelExpressionParser;
3737
import org.springframework.util.ReflectionUtils;
3838

39+
import static org.hamcrest.MatcherAssert.assertThat;
3940
import static org.hamcrest.Matchers.*;
4041
import static org.junit.Assert.*;
4142

spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java

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

1919
import org.junit.Test;
2020

21+
import static org.hamcrest.MatcherAssert.assertThat;
2122
import static org.hamcrest.Matchers.*;
22-
import static org.junit.Assert.*;
2323

2424
/**
2525
* Tests for {@link SimpleKeyGenerator} and {@link SimpleKey}.

spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java

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

3636
import static java.lang.String.*;
37+
import static org.hamcrest.MatcherAssert.assertThat;
3738
import static org.hamcrest.Matchers.*;
3839
import static org.junit.Assert.*;
3940
import static org.springframework.util.StringUtils.*;

spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
2626
import org.springframework.beans.factory.config.BeanDefinition;
2727

28+
import static org.hamcrest.MatcherAssert.assertThat;
2829
import static org.hamcrest.Matchers.*;
29-
import static org.junit.Assert.*;
3030

3131
/**
3232
* @author Phillip Webb

spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.beans.factory.support.RootBeanDefinition;
2727

2828
import static org.hamcrest.CoreMatchers.*;
29+
import static org.hamcrest.MatcherAssert.assertThat;
2930
import static org.junit.Assert.*;
3031

3132
/**

spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java

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

5858
import static org.hamcrest.CoreMatchers.*;
59+
import static org.hamcrest.MatcherAssert.assertThat;
5960
import static org.junit.Assert.*;
6061

6162
/**

spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.springframework.util.SerializationTestUtils;
6464

6565
import static org.hamcrest.CoreMatchers.*;
66+
import static org.hamcrest.MatcherAssert.assertThat;
6667
import static org.junit.Assert.*;
6768
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
6869

spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.context.annotation.componentscan.level3.Level3Component;
2525

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

2929
/**
3030
* Tests ensuring that configuration classes marked with @ComponentScan

spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.core.type.filter.TypeFilter;
3535

3636
import static org.hamcrest.CoreMatchers.*;
37+
import static org.hamcrest.MatcherAssert.assertThat;
3738
import static org.junit.Assert.*;
3839

3940
/**

spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.tests.sample.beans.TestBean;
2626

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

3030
/**
3131
* Tests semantics of declaring {@link BeanFactoryPostProcessor}-returning @Bean
@@ -115,5 +115,4 @@ public static TestBean testBean() {
115115
}
116116
}
117117

118-
119118
}

spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.tests.sample.beans.TestBean;
2525

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

2929
/**
3030
* Tests cornering the issue reported in SPR-8080. If the product of a @Bean method

spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java

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

3434
import static org.hamcrest.Matchers.*;
35+
import static org.hamcrest.MatcherAssert.assertThat;
3536
import static org.junit.Assert.*;
3637

3738
/**

0 commit comments

Comments
 (0)