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
aebaa580
Commit
aebaa580
authored
Jan 09, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for user overriding @EnableJpaRepositories
parent
c8152bfc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
JpaRepositoriesAutoConfigurationTests.java
...configure/data/JpaRepositoriesAutoConfigurationTests.java
+24
-0
CityRepository.java
...framework/boot/autoconfigure/data/alt/CityRepository.java
+24
-0
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/JpaRepositoriesAutoConfigurationTests.java
View file @
aebaa580
...
...
@@ -28,6 +28,7 @@ import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurat
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.jpa.repository.config.EnableJpaRepositories
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
...
@@ -56,10 +57,33 @@ public class JpaRepositoriesAutoConfigurationTests {
assertNotNull
(
this
.
context
.
getBean
(
EntityManagerFactory
.
class
));
}
@Test
public
void
testOverrideRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
CustomConfiguration
.
class
,
ComponentScanDetectorConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
HibernateJpaAutoConfiguration
.
class
,
JpaRepositoriesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertNotNull
(
this
.
context
.
getBean
(
org
.
springframework
.
boot
.
autoconfigure
.
data
.
alt
.
CityRepository
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
PlatformTransactionManager
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
EntityManagerFactory
.
class
));
}
@Configuration
@ComponentScan
(
basePackageClasses
=
City
.
class
)
protected
static
class
TestConfiguration
{
}
@Configuration
@EnableJpaRepositories
(
basePackageClasses
=
org
.
springframework
.
boot
.
autoconfigure
.
data
.
alt
.
CityRepository
.
class
)
@ComponentScan
(
basePackageClasses
=
City
.
class
)
protected
static
class
CustomConfiguration
{
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/alt/CityRepository.java
0 → 100644
View file @
aebaa580
/*
* Copyright 2012-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
data
.
alt
;
import
org.springframework.boot.autoconfigure.data.jpa.City
;
import
org.springframework.data.repository.Repository
;
public
interface
CityRepository
extends
Repository
<
City
,
Long
>
{
}
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