Skip to content

Commit 6592086

Browse files
authored
autocloseable test pair (#317)
1 parent c275d19 commit 6592086

25 files changed

+34
-26
lines changed

avaje-jex-test/src/main/java/io/avaje/jex/test/TestPair.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import io.avaje.jex.Jex;
88

99
/** Server and Client pair for a test. */
10-
public class TestPair {
10+
public class TestPair implements AutoCloseable {
1111

1212
private final int port;
1313

@@ -23,6 +23,7 @@ public TestPair(int port, Jex.Server server, HttpClient client) {
2323

2424
public void shutdown() {
2525
server.shutdown();
26+
client.close();
2627
}
2728

2829
public HttpClientRequest request() {
@@ -48,4 +49,9 @@ public static TestPair create(Jex app) {
4849

4950
return new TestPair(port, jexServer, client);
5051
}
52+
53+
@Override
54+
public void close() throws Exception {
55+
shutdown();
56+
}
5157
}

avaje-jex/src/test/java/io/avaje/jex/CtxPathTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static TestPair init() {
2121

2222
@AfterAll
2323
static void end() {
24-
pair.shutdown();
24+
pair.close();
2525
}
2626

2727
@Test

avaje-jex/src/test/java/io/avaje/jex/SpiRouteTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ void get() {
2525
HttpResponse<String> res = pair.request().path("spi").GET().asString();
2626

2727
assertThat(res.body()).isEqualTo("hello from spi");
28-
pair.shutdown();
28+
pair.close();
2929
}
3030
}

avaje-jex/src/test/java/io/avaje/jex/compression/CompressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static TestPair init() {
4040

4141
@AfterAll
4242
static void end() {
43-
pair.shutdown();
43+
pair.close();
4444
}
4545

4646
@Test

avaje-jex/src/test/java/io/avaje/jex/core/CharacterEncodingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static TestPair init() {
2424

2525
@AfterAll
2626
static void end() {
27-
pair.shutdown();
27+
pair.close();
2828
}
2929

3030
@Test

avaje-jex/src/test/java/io/avaje/jex/core/ContextAttributeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static TestPair init() {
5454

5555
@AfterAll
5656
static void end() {
57-
pair.shutdown();
57+
pair.close();
5858
}
5959

6060
@Test

avaje-jex/src/test/java/io/avaje/jex/core/ContextFormParamTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static TestPair init() {
2525

2626
@AfterAll
2727
static void end() {
28-
pair.shutdown();
28+
pair.close();
2929
}
3030

3131
@Test

avaje-jex/src/test/java/io/avaje/jex/core/ContextLengthTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static TestPair init() {
2828

2929
@AfterAll
3030
static void end() {
31-
pair.shutdown();
31+
pair.close();
3232
}
3333

3434
@Test

avaje-jex/src/test/java/io/avaje/jex/core/ContextRequestTooBigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static TestPair init() {
2626

2727
@AfterAll
2828
static void end() {
29-
pair.shutdown();
29+
pair.close();
3030
}
3131

3232
@Test

avaje-jex/src/test/java/io/avaje/jex/core/ContextTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static TestPair init() {
5959

6060
@AfterAll
6161
static void end() {
62-
pair.shutdown();
62+
pair.close();
6363
}
6464

6565
@Test

0 commit comments

Comments
 (0)