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
c9b2afbd
Commit
c9b2afbd
authored
Apr 24, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
760b5e85
f39cea04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
CassandraContainer.java
...k/boot/testsupport/testcontainers/CassandraContainer.java
+12
-5
Neo4jContainer.java
...ework/boot/testsupport/testcontainers/Neo4jContainer.java
+15
-6
No files found.
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/CassandraContainer.java
View file @
c9b2afbd
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
testsupport
.
testcontainers
;
import
java.time.Duration
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -24,7 +25,7 @@ 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
;
import
org.testcontainers.containers.wait.
strategy.
HostPortWaitStrategy
;
/**
* A {@link GenericContainer} for Cassandra.
...
...
@@ -38,13 +39,20 @@ public class CassandraContainer extends Container {
public
CassandraContainer
()
{
super
(
"cassandra:3.11.1"
,
PORT
,
(
container
)
->
container
.
waitingFor
(
new
WaitStrategy
()).
withStartupAttempts
(
3
));
.
waitingFor
(
new
WaitStrategy
(
container
.
getMappedPort
(
PORT
)))
.
withStartupAttempts
(
3
).
withStartupTimeout
(
Duration
.
ofSeconds
(
60
)));
}
private
static
class
WaitStrategy
extends
HostPortWaitStrategy
{
private
final
int
port
;
private
WaitStrategy
(
int
port
)
{
this
.
port
=
port
;
}
@Override
public
void
waitUntilReady
(
GenericContainer
container
)
{
public
void
waitUntilReady
()
{
super
.
waitUntilReady
();
try
{
...
...
@@ -58,8 +66,7 @@ public class CassandraContainer extends Container {
private
Callable
<
Boolean
>
checkConnection
()
{
return
()
->
{
try
(
Cluster
cluster
=
Cluster
.
builder
()
.
withPort
(
container
.
getMappedPort
(
PORT
))
try
(
Cluster
cluster
=
Cluster
.
builder
().
withPort
(
this
.
port
)
.
addContactPoint
(
"localhost"
).
build
())
{
cluster
.
connect
();
return
true
;
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/Neo4jContainer.java
View file @
c9b2afbd
...
...
@@ -24,7 +24,7 @@ import org.neo4j.ogm.session.SessionFactory;
import
org.rnorth.ducttape.TimeoutException
;
import
org.rnorth.ducttape.unreliables.Unreliables
;
import
org.testcontainers.containers.GenericContainer
;
import
org.testcontainers.containers.wait.HostPortWaitStrategy
;
import
org.testcontainers.containers.wait.
strategy.
HostPortWaitStrategy
;
/**
* A {@link GenericContainer} for Neo4J.
...
...
@@ -34,19 +34,28 @@ import org.testcontainers.containers.wait.HostPortWaitStrategy;
*/
public
class
Neo4jContainer
extends
Container
{
private
static
final
int
PORT
=
7687
;
public
Neo4jContainer
()
{
super
(
"neo4j:3.3.1"
,
7687
,
(
container
)
->
container
.
waitingFor
(
new
WaitStrategy
())
.
withEnv
(
"NEO4J_AUTH"
,
"none"
));
super
(
"neo4j:3.3.1"
,
PORT
,
(
container
)
->
container
.
waitingFor
(
new
WaitStrategy
(
container
.
getMappedPort
(
PORT
)))
.
withEnv
(
"NEO4J_AUTH"
,
"none"
));
}
private
static
class
WaitStrategy
extends
HostPortWaitStrategy
{
private
final
int
port
;
private
WaitStrategy
(
int
port
)
{
this
.
port
=
port
;
}
@Override
public
void
waitUntilReady
(
GenericContainer
container
)
{
public
void
waitUntilReady
()
{
super
.
waitUntilReady
();
Configuration
configuration
=
new
Configuration
.
Builder
()
.
uri
(
"bolt://localhost:"
+
container
.
getMappedPort
(
7687
))
.
build
();
.
uri
(
"bolt://localhost:"
+
this
.
port
).
build
();
SessionFactory
sessionFactory
=
new
SessionFactory
(
configuration
,
"org.springframework.boot.test.autoconfigure.data.neo4j"
);
try
{
...
...
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