Skip to content

Commit 6f6da91

Browse files
committed
Fix test by re-adding fixtures
1 parent 490d077 commit 6f6da91

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/com/rabbitmq/stream/impl/SuperStreamConsumerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
import static com.rabbitmq.stream.impl.TestUtils.b;
1717
import static com.rabbitmq.stream.impl.TestUtils.declareSuperStreamTopology;
18+
import static com.rabbitmq.stream.impl.TestUtils.deleteSuperStreamTopology;
1819
import static com.rabbitmq.stream.impl.TestUtils.latchAssert;
20+
import static com.rabbitmq.stream.impl.TestUtils.localhost;
1921
import static org.assertj.core.api.Assertions.assertThat;
2022

2123
import com.rabbitmq.client.Connection;
24+
import com.rabbitmq.client.ConnectionFactory;
2225
import com.rabbitmq.stream.Consumer;
2326
import com.rabbitmq.stream.Environment;
27+
import com.rabbitmq.stream.EnvironmentBuilder;
2428
import com.rabbitmq.stream.OffsetSpecification;
2529
import com.rabbitmq.stream.impl.Client.ClientParameters;
2630
import io.netty.channel.EventLoopGroup;
@@ -31,7 +35,10 @@
3135
import java.util.concurrent.ConcurrentMap;
3236
import java.util.concurrent.CountDownLatch;
3337
import java.util.concurrent.atomic.AtomicInteger;
38+
import org.junit.jupiter.api.AfterEach;
39+
import org.junit.jupiter.api.BeforeEach;
3440
import org.junit.jupiter.api.Test;
41+
import org.junit.jupiter.api.TestInfo;
3542
import org.junit.jupiter.api.extension.ExtendWith;
3643

3744
@ExtendWith(TestUtils.StreamTestInfrastructureExtension.class)
@@ -47,6 +54,26 @@ public class SuperStreamConsumerTest {
4754
String[] routingKeys = null;
4855
TestUtils.ClientFactory cf;
4956

57+
@BeforeEach
58+
void init(TestInfo info) throws Exception {
59+
EnvironmentBuilder environmentBuilder = Environment.builder().eventLoopGroup(eventLoopGroup);
60+
environmentBuilder.addressResolver(add -> localhost());
61+
environment = environmentBuilder.build();
62+
superStream = TestUtils.streamName(info);
63+
connection = new ConnectionFactory().newConnection();
64+
}
65+
66+
@AfterEach
67+
void tearDown() throws Exception {
68+
environment.close();
69+
if (routingKeys == null) {
70+
deleteSuperStreamTopology(connection, superStream, partitionCount);
71+
} else {
72+
deleteSuperStreamTopology(connection, superStream, routingKeys);
73+
}
74+
connection.close();
75+
}
76+
5077
private static void publishToPartitions(
5178
TestUtils.ClientFactory cf, List<String> partitions, int messageCount) {
5279
CountDownLatch publishLatch = new CountDownLatch(messageCount);

0 commit comments

Comments
 (0)