Skip to content

Commit 6684c8c

Browse files
committed
#190 - More simplifications for Spring Boot 1.4 M3.
Replaced all occurrences of @SpringApplicationConfiguration with @SpringBootTest. Using SpringRunner instead of @SpringJUnit4ClassRunner now.
1 parent 24ca298 commit 6684c8c

File tree

86 files changed

+410
-639
lines changed

Some content is hidden

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

86 files changed

+410
-639
lines changed

elasticsearch/example/src/test/java/example/springdata/elasticsearch/conference/ElasticsearchOperationsTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import org.junit.Test;
2626
import org.junit.runner.RunWith;
2727
import org.springframework.beans.factory.annotation.Autowired;
28-
import org.springframework.boot.test.SpringApplicationConfiguration;
28+
import org.springframework.boot.test.context.SpringBootTest;
2929
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
3030
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
3131
import org.springframework.data.elasticsearch.core.query.Criteria;
3232
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
33-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
33+
import org.springframework.test.context.junit4.SpringRunner;
3434

3535
/**
3636
* Test case to show Spring Data Elasticsearch functionality.
@@ -39,8 +39,8 @@
3939
* @author Oliver Gierke
4040
* @author Christoph Strobl
4141
*/
42-
@RunWith(SpringJUnit4ClassRunner.class)
43-
@SpringApplicationConfiguration(classes = ApplicationConfiguration.class)
42+
@RunWith(SpringRunner.class)
43+
@SpringBootTest(classes = ApplicationConfiguration.class)
4444
public class ElasticsearchOperationsTest {
4545

4646
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/Application.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

jpa/eclipselink/src/test/java/example/springdata/jpa/eclipselink/CustomerRepositoryIntegrationTests.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,23 +18,22 @@
1818
import static org.hamcrest.CoreMatchers.*;
1919
import static org.junit.Assert.*;
2020

21-
import example.springdata.jpa.eclipselink.Application;
22-
import example.springdata.jpa.eclipselink.Customer;
23-
import example.springdata.jpa.eclipselink.CustomerRepository;
21+
import javax.transaction.Transactional;
2422

2523
import org.junit.Test;
2624
import org.junit.runner.RunWith;
2725
import org.springframework.beans.factory.annotation.Autowired;
28-
import org.springframework.boot.test.SpringApplicationConfiguration;
29-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
26+
import org.springframework.boot.test.context.SpringBootTest;
27+
import org.springframework.test.context.junit4.SpringRunner;
3028

3129
/**
3230
* Integration test for {@link CustomerRepository}.
3331
*
3432
* @author Oliver Gierke
3533
*/
36-
@RunWith(SpringJUnit4ClassRunner.class)
37-
@SpringApplicationConfiguration(classes = Application.class)
34+
@RunWith(SpringRunner.class)
35+
@SpringBootTest
36+
@Transactional
3837
public class CustomerRepositoryIntegrationTests {
3938

4039
@Autowired CustomerRepository customers;

jpa/example/src/main/java/example/springdata/jpa/caching/CachingConfiguration.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,24 +17,22 @@
1717

1818
import java.util.Arrays;
1919

20-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2121
import org.springframework.cache.Cache;
2222
import org.springframework.cache.CacheManager;
2323
import org.springframework.cache.annotation.EnableCaching;
2424
import org.springframework.cache.concurrent.ConcurrentMapCache;
2525
import org.springframework.cache.support.SimpleCacheManager;
2626
import org.springframework.context.annotation.Bean;
27-
import org.springframework.context.annotation.Configuration;
2827

2928
/**
3029
* Java config to use Spring Data JPA alongside the Spring caching support.
3130
*
3231
* @author Oliver Gierke
3332
* @author Thomas Darimont
3433
*/
35-
@Configuration
3634
@EnableCaching
37-
@EnableAutoConfiguration
35+
@SpringBootApplication
3836
class CachingConfiguration {
3937

4038
@Bean

jpa/example/src/main/java/example/springdata/jpa/custom/CustomRepositoryConfig.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,15 +15,13 @@
1515
*/
1616
package example.springdata.jpa.custom;
1717

18-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
19-
import org.springframework.context.annotation.Configuration;
18+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2019

2120
/**
2221
* Sample configuration to bootstrap Spring Data JPA through JavaConfig
2322
*
2423
* @author Thomas Darimont
2524
* @author Oliver Gierke
2625
*/
27-
@Configuration
28-
@EnableAutoConfiguration
26+
@SpringBootApplication
2927
class CustomRepositoryConfig {}

jpa/example/src/main/java/example/springdata/jpa/customall/CustomRepositoryConfig.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,8 +15,7 @@
1515
*/
1616
package example.springdata.jpa.customall;
1717

18-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
19-
import org.springframework.context.annotation.Configuration;
18+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2019
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
2120

2221
/**
@@ -27,7 +26,6 @@
2726
* @author Oliver Gierke
2827
* @soundtrack Tim Neuhaus - As life found you (The Cabinet)
2928
*/
30-
@Configuration
31-
@EnableAutoConfiguration
29+
@SpringBootApplication
3230
@EnableJpaRepositories(repositoryBaseClass = ExtendedJpaRepository.class)
3331
class CustomRepositoryConfig {}

jpa/example/src/main/java/example/springdata/jpa/simple/SimpleConfiguration.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
1515
*/
1616
package example.springdata.jpa.simple;
1717

18-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
19-
import org.springframework.context.annotation.Configuration;
18+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2019

2120
/**
2221
* @author Oliver Gierke
2322
*/
24-
@Configuration
25-
@EnableAutoConfiguration
23+
@SpringBootApplication
2624
class SimpleConfiguration {}

jpa/example/src/test/java/example/springdata/jpa/auditing/AuditableUserSample.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,18 +23,17 @@
2323
import org.springframework.beans.factory.annotation.Autowired;
2424
import org.springframework.boot.test.context.SpringBootTest;
2525
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
26-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
26+
import org.springframework.test.context.junit4.SpringRunner;
2727
import org.springframework.test.util.ReflectionTestUtils;
2828
import org.springframework.transaction.annotation.Transactional;
2929

3030
/**
3131
* @author Oliver Gierke
3232
* @author Thomas Darimont
3333
*/
34-
35-
@RunWith(SpringJUnit4ClassRunner.class)
34+
@RunWith(SpringRunner.class)
3635
@Transactional
37-
@SpringBootTest(classes = AuditingConfiguration.class)
36+
@SpringBootTest
3837
public class AuditableUserSample {
3938

4039
@Autowired AuditableUserRepository repository;

jpa/example/src/test/java/example/springdata/jpa/caching/CachingRepositoryTests.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,27 +21,23 @@
2121
import org.junit.Test;
2222
import org.junit.runner.RunWith;
2323
import org.springframework.beans.factory.annotation.Autowired;
24+
import org.springframework.boot.test.context.SpringBootTest;
2425
import org.springframework.cache.Cache;
2526
import org.springframework.cache.Cache.ValueWrapper;
2627
import org.springframework.cache.CacheManager;
2728
import org.springframework.cache.annotation.Cacheable;
28-
import org.springframework.test.context.ContextConfiguration;
29-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
29+
import org.springframework.test.context.junit4.SpringRunner;
3030
import org.springframework.transaction.annotation.Transactional;
3131

32-
import example.springdata.jpa.caching.CachingConfiguration;
33-
import example.springdata.jpa.caching.CachingUserRepository;
34-
import example.springdata.jpa.caching.User;
35-
3632
/**
3733
* Integration test to show how to use {@link Cacheable} with a Spring Data repository.
3834
*
3935
* @author Oliver Gierke
4036
* @author Thomas Darimont
4137
*/
42-
@RunWith(SpringJUnit4ClassRunner.class)
38+
@RunWith(SpringRunner.class)
4339
@Transactional
44-
@ContextConfiguration(classes = CachingConfiguration.class)
40+
@SpringBootTest
4541
public abstract class CachingRepositoryTests {
4642

4743
@Autowired CachingUserRepository repository;

jpa/example/src/test/java/example/springdata/jpa/custom/UserRepositoryCustomizationTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
2222
import org.junit.Test;
2323
import org.junit.runner.RunWith;
2424
import org.springframework.beans.factory.annotation.Autowired;
25-
import org.springframework.test.context.ContextConfiguration;
26-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
25+
import org.springframework.boot.test.context.SpringBootTest;
26+
import org.springframework.test.context.junit4.SpringRunner;
2727
import org.springframework.transaction.annotation.Transactional;
2828

2929
/**
@@ -32,9 +32,9 @@
3232
* @author Oliver Gierke
3333
* @author Thomas Darimont
3434
*/
35-
@RunWith(SpringJUnit4ClassRunner.class)
35+
@RunWith(SpringRunner.class)
3636
@Transactional
37-
@ContextConfiguration(classes = CustomRepositoryConfig.class)
37+
@SpringBootTest
3838
// @ActiveProfiles("jdbc") // Uncomment @ActiveProfiles to enable the JDBC Implementation of the custom repository
3939
public class UserRepositoryCustomizationTests {
4040

jpa/example/src/test/java/example/springdata/jpa/customall/UserRepositoryCustomizationTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
2121
import org.junit.Test;
2222
import org.junit.runner.RunWith;
2323
import org.springframework.beans.factory.annotation.Autowired;
24-
import org.springframework.test.context.ContextConfiguration;
25-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
import org.springframework.test.context.junit4.SpringRunner;
2626
import org.springframework.transaction.annotation.Transactional;
2727

2828
/**
@@ -31,9 +31,9 @@
3131
* @author Oliver Gierke
3232
* @soundtrack Elen - It's you (Elen)
3333
*/
34-
@RunWith(SpringJUnit4ClassRunner.class)
34+
@RunWith(SpringRunner.class)
3535
@Transactional
36-
@ContextConfiguration(classes = CustomRepositoryConfig.class)
36+
@SpringBootApplication
3737
public class UserRepositoryCustomizationTests {
3838

3939
@Autowired UserRepository repository;

jpa/example/src/test/java/example/springdata/jpa/simple/SimpleUserRepositoryTests.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,11 +28,11 @@
2828
import org.junit.Test;
2929
import org.junit.runner.RunWith;
3030
import org.springframework.beans.factory.annotation.Autowired;
31+
import org.springframework.boot.test.context.SpringBootTest;
3132
import org.springframework.data.domain.PageRequest;
3233
import org.springframework.data.domain.Slice;
3334
import org.springframework.data.domain.Sort;
34-
import org.springframework.test.context.ContextConfiguration;
35-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
35+
import org.springframework.test.context.junit4.SpringRunner;
3636
import org.springframework.transaction.annotation.Transactional;
3737

3838
/**
@@ -42,9 +42,9 @@
4242
* @author Thomas Darimont
4343
* @author Christoph Strobl
4444
*/
45-
@RunWith(SpringJUnit4ClassRunner.class)
45+
@RunWith(SpringRunner.class)
4646
@Transactional
47-
@ContextConfiguration(classes = SimpleConfiguration.class)
47+
@SpringBootTest
4848
public class SimpleUserRepositoryTests {
4949

5050
@Autowired SimpleUserRepository repository;

jpa/interceptors/src/main/java/example/springdata/jpa/interceptors/ApplicationConfiguration.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,18 +19,15 @@
1919
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
2020
import org.springframework.aop.interceptor.CustomizableTraceInterceptor;
2121
import org.springframework.aop.support.DefaultPointcutAdvisor;
22-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
2323
import org.springframework.context.annotation.Bean;
24-
import org.springframework.context.annotation.Configuration;
2524
import org.springframework.context.annotation.EnableAspectJAutoProxy;
2625

27-
@Configuration
26+
@SpringBootApplication
2827
@EnableAspectJAutoProxy
29-
@EnableAutoConfiguration
3028
public class ApplicationConfiguration {
3129

32-
@Bean
33-
public CustomizableTraceInterceptor interceptor() {
30+
public @Bean CustomizableTraceInterceptor interceptor() {
3431

3532
CustomizableTraceInterceptor interceptor = new CustomizableTraceInterceptor();
3633
interceptor.setEnterMessage("Entering $[methodName]($[arguments]).");
@@ -39,8 +36,7 @@ public CustomizableTraceInterceptor interceptor() {
3936
return interceptor;
4037
}
4138

42-
@Bean
43-
public Advisor traceAdvisor() {
39+
public @Bean Advisor traceAdvisor() {
4440

4541
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
4642
pointcut.setExpression("execution(public * org.springframework.data.repository.Repository+.*(..))");

jpa/interceptors/src/test/java/example/springdata/jpa/interceptors/InterceptorIntegrationTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@
1818
import org.junit.Test;
1919
import org.junit.runner.RunWith;
2020
import org.springframework.beans.factory.annotation.Autowired;
21-
import org.springframework.test.context.ContextConfiguration;
22-
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
21+
import org.springframework.boot.test.context.SpringBootTest;
22+
import org.springframework.test.context.junit4.SpringRunner;
2323

24-
@RunWith(SpringJUnit4ClassRunner.class)
25-
@ContextConfiguration(classes = ApplicationConfiguration.class)
24+
@RunWith(SpringRunner.class)
25+
@SpringBootTest
2626
public class InterceptorIntegrationTest {
2727

2828
@Autowired CustomerRepository repository;

0 commit comments

Comments
 (0)