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
b7700ed0
Commit
b7700ed0
authored
May 14, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve reliability of kafka sample integration test
parent
91f7a2b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
SampleKafkaApplicationTests.java
...c/test/java/sample/kafka/SampleKafkaApplicationTests.java
+7
-7
No files found.
spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java
View file @
b7700ed0
...
@@ -16,10 +16,9 @@
...
@@ -16,10 +16,9 @@
package
sample
.
kafka
;
package
sample
.
kafka
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.RegisterExtension
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.extension.OutputCapture
;
import
org.springframework.kafka.test.context.EmbeddedKafka
;
import
org.springframework.kafka.test.context.EmbeddedKafka
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -36,17 +35,18 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -36,17 +35,18 @@ import static org.assertj.core.api.Assertions.assertThat;
@EmbeddedKafka
(
topics
=
"testTopic"
)
@EmbeddedKafka
(
topics
=
"testTopic"
)
class
SampleKafkaApplicationTests
{
class
SampleKafkaApplicationTests
{
@
RegisterExtension
@
Autowired
OutputCapture
output
=
new
OutputCapture
()
;
private
Consumer
consumer
;
@Test
@Test
void
testVanillaExchange
()
throws
Exception
{
void
testVanillaExchange
()
throws
Exception
{
long
end
=
System
.
currentTimeMillis
()
+
3
0000
;
long
end
=
System
.
currentTimeMillis
()
+
1
0000
;
while
(
!
this
.
output
.
toString
().
contains
(
"A simple test message"
)
while
(
this
.
consumer
.
getMessages
().
isEmpty
(
)
&&
System
.
currentTimeMillis
()
<
end
)
{
&&
System
.
currentTimeMillis
()
<
end
)
{
Thread
.
sleep
(
250
);
Thread
.
sleep
(
250
);
}
}
assertThat
(
this
.
output
).
contains
(
"A simple test message"
);
assertThat
(
this
.
consumer
.
getMessages
()).
extracting
(
"message"
)
.
containsOnly
(
"A simple test message"
);
}
}
}
}
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