Merge pull request #27 from matzew/random_port

Using random port for http server launch
This commit is contained in:
Matthias Wessendorf 2018-12-18 14:07:54 +01:00 committed by GitHub
commit e8f6419e8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 8 deletions

View File

@ -32,9 +32,9 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.URI;
import java.util.List;
import java.util.logging.Logger;
import static io.cloudevents.SpecVersion.V_01;
import static io.cloudevents.SpecVersion.V_02;
@ -43,6 +43,15 @@ import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(VertxExtension.class)
class VertxCloudEventsTests {
private int port;
@BeforeEach
void setUp(Vertx vertx, VertxTestContext testContext) throws IOException {
ServerSocket socket = new ServerSocket(0);
port = socket.getLocalPort();
socket.close();
testContext.completeNow();
}
@Test
@DisplayName("Post a 0.2 CloudEvents object with a payload")
void cloudEventWithPayload(Vertx vertx, VertxTestContext testContext) {
@ -76,7 +85,7 @@ class VertxCloudEventsTests {
req.response().end();
serverCheckpoint.flag();
})))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
// create client to POST a CloudEvent to the server
@ -128,7 +137,7 @@ class VertxCloudEventsTests {
req.response().end();
serverCheckpoint.flag();
})))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
// create client to POST a CloudEvent to the server
@ -181,7 +190,7 @@ class VertxCloudEventsTests {
req.response().end();
serverCheckpoint.flag();
})))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
// create client to POST a CloudEvent to the server
@ -214,7 +223,7 @@ class VertxCloudEventsTests {
serverCheckpoint.flag();
}
}))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
@ -273,7 +282,7 @@ class VertxCloudEventsTests {
req.response().end();
serverCheckpoint.flag();
})))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
// create client to POST a CloudEvent to the server
@ -316,7 +325,7 @@ class VertxCloudEventsTests {
req.response().end();
serverCheckpoint.flag();
})))
.rxListen(8080)
.rxListen(port)
.doOnError(testContext::failNow)
.subscribe(server -> {
// create client to POST a CloudEvent to the server