Skip to content

Commit bc34930

Browse files
ahus1vietj
authored andcommitted
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. Closes #5851 (cherry picked from commit a07b88f)
1 parent 16ba3c6 commit bc34930

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

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

Lines changed: 8 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,17 @@ 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+
CountDownLatch waitForServerClose = new CountDownLatch(1);
88+
server.close().onComplete(onSuccess(resp -> waitForServerClose.countDown()));
8789
server = serverFactory.apply(vertx);
90+
CountDownLatch waitForClientClose = new CountDownLatch(1);
91+
client.close().onComplete(onSuccess(resp -> waitForClientClose.countDown()));
8892
client = clientFactory.apply(vertx);
8993
}
9094

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-
9995
@Test
10096
public void sendBufferThrottled() throws Exception {
10197
Buffer expectedBuffer = TestUtils.randomBuffer(TEST_CONTENT_SIZE);

0 commit comments

Comments
 (0)