File tree Expand file tree Collapse file tree
demo-kafka/src/test/java/com/helltractor/demo/messaging Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import org .springframework .beans .factory .annotation .Autowired ;
1313import org .springframework .boot .test .context .SpringBootTest ;
1414import org .springframework .context .annotation .Lazy ;
15+ import org .springframework .test .annotation .DirtiesContext ;
1516
1617import java .util .List ;
1718import java .util .concurrent .atomic .AtomicInteger ;
1819
1920import static org .junit .jupiter .api .Assertions .assertEquals ;
2021
2122@ SpringBootTest (classes = KafkaApplication .class )
23+ @ DirtiesContext (classMode = DirtiesContext .ClassMode .AFTER_EACH_TEST_METHOD )
2224public class MessagingTest {
2325
2426 final static Logger logger = LoggerFactory .getLogger (MessagingTest .class );
@@ -66,7 +68,7 @@ int getTotalMessages() {
6668
6769 @ Test
6870 void test () throws InterruptedException {
69- for (int i = 0 ; i < 1000 ; i ++) {
71+ for (int i = 0 ; i < 100 ; i ++) {
7072 TestMessage testMessage = new TestMessage ();
7173 testMessage .message = "Test-" + i ;
7274 processorOne .sendMessages (testMessage );
@@ -81,6 +83,6 @@ void test() throws InterruptedException {
8183 }
8284
8385 Thread .sleep (10000 );
84- assertEquals (3000 , testConsumer .getTotalMessages ());
86+ assertEquals (300 , testConsumer .getTotalMessages ());
8587 }
8688}
You can’t perform that action at this time.
0 commit comments