Skip to content

Commit 735c4f2

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 ad40676 commit 735c4f2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

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

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

69-
private Function<Vertx, HttpServer> serverFactory;
70-
private Function<Vertx, HttpClientAgent> clientFactory;
71-
private Function<Vertx, HttpServer> nonTrafficShapedServerFactory;
69+
private final Function<Vertx, HttpServer> serverFactory;
70+
private final Function<Vertx, HttpClientAgent> clientFactory;
71+
private final Function<Vertx, HttpServer> nonTrafficShapedServerFactory;
7272

7373
public HttpBandwidthLimitingTest(double protoVersion, Function<Vertx, HttpServer> serverFactory,
7474
Function<Vertx, HttpClientAgent> clientFactory,
@@ -78,21 +78,15 @@ public HttpBandwidthLimitingTest(double protoVersion, Function<Vertx, HttpServer
7878
this.nonTrafficShapedServerFactory = nonTrafficShapedServerFactory;
7979
}
8080

81-
@Before
81+
@Override
8282
public void setUp() throws Exception {
8383
super.setUp();
84+
server.close().await();
8485
server = serverFactory.apply(vertx);
86+
client.close().await();
8587
client = clientFactory.apply(vertx);
8688
}
8789

88-
@After
89-
public void after() throws InterruptedException
90-
{
91-
CountDownLatch waitForClose = new CountDownLatch(1);
92-
vertx.close().onComplete(onSuccess(resp -> waitForClose.countDown()));
93-
awaitLatch(waitForClose);
94-
}
95-
9690
@Test
9791
public void sendBufferThrottled() throws Exception {
9892
Buffer expectedBuffer = TestUtils.randomBuffer(TEST_CONTENT_SIZE);

0 commit comments

Comments
 (0)