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
201da977
Commit
201da977
authored
Jan 09, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further refine test containers
parent
2c52b9e8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
161 additions
and
106 deletions
+161
-106
CassandraDataAutoConfigurationIntegrationTests.java
...andra/CassandraDataAutoConfigurationIntegrationTests.java
+4
-8
RedisRepositoriesAutoConfigurationTests.java
...e/data/redis/RedisRepositoriesAutoConfigurationTests.java
+3
-7
SessionAutoConfigurationRedisTests.java
...configure/session/SessionAutoConfigurationRedisTests.java
+1
-2
DataNeo4jTestIntegrationTests.java
...toconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java
+3
-7
DataNeo4jTestWithIncludeFilterIntegrationTests.java
...neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java
+3
-6
DataRedisTestIntegrationTests.java
...toconfigure/data/redis/DataRedisTestIntegrationTests.java
+3
-7
DataRedisTestWithIncludeFilterIntegrationTests.java
...redis/DataRedisTestWithIncludeFilterIntegrationTests.java
+3
-7
CassandraContainer.java
...k/boot/testsupport/testcontainers/CassandraContainer.java
+75
-0
Container.java
...gframework/boot/testsupport/testcontainers/Container.java
+24
-9
Neo4jContainer.java
...ework/boot/testsupport/testcontainers/Neo4jContainer.java
+9
-53
RedisContainer.java
...ework/boot/testsupport/testcontainers/RedisContainer.java
+33
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationIntegrationTests.java
View file @
201da977
...
...
@@ -22,14 +22,12 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.boot.autoconfigure.AutoConfigurationPackages
;
import
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration
;
import
org.springframework.boot.autoconfigure.data.cassandra.city.City
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.CassandraContainer
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.data.cassandra.config.CassandraSessionFactoryBean
;
import
org.springframework.data.cassandra.config.SchemaAction
;
...
...
@@ -45,16 +43,14 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
CassandraDataAutoConfigurationIntegrationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
cassandra
=
new
DockerTestContainer
<>(
TestContainers:
:
cassandra
);
public
static
CassandraContainer
cassandra
=
new
CassandraContainer
();
private
AnnotationConfigApplicationContext
context
;
@Before
public
void
setUp
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
TestPropertyValues
.
of
(
"spring.data.cassandra.port="
+
cassandra
.
getMappedPort
(
9042
))
TestPropertyValues
.
of
(
"spring.data.cassandra.port="
+
cassandra
.
getMappedPort
())
.
applyTo
(
this
.
context
.
getEnvironment
());
}
...
...
@@ -96,7 +92,7 @@ public class CassandraDataAutoConfigurationIntegrationTests {
}
private
void
createTestKeyspaceIfNotExists
()
{
Cluster
cluster
=
Cluster
.
builder
().
withPort
(
cassandra
.
getMappedPort
(
9042
))
Cluster
cluster
=
Cluster
.
builder
().
withPort
(
cassandra
.
getMappedPort
())
.
addContactPoint
(
"localhost"
).
build
();
try
(
Session
session
=
cluster
.
connect
())
{
session
.
execute
(
"CREATE KEYSPACE IF NOT EXISTS boot_test"
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java
View file @
201da977
...
...
@@ -20,7 +20,6 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.boot.autoconfigure.TestAutoConfigurationPackage
;
import
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
;
...
...
@@ -29,8 +28,7 @@ import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import
org.springframework.boot.autoconfigure.data.redis.city.City
;
import
org.springframework.boot.autoconfigure.data.redis.city.CityRepository
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.RedisContainer
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.repository.configuration.EnableRedisRepositories
;
...
...
@@ -45,15 +43,13 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
RedisRepositoriesAutoConfigurationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
redis
=
new
DockerTestContainer
<>(
TestContainers:
:
redis
);
public
static
RedisContainer
redis
=
new
RedisContainer
();
private
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
@Before
public
void
setUp
()
{
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
(
6379
))
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
())
.
applyTo
(
this
.
context
.
getEnvironment
());
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java
View file @
201da977
...
...
@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.session;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
...
...
@@ -48,7 +47,7 @@ public class SessionAutoConfigurationRedisTests
extends
AbstractSessionAutoConfigurationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
redis
=
new
DockerTestContainer
<>
(
public
static
DockerTestContainer
redis
=
new
DockerTestContainer
(
TestContainers:
:
redis
);
protected
final
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
()
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java
View file @
201da977
...
...
@@ -22,13 +22,11 @@ import org.junit.Test;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.neo4j.ogm.session.Session
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.Neo4jContainer
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
...
@@ -49,8 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
DataNeo4jTestIntegrationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
neo4j
=
new
DockerTestContainer
<>(
TestContainers:
:
neo4j
);
public
static
Neo4jContainer
neo4j
=
new
Neo4jContainer
();
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
...
...
@@ -87,8 +84,7 @@ public class DataNeo4jTestIntegrationTests {
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.data.neo4j.uri=bolt://localhost:"
+
neo4j
.
getMappedPort
(
7687
))
.
of
(
"spring.data.neo4j.uri=bolt://localhost:"
+
neo4j
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestWithIncludeFilterIntegrationTests.java
View file @
201da977
...
...
@@ -19,12 +19,10 @@ package org.springframework.boot.test.autoconfigure.data.neo4j;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.Neo4jContainer
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
...
...
@@ -45,8 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
DataNeo4jTestWithIncludeFilterIntegrationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
neo4j
=
new
DockerTestContainer
<>(
TestContainers:
:
neo4j
);
public
static
Neo4jContainer
neo4j
=
new
Neo4jContainer
();
@Autowired
private
ExampleService
service
;
...
...
@@ -63,7 +60,7 @@ public class DataNeo4jTestWithIncludeFilterIntegrationTests {
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.data.neo4j.uri=bolt://localhost:"
+
neo4j
.
getMappedPort
(
7687
))
.
of
(
"spring.data.neo4j.uri=bolt://localhost:"
+
neo4j
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java
View file @
201da977
...
...
@@ -24,13 +24,11 @@ import org.junit.Rule;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.RedisContainer
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
...
@@ -52,8 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
DataRedisTestIntegrationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
redis
=
new
DockerTestContainer
<>(
TestContainers:
:
redis
);
public
static
RedisContainer
redis
=
new
RedisContainer
();
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
...
...
@@ -93,8 +90,7 @@ public class DataRedisTestIntegrationTests {
@Override
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
(
6379
))
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java
View file @
201da977
...
...
@@ -19,12 +19,10 @@ package org.springframework.boot.test.autoconfigure.data.redis;
import
org.junit.ClassRule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.testcontainers.containers.GenericContainer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.testsupport.testcontainers.DockerTestContainer
;
import
org.springframework.boot.testsupport.testcontainers.TestContainers
;
import
org.springframework.boot.testsupport.testcontainers.RedisContainer
;
import
org.springframework.context.ApplicationContextInitializer
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
...
...
@@ -45,8 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
DataRedisTestWithIncludeFilterIntegrationTests
{
@ClassRule
public
static
DockerTestContainer
<
GenericContainer
<?>>
redis
=
new
DockerTestContainer
<>(
TestContainers:
:
redis
);
public
static
RedisContainer
redis
=
new
RedisContainer
();
@Autowired
private
ExampleRepository
exampleRepository
;
...
...
@@ -69,8 +66,7 @@ public class DataRedisTestWithIncludeFilterIntegrationTests {
@Override
public
void
initialize
(
ConfigurableApplicationContext
configurableApplicationContext
)
{
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
(
6379
))
TestPropertyValues
.
of
(
"spring.redis.port="
+
redis
.
getMappedPort
())
.
applyTo
(
configurableApplicationContext
.
getEnvironment
());
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java
0 → 100644
View file @
201da977
/*
* Copyright 2012-2018 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
.
testsupport
.
testcontainers
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.TimeUnit
;
import
com.datastax.driver.core.Cluster
;
import
com.datastax.driver.core.exceptions.NoHostAvailableException
;
import
org.rnorth.ducttape.TimeoutException
;
import
org.rnorth.ducttape.unreliables.Unreliables
;
import
org.testcontainers.containers.GenericContainer
;
import
org.testcontainers.containers.wait.HostPortWaitStrategy
;
/**
* A {@link GenericContainer} for Cassandra.
*
* @author Andy Wilkinson
* @author Madhura Bhave
*/
public
class
CassandraContainer
extends
Container
{
private
static
final
int
PORT
=
9042
;
public
CassandraContainer
()
{
super
(
"cassandra:3.11.1"
,
PORT
,
(
container
)
->
container
.
waitingFor
(
new
WaitStrategy
()));
}
private
static
class
WaitStrategy
extends
HostPortWaitStrategy
{
@Override
protected
void
waitUntilReady
()
{
super
.
waitUntilReady
();
try
{
Unreliables
.
retryUntilTrue
((
int
)
this
.
startupTimeout
.
getSeconds
(),
TimeUnit
.
SECONDS
,
checkConnection
());
}
catch
(
TimeoutException
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
private
Callable
<
Boolean
>
checkConnection
()
{
return
()
->
{
try
(
Cluster
cluster
=
Cluster
.
builder
()
.
withPort
(
this
.
container
.
getMappedPort
(
PORT
))
.
addContactPoint
(
"localhost"
).
build
())
{
cluster
.
connect
();
return
true
;
}
catch
(
IllegalArgumentException
|
NoHostAvailableException
ex
)
{
return
false
;
}
};
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/
DockerTest
Container.java
→
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/Container.java
View file @
201da977
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
testsupport
.
testcontainers
;
import
java.util.function.Consumer
;
import
java.util.function.Supplier
;
import
org.junit.AssumptionViolatedException
;
...
...
@@ -29,17 +30,31 @@ import org.testcontainers.containers.GenericContainer;
* {@link TestRule} for working with an optional Docker environment. Spins up a
* {@link GenericContainer} if a valid docker environment is found.
*
* @param <T> the type of the container
* @author Madhura Bhave
* @author Phillip Webb
*/
public
class
DockerTestContainer
<
T
extends
GenericContainer
<?>>
implements
TestRule
{
class
Container
implements
TestRule
{
private
final
Supplier
<
T
>
containerSupplier
;
private
final
int
port
;
private
T
container
;
private
final
Supplier
<
GenericContainer
<?>>
containerFactory
;
public
DockerTestContainer
(
Supplier
<
T
>
containerSupplier
)
{
this
.
containerSupplier
=
containerSupplier
;
private
GenericContainer
<?>
container
;
<
T
extends
GenericContainer
<
T
>>
Container
(
String
dockerImageName
,
int
port
)
{
this
(
dockerImageName
,
port
,
null
);
}
@SuppressWarnings
({
"unchecked"
,
"resource"
})
<
T
extends
GenericContainer
<
T
>>
Container
(
String
dockerImageName
,
int
port
,
Consumer
<
T
>
customizer
)
{
this
.
port
=
port
;
this
.
containerFactory
=
()
->
{
T
container
=
(
T
)
new
GenericContainer
<>(
dockerImageName
)
.
withExposedPorts
(
port
);
customizer
.
accept
(
container
);
return
container
;
};
}
@Override
...
...
@@ -50,12 +65,12 @@ public class DockerTestContainer<T extends GenericContainer<?>> implements TestR
catch
(
Throwable
t
)
{
return
new
SkipStatement
();
}
this
.
container
=
this
.
container
Supplier
.
get
();
this
.
container
=
this
.
container
Factory
.
get
();
return
this
.
container
.
apply
(
base
,
description
);
}
public
int
getMappedPort
(
int
originalPort
)
{
return
this
.
container
.
getMappedPort
(
originalP
ort
);
public
int
getMappedPort
()
{
return
this
.
container
.
getMappedPort
(
this
.
p
ort
);
}
private
static
class
SkipStatement
extends
Statement
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/
TestContainers
.java
→
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/
Neo4jContainer
.java
View file @
201da977
...
...
@@ -19,8 +19,6 @@ package org.springframework.boot.testsupport.testcontainers;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.TimeUnit
;
import
com.datastax.driver.core.Cluster
;
import
com.datastax.driver.core.exceptions.NoHostAvailableException
;
import
org.neo4j.ogm.config.Configuration
;
import
org.neo4j.ogm.session.SessionFactory
;
import
org.rnorth.ducttape.TimeoutException
;
...
...
@@ -29,69 +27,26 @@ import org.testcontainers.containers.GenericContainer;
import
org.testcontainers.containers.wait.HostPortWaitStrategy
;
/**
* Provides utility methods that allow creation of docker containers for
* tests.
* A {@link GenericContainer} for Neo4J.
*
* @author Andy Wilkinson
* @author Madhura Bhave
*/
public
abstract
class
TestContainers
{
public
class
Neo4jContainer
extends
Container
{
@SuppressWarnings
(
"resource"
)
public
static
GenericContainer
<?>
redis
()
{
return
new
GenericContainer
<>(
"redis:4.0.6"
).
withExposedPorts
(
6379
);
public
Neo4jContainer
()
{
super
(
"neo4j:3.3.1"
,
7687
,
(
container
)
->
container
.
waitingFor
(
new
WaitStrategy
())
.
withEnv
(
"NEO4J_AUTH"
,
"none"
)
);
}
@SuppressWarnings
(
"resource"
)
public
static
GenericContainer
<?>
cassandra
()
{
return
new
GenericContainer
<>(
"cassandra:3.11.1"
).
withExposedPorts
(
9042
)
.
waitingFor
(
new
CassandraConnectionVerifyingWaitStrategy
());
}
public
static
GenericContainer
<?>
neo4j
()
{
return
new
GenericContainer
<>(
"neo4j:3.3.1"
).
withExposedPorts
(
7687
)
.
waitingFor
(
new
Neo4jConnectionVerifyingWaitStrategy
())
.
withEnv
(
"NEO4J_AUTH"
,
"none"
);
}
private
static
class
CassandraConnectionVerifyingWaitStrategy
extends
HostPortWaitStrategy
{
@Override
protected
void
waitUntilReady
()
{
super
.
waitUntilReady
();
try
{
Unreliables
.
retryUntilTrue
((
int
)
this
.
startupTimeout
.
getSeconds
(),
TimeUnit
.
SECONDS
,
checkConnection
());
}
catch
(
TimeoutException
ex
)
{
throw
new
IllegalStateException
(
ex
);
}
}
private
Callable
<
Boolean
>
checkConnection
()
{
return
()
->
{
try
(
Cluster
cluster
=
Cluster
.
builder
().
withPort
(
this
.
container
.
getMappedPort
(
9042
))
.
addContactPoint
(
"localhost"
)
.
build
())
{
cluster
.
connect
();
return
true
;
}
catch
(
IllegalArgumentException
|
NoHostAvailableException
ex
)
{
return
false
;
}
};
}
}
private
static
class
Neo4jConnectionVerifyingWaitStrategy
extends
HostPortWaitStrategy
{
private
static
class
WaitStrategy
extends
HostPortWaitStrategy
{
@Override
protected
void
waitUntilReady
()
{
super
.
waitUntilReady
();
Configuration
configuration
=
new
Configuration
.
Builder
()
.
uri
(
"bolt://localhost:"
+
this
.
container
.
getMappedPort
(
7687
)).
build
();
.
uri
(
"bolt://localhost:"
+
this
.
container
.
getMappedPort
(
7687
))
.
build
();
SessionFactory
sessionFactory
=
new
SessionFactory
(
configuration
,
"org.springframework.boot.test.autoconfigure.data.neo4j"
);
try
{
...
...
@@ -114,6 +69,7 @@ public abstract class TestContainers {
}
};
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/RedisContainer.java
0 → 100644
View file @
201da977
/*
* Copyright 2012-2018 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
.
testsupport
.
testcontainers
;
import
org.testcontainers.containers.GenericContainer
;
/**
* A {@link GenericContainer} for Redis.
*
* @author Andy Wilkinson
* @author Madhura Bhave
*/
public
class
RedisContainer
extends
Container
{
public
RedisContainer
()
{
super
(
"redis:4.0.6"
,
6379
);
}
}
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