Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9a457527
Commit
9a457527
authored
Jun 09, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish test
parent
36a05375
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
JpaWebAutoConfigurationTests.java
.../autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java
+20
-22
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java
View file @
9a457527
...
@@ -16,21 +16,21 @@
...
@@ -16,21 +16,21 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
jpa
;
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
jpa
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.autoconfigure.TestAutoConfigurationPackage
;
import
org.springframework.boot.autoconfigure.TestAutoConfigurationPackage
;
import
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.data.jpa.city.City
;
import
org.springframework.boot.autoconfigure.data.jpa.city.City
;
import
org.springframework.boot.autoconfigure.data.jpa.city.CityRepository
;
import
org.springframework.boot.autoconfigure.data.jpa.city.CityRepository
;
import
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
;
import
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.
EmbeddedDataSource
Configuration
;
import
org.springframework.boot.autoconfigure.jdbc.
DataSourceAuto
Configuration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.geo.Distance
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.data.web.PageableHandlerMethodArgumentResolver
;
import
org.springframework.data.web.SortHandlerMethodArgumentResolver
;
import
org.springframework.format.support.FormattingConversionService
;
import
org.springframework.format.support.FormattingConversionService
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -40,33 +40,31 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -40,33 +40,31 @@ import static org.assertj.core.api.Assertions.assertThat;
* {@link JpaRepositoriesAutoConfiguration}.
* {@link JpaRepositoriesAutoConfiguration}.
*
*
* @author Dave Syer
* @author Dave Syer
* @author Stephane Nicoll
*/
*/
public
class
JpaWebAutoConfigurationTests
{
public
class
JpaWebAutoConfigurationTests
{
private
AnnotationConfigWebApplicationContext
context
;
private
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
.
withConfiguration
(
@After
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
,
public
void
close
()
{
JpaRepositoriesAutoConfiguration
.
class
,
SpringDataWebAutoConfiguration
.
class
))
this
.
context
.
close
();
.
withPropertyValues
(
"spring.datasource.generate-unique-name=true"
);
}
@Test
@Test
public
void
testDefaultRepositoryConfiguration
()
{
public
void
springDataWebIsConfiguredWithJpaRepositories
()
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
contextRunner
.
withUserConfiguration
(
TestConfiguration
.
class
).
run
((
context
)
->
{
this
.
context
.
setServletContext
(
new
MockServletContext
());
assertThat
(
context
).
hasSingleBean
(
CityRepository
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
assertThat
(
context
).
hasSingleBean
(
PageableHandlerMethodArgumentResolver
.
class
);
HibernateJpaAutoConfiguration
.
class
,
JpaRepositoriesAutoConfiguration
.
class
,
assertThat
(
context
).
hasSingleBean
(
SortHandlerMethodArgumentResolver
.
class
);
SpringDataWebAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
assertThat
(
context
.
getBean
(
FormattingConversionService
.
class
).
canConvert
(
String
.
class
,
Distance
.
class
))
this
.
context
.
refresh
();
.
isTrue
();
assertThat
(
this
.
context
.
getBean
(
CityRepository
.
class
)).
isNotNull
();
});
assertThat
(
this
.
context
.
getBean
(
PageableHandlerMethodArgumentResolver
.
class
)).
isNotNull
();
assertThat
(
this
.
context
.
getBean
(
FormattingConversionService
.
class
).
canConvert
(
Long
.
class
,
City
.
class
)).
isTrue
();
}
}
@Configuration
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
@TestAutoConfigurationPackage
(
City
.
class
)
@EnableWebMvc
@EnableWebMvc
protected
static
class
TestConfiguration
{
static
class
TestConfiguration
{
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment