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
c6a1df6c
Commit
c6a1df6c
authored
Feb 11, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
parents
d9ec48ef
93a6dfd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
JpaBaseConfiguration.java
...work/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java
+3
-1
AbstractJpaAutoConfigurationTests.java
...oconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
+55
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java
View file @
c6a1df6c
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -39,6 +39,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type
;
import
org.springframework.boot.autoconfigure.domain.EntityScanPackages
;
import
org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers
;
import
org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -211,6 +212,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
@ConditionalOnClass
(
WebMvcConfigurer
.
class
)
@ConditionalOnMissingBean
({
OpenEntityManagerInViewInterceptor
.
class
,
OpenEntityManagerInViewFilter
.
class
})
@ConditionalOnMissingFilterBean
(
OpenEntityManagerInViewFilter
.
class
)
@ConditionalOnProperty
(
prefix
=
"spring.jpa"
,
name
=
"open-in-view"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
protected
static
class
JpaWebConfiguration
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java
View file @
c6a1df6c
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -37,6 +37,7 @@ import org.springframework.boot.test.context.assertj.AssertableApplicationContex
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.context.runner.ContextConsumer
;
import
org.springframework.boot.test.context.runner.WebApplicationContextRunner
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -158,6 +159,32 @@ public abstract class AbstractJpaAutoConfigurationTests {
.
doesNotHaveBean
(
OpenEntityManagerInViewInterceptor
.
class
));
}
@Test
public
void
openEntityManagerInViewInterceptorIsNotRegisteredWhenFilterRegistrationPresent
()
{
new
WebApplicationContextRunner
()
.
withPropertyValues
(
"spring.datasource.generate-unique-name=true"
)
.
withUserConfiguration
(
TestFilterRegistrationConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
,
TransactionAutoConfiguration
.
class
,
this
.
autoConfiguredClass
))
.
run
((
context
)
->
assertThat
(
context
)
.
doesNotHaveBean
(
OpenEntityManagerInViewInterceptor
.
class
));
}
@Test
public
void
openEntityManagerInViewInterceptorAutoConfigurationBacksOffWhenManuallyRegistered
()
{
new
WebApplicationContextRunner
()
.
withPropertyValues
(
"spring.datasource.generate-unique-name=true"
)
.
withUserConfiguration
(
TestInterceptorManualConfiguration
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
DataSourceAutoConfiguration
.
class
,
TransactionAutoConfiguration
.
class
,
this
.
autoConfiguredClass
))
.
run
((
context
)
->
assertThat
(
context
)
.
getBean
(
OpenEntityManagerInViewInterceptor
.
class
)
.
isExactlyInstanceOf
(
TestInterceptorManualConfiguration
.
ManualOpenEntityManagerInViewInterceptor
.
class
));
}
@Test
public
void
openEntityManagerInViewInterceptorISNotRegisteredWhenExplicitlyOff
()
{
new
WebApplicationContextRunner
()
...
...
@@ -295,6 +322,33 @@ public abstract class AbstractJpaAutoConfigurationTests {
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestFilterRegistrationConfiguration
{
@Bean
public
FilterRegistrationBean
<
OpenEntityManagerInViewFilter
>
OpenEntityManagerInViewFilterFilterRegistrationBean
()
{
return
new
FilterRegistrationBean
<>();
}
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestInterceptorManualConfiguration
{
@Bean
public
OpenEntityManagerInViewInterceptor
openEntityManagerInViewInterceptor
()
{
return
new
ManualOpenEntityManagerInViewInterceptor
();
}
protected
static
class
ManualOpenEntityManagerInViewInterceptor
extends
OpenEntityManagerInViewInterceptor
{
}
}
@Configuration
protected
static
class
TestConfigurationWithLocalContainerEntityManagerFactoryBean
extends
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