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
4a97b385
Commit
4a97b385
authored
Nov 30, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated code
Closes gh-6563
parent
2dbebf67
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
384 deletions
+0
-384
AutoConfigureTestDatabase.java
...test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java
+0
-84
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+0
-5
DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java
...ureTestDatabaseReplaceAutoConfiguredIntegrationTests.java
+0
-75
DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java
...ReplaceAutoConfiguredWithoutOverrideIntegrationTests.java
+0
-67
DataJpaTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java
...ConfigureTestDatabaseReplaceExplicitIntegrationTests.java
+0
-86
DataJpaTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java
...AutoConfigureTestDatabaseReplaceNoneIntegrationTests.java
+0
-67
No files found.
spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/AutoConfigureTestDatabase.java
deleted
100644 → 0
View file @
2dbebf67
/*
* Copyright 2012-2016 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
.
test
.
autoconfigure
.
orm
.
jpa
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
javax.sql.DataSource
;
import
org.springframework.boot.autoconfigure.ImportAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection
;
import
org.springframework.boot.test.autoconfigure.properties.PropertyMapping
;
/**
* Annotation that can be applied to a test class to configure a test database to use
* instead of any application defined or auto-configured {@link DataSource}.
*
* @author Stephane Nicoll
* @deprecated since 1.5 in favour of {@link org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase}
*/
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@ImportAutoConfiguration
@PropertyMapping
(
"spring.test.database"
)
@Deprecated
public
@interface
AutoConfigureTestDatabase
{
/**
* Determines what type of existing DataSource beans can be replaced.
* @return the type of existing DataSource to replace
*/
Replace
replace
()
default
Replace
.
ANY
;
/**
* The type of connection to be established when {@link #replace() replacing} the data
* source. By default will attempt to detect the connection based on the classpath.
* @return the type of connection to use
*/
EmbeddedDatabaseConnection
connection
()
default
EmbeddedDatabaseConnection
.
NONE
;
/**
* What the test database can replace.
*/
@Deprecated
enum
Replace
{
/**
* Replace any DataSource bean (auto-configured or manually defined).
*/
ANY
,
/**
* Only replace auto-configured DataSource.
*/
AUTO_CONFIGURED
,
/**
* Don't replace the application default DataSource.
*/
NONE
}
}
spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
4a97b385
...
...
@@ -51,11 +51,6 @@ org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerAuto
org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs=\
org.springframework.boot.test.autoconfigure.restdocs.RestDocsAutoConfiguration
# AutoConfigureTestDatabase auto-configuration imports
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase=\
org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
# AutoConfigureTestEntityManager auto-configuration imports
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager=\
org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration
...
...
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests.java
deleted
100644 → 0
View file @
2dbebf67
/*
* Copyright 2012-2016 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
.
test
.
autoconfigure
.
orm
.
jpa
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase.Replace
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Integration tests for {@link DataJpaTest}.
*
* @author Phillip Webb
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
@AutoConfigureTestDatabase
(
replace
=
Replace
.
AUTO_CONFIGURED
,
connection
=
EmbeddedDatabaseConnection
.
HSQL
)
@Deprecated
public
class
DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests
{
@Autowired
private
TestEntityManager
entities
;
@Autowired
private
ExampleRepository
repository
;
@Autowired
private
DataSource
dataSource
;
@Test
public
void
testRepository
()
throws
Exception
{
this
.
entities
.
persist
(
new
ExampleEntity
(
"spring"
,
"123"
));
this
.
entities
.
persist
(
new
ExampleEntity
(
"boot"
,
"124"
));
this
.
entities
.
flush
();
ExampleEntity
found
=
this
.
repository
.
findByReference
(
"124"
);
assertThat
(
found
.
getName
()).
isEqualTo
(
"boot"
);
}
@Test
public
void
replacesAutoConfiguredDataSource
()
throws
Exception
{
String
product
=
this
.
dataSource
.
getConnection
().
getMetaData
()
.
getDatabaseProductName
();
assertThat
(
product
).
startsWith
(
"HSQL"
);
}
@Configuration
@EnableAutoConfiguration
// Will auto-configure H2
static
class
Config
{
}
}
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests.java
deleted
100644 → 0
View file @
2dbebf67
/*
* Copyright 2012-2016 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
.
test
.
autoconfigure
.
orm
.
jpa
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase.Replace
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Integration tests for {@link DataJpaTest}.
*
* @author Phillip Webb
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
@AutoConfigureTestDatabase
(
replace
=
Replace
.
AUTO_CONFIGURED
)
@Deprecated
public
class
DataJpaTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredWithoutOverrideIntegrationTests
{
@Autowired
private
TestEntityManager
entities
;
@Autowired
private
ExampleRepository
repository
;
@Autowired
private
DataSource
dataSource
;
@Test
public
void
testRepository
()
throws
Exception
{
this
.
entities
.
persist
(
new
ExampleEntity
(
"spring"
,
"123"
));
this
.
entities
.
persist
(
new
ExampleEntity
(
"boot"
,
"124"
));
this
.
entities
.
flush
();
ExampleEntity
found
=
this
.
repository
.
findByReference
(
"124"
);
assertThat
(
found
.
getName
()).
isEqualTo
(
"boot"
);
}
@Test
public
void
usesDefaultEmbeddedDatabase
()
throws
Exception
{
String
product
=
this
.
dataSource
.
getConnection
().
getMetaData
()
.
getDatabaseProductName
();
// @AutoConfigureTestDatabase would use H2 but HSQL is manually defined
assertThat
(
product
).
startsWith
(
"HSQL"
);
}
}
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests.java
deleted
100644 → 0
View file @
2dbebf67
/*
* Copyright 2012-2016 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
.
test
.
autoconfigure
.
orm
.
jpa
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder
;
import
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Integration tests for {@link DataJpaTest}.
*
* @author Phillip Webb
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
@AutoConfigureTestDatabase
(
connection
=
EmbeddedDatabaseConnection
.
HSQL
)
@Deprecated
public
class
DataJpaTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests
{
@Autowired
private
TestEntityManager
entities
;
@Autowired
private
ExampleRepository
repository
;
@Autowired
private
DataSource
dataSource
;
@Test
public
void
testRepository
()
throws
Exception
{
this
.
entities
.
persist
(
new
ExampleEntity
(
"spring"
,
"123"
));
this
.
entities
.
persist
(
new
ExampleEntity
(
"boot"
,
"124"
));
this
.
entities
.
flush
();
ExampleEntity
found
=
this
.
repository
.
findByReference
(
"124"
);
assertThat
(
found
.
getName
()).
isEqualTo
(
"boot"
);
}
@Test
public
void
replacesDefinedDataSourceWithExplicit
()
throws
Exception
{
// H2 is explicitly defined but HSQL is the override.
String
product
=
this
.
dataSource
.
getConnection
().
getMetaData
()
.
getDatabaseProductName
();
assertThat
(
product
).
startsWith
(
"HSQL"
);
}
@Configuration
@EnableAutoConfiguration
static
class
Config
{
@Bean
public
DataSource
dataSource
()
{
EmbeddedDatabaseBuilder
builder
=
new
EmbeddedDatabaseBuilder
()
.
generateUniqueName
(
true
)
.
setType
(
EmbeddedDatabaseType
.
H2
);
return
builder
.
build
();
}
}
}
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests.java
deleted
100644 → 0
View file @
2dbebf67
/*
* Copyright 2012-2016 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
.
test
.
autoconfigure
.
orm
.
jpa
;
import
javax.sql.DataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase.Replace
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Integration tests for {@link DataJpaTest}.
*
* @author Phillip Webb
*/
@RunWith
(
SpringRunner
.
class
)
@DataJpaTest
@AutoConfigureTestDatabase
(
replace
=
Replace
.
NONE
)
@Deprecated
public
class
DataJpaTestWithAutoConfigureTestDatabaseReplaceNoneIntegrationTests
{
@Autowired
private
TestEntityManager
entities
;
@Autowired
private
ExampleRepository
repository
;
@Autowired
private
DataSource
dataSource
;
@Test
public
void
testRepository
()
throws
Exception
{
this
.
entities
.
persist
(
new
ExampleEntity
(
"spring"
,
"123"
));
this
.
entities
.
persist
(
new
ExampleEntity
(
"boot"
,
"124"
));
this
.
entities
.
flush
();
ExampleEntity
found
=
this
.
repository
.
findByReference
(
"124"
);
assertThat
(
found
.
getName
()).
isEqualTo
(
"boot"
);
}
@Test
public
void
usesDefaultEmbeddedDatabase
()
throws
Exception
{
// HSQL is explicitly defined and should not be replaced
String
product
=
this
.
dataSource
.
getConnection
().
getMetaData
()
.
getDatabaseProductName
();
assertThat
(
product
).
startsWith
(
"HSQL"
);
}
}
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