Skip to content

Commit

Permalink
Expose getter/setter for serverPort to facilitate testing (#7480)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccozzolino authored and wing328 committed Jan 24, 2018
1 parent fe22472 commit 0b2d805
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ import io.vertx.core.Vertx;
import io.vertx.ext.web.Router;

public class MainApiVerticle extends AbstractVerticle {
final static Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class);
final static Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class);
private int serverPort = {{serverPort}};
protected Router router;

public int getServerPort() {
return serverPort;
}

public void setServerPort(int serverPort) {
this.serverPort = serverPort;
}

@Override
public void init(Vertx vertx, Context context) {
super.init(vertx, context);
Expand All @@ -37,13 +46,18 @@ public class MainApiVerticle extends AbstractVerticle {
if (readFile.succeeded()) {
Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
deployVerticles(startFuture);
vertx.createHttpServer()
vertx.createHttpServer()
.requestHandler(swaggerRouter::accept)
.listen({{serverPort}});
startFuture.complete();
.listen(serverPort, h -> {
if (h.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(h.cause());
}
});
} else {
startFuture.fail(readFile.cause());
}
Expand Down

0 comments on commit 0b2d805

Please # to comment.