|
22 | 22 | import java.util.List;
|
23 | 23 | import java.util.Map;
|
24 | 24 | import java.util.Properties;
|
| 25 | +import java.util.concurrent.ExecutionException; |
25 | 26 |
|
26 | 27 | import org.apache.kafka.clients.admin.NewTopic;
|
27 | 28 | import org.apache.kafka.clients.consumer.ConsumerConfig;
|
|
38 | 39 | import org.springframework.kafka.core.ProducerFactory;
|
39 | 40 | import org.springframework.kafka.test.rule.EmbeddedKafkaRule;
|
40 | 41 | import org.springframework.kafka.test.utils.KafkaTestUtils;
|
| 42 | +import org.springframework.util.concurrent.ListenableFuture; |
41 | 43 |
|
42 | 44 | import static org.hamcrest.Matchers.containsInAnyOrder;
|
43 | 45 | import static org.hamcrest.Matchers.is;
|
@@ -269,15 +271,20 @@ public void testReadFromSinglePartitionAfterRestart() {
|
269 | 271 | }
|
270 | 272 |
|
271 | 273 | @Test
|
272 |
| - public void testReadFromMultiplePartitionsAfterRestart() { |
273 |
| - this.template.send("topic4", 0, null, "val0"); |
274 |
| - this.template.send("topic4", 0, null, "val2"); |
275 |
| - this.template.send("topic4", 0, null, "val4"); |
276 |
| - this.template.send("topic4", 0, null, "val6"); |
277 |
| - this.template.send("topic4", 1, null, "val1"); |
278 |
| - this.template.send("topic4", 1, null, "val3"); |
279 |
| - this.template.send("topic4", 1, null, "val5"); |
280 |
| - this.template.send("topic4", 1, null, "val7"); |
| 274 | + public void testReadFromMultiplePartitionsAfterRestart() throws ExecutionException, InterruptedException { |
| 275 | + List<ListenableFuture> futures = new ArrayList<>(); |
| 276 | + futures.add(this.template.send("topic4", 0, null, "val0")); |
| 277 | + futures.add(this.template.send("topic4", 0, null, "val2")); |
| 278 | + futures.add(this.template.send("topic4", 0, null, "val4")); |
| 279 | + futures.add(this.template.send("topic4", 0, null, "val6")); |
| 280 | + futures.add(this.template.send("topic4", 1, null, "val1")); |
| 281 | + futures.add(this.template.send("topic4", 1, null, "val3")); |
| 282 | + futures.add(this.template.send("topic4", 1, null, "val5")); |
| 283 | + futures.add(this.template.send("topic4", 1, null, "val7")); |
| 284 | + |
| 285 | + for (ListenableFuture future : futures) { |
| 286 | + future.get(); |
| 287 | + } |
281 | 288 |
|
282 | 289 | ExecutionContext executionContext = new ExecutionContext();
|
283 | 290 | Map<TopicPartition, Long> offsets = new HashMap<>();
|
|
0 commit comments