Skip to content

Commit

Permalink
(#547) Applied changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
svettwer committed Dec 17, 2018
1 parent e4609b8 commit b5daaf9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
Expand Up @@ -34,9 +34,6 @@
@Test
public class WaitJavaIT extends TestNGCitrusTestDesigner {

/** Random http server port */
private final static int serverPort = SocketUtils.findAvailableTcpPort();

@CitrusEndpoint(name = "waitHttpServer")
@HttpServerConfig
private HttpServer httpServer;
Expand All @@ -52,9 +49,7 @@ public void waitFile() throws IOException {
public void waitHttpDeprecated() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand All @@ -78,9 +73,7 @@ public void waitHttpDeprecated() {
public void waitHttpAsAction() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand All @@ -104,9 +97,7 @@ public void waitHttpAsAction() {
public void waitHttp() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand Down Expand Up @@ -151,4 +142,12 @@ public void apply() {
}
});
}

private String startHttpServerAndGetUrl() {
final int serverPort = SocketUtils.findAvailableTcpPort();
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
return server;
}
}
Expand Up @@ -33,9 +33,6 @@
@Test
public class WaitTestRunnerIT extends TestNGCitrusTestRunner {

/** Random http server port */
private final static int serverPort = SocketUtils.findAvailableTcpPort();

@CitrusEndpoint(name = "waitHttpServer")
@HttpServerConfig
private HttpServer httpServer;
Expand All @@ -51,9 +48,7 @@ public void waitFile() throws IOException {
public void waitHttpDeprecated() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand All @@ -77,9 +72,7 @@ public void waitHttpDeprecated() {
public void waitHttpAsAction() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand All @@ -103,9 +96,7 @@ public void waitHttpAsAction() {
public void waitHttp() {

//GIVEN
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
String server = startHttpServerAndGetUrl();

parallel().actions(
sequential().actions(
Expand Down Expand Up @@ -150,4 +141,12 @@ public void apply() {
}
});
}

private String startHttpServerAndGetUrl() {
final int serverPort = SocketUtils.findAvailableTcpPort();
String server = String.format("http://localhost:%s", serverPort);
httpServer.setPort(serverPort);
start(httpServer);
return server;
}
}

0 comments on commit b5daaf9

Please sign in to comment.