Skip to content

Commit a07b88f

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. Also not create more servers and clients than necessary. Closes #5851
1 parent 9a399e2 commit a07b88f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

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

Lines changed: 9 additions & 14 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,19 +78,14 @@ public HttpBandwidthLimitingTest(double protoVersion, Function<Vertx, HttpServer
7878
this.nonTrafficShapedServerFactory = nonTrafficShapedServerFactory;
7979
}
8080

81-
@Before
82-
public void setUp() throws Exception {
83-
super.setUp();
84-
server = serverFactory.apply(vertx);
85-
client = clientFactory.apply(vertx);
81+
@Override
82+
protected HttpClientAgent createHttpClient() {
83+
return clientFactory.apply(vertx);
8684
}
8785

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);
86+
@Override
87+
protected HttpServer createHttpServer() {
88+
return serverFactory.apply(vertx);
9489
}
9590

9691
@Test

0 commit comments

Comments
 (0)