Skip to content

Commit ee9ac57

Browse files
committed
Ensure setup is only called once
It is called from the AsyncTestBase's @before. No explicit teardown necessary, as Vert.x instances are closed automatically via AsyncTestBase's @after. Also not create more servers and clients than necessary. Closes #5851 (cherry picked from commit a07b88f)
1 parent 16ba3c6 commit ee9ac57

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/test/java/io/vertx/core/http/HttpBandwidthLimitingTest.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public static Iterable<Object[]> data() {
6969
});
7070
}
7171

72-
private Function<Vertx, HttpServer> serverFactory;
73-
private Function<Vertx, HttpClient> clientFactory;
74-
private Function<Vertx, HttpServer> nonTrafficShapedServerFactory;
72+
private final Function<Vertx, HttpServer> serverFactory;
73+
private final Function<Vertx, HttpClient> clientFactory;
74+
private final Function<Vertx, HttpServer> nonTrafficShapedServerFactory;
7575

7676
public HttpBandwidthLimitingTest(double protoVersion, Function<Vertx, HttpServer> serverFactory,
7777
Function<Vertx, HttpClient> clientFactory,
@@ -81,21 +81,15 @@ public HttpBandwidthLimitingTest(double protoVersion, Function<Vertx, HttpServer
8181
this.nonTrafficShapedServerFactory = nonTrafficShapedServerFactory;
8282
}
8383

84-
@Before
84+
@Override
8585
public void setUp() throws Exception {
8686
super.setUp();
87+
server.close();
8788
server = serverFactory.apply(vertx);
89+
client.close();
8890
client = clientFactory.apply(vertx);
8991
}
9092

91-
@After
92-
public void after() throws InterruptedException
93-
{
94-
CountDownLatch waitForClose = new CountDownLatch(1);
95-
vertx.close().onComplete(onSuccess(resp -> waitForClose.countDown()));
96-
awaitLatch(waitForClose);
97-
}
98-
9993
@Test
10094
public void sendBufferThrottled() throws Exception {
10195
Buffer expectedBuffer = TestUtils.randomBuffer(TEST_CONTENT_SIZE);

0 commit comments

Comments
 (0)