Skip to content

Commit

Permalink
Return future from launcher starting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjohnson-kint committed Jul 25, 2018
1 parent 750e147 commit 7335acb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/main/java/org/folio/circulation/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void main(String[] args) throws

Integer port = Integer.getInteger("port", 9801);

launcher.start(port);
launcher.start(port).get(10, TimeUnit.SECONDS);
}

private void stop() {
Expand All @@ -51,10 +51,7 @@ public CompletableFuture<Void> undeploy() {
return vertxAssistant.undeployVerticle(moduleDeploymentId);
}

public void start(Integer port) throws
InterruptedException,
ExecutionException,
TimeoutException {
public CompletableFuture<Void> start(Integer port) {

if(port == null) {
throw new IllegalArgumentException("port should not be null");
Expand All @@ -70,8 +67,8 @@ public void start(Integer port) throws
CompletableFuture<String> deployed =
vertxAssistant.deployVerticle(CirculationVerticle.class, config);

deployed.thenAccept(result -> log.info("Server Started"));

moduleDeploymentId = deployed.get(10, TimeUnit.SECONDS);
return deployed
.thenApply(result -> moduleDeploymentId = result)
.thenAccept(result -> log.info("Server Started"));
}
}
9 changes: 6 additions & 3 deletions src/test/java/api/APITestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ public static void before()
} else {
fakeStorageModuleDeployed = CompletableFuture.completedFuture(null);
}

launcher.start(port);

fakeOkapiDeploymentId = fakeStorageModuleDeployed.get(10, TimeUnit.SECONDS);
final CompletableFuture<Void> circulationModuleStarted = launcher.start(port);

fakeStorageModuleDeployed.thenAccept(result -> fakeOkapiDeploymentId = result);

CompletableFuture.allOf(circulationModuleStarted, fakeStorageModuleDeployed)
.get(10, TimeUnit.SECONDS);

createMaterialTypes();
createLoanTypes();
Expand Down

0 comments on commit 7335acb

Please sign in to comment.