src/test/java/edu/ucla/library/bucketeer/verticles/FesterVerticleTest.java
private void startTestServer(final Handler<RoutingContext> aHandler, final Promise<Void> aPromise) {
        final Router router = Router.router(myVertx);

        // We have to have a body handler or our router handling will not work
        router.route().handler(BodyHandler.create());

        // Create a route that handles POSTs from our FesterVerticle
        router.post("/collections").handler(aHandler);

        // Start the test server that's now configured with the test handler
        myServer = myVertx.createHttpServer().requestHandler(router).listen(myPort, listen -> {
            if (listen.succeeded()) {
                // Configure our FesterVerticle to POST to our test server's port
                final DeploymentOptions options = new DeploymentOptions().setConfig(myConfig);

                // Deploy the verticle we want to test
                myVertx.deployVerticle(FesterVerticle.class.getName(), options, deployment -> {
                    if (deployment.succeeded()) {
                        aPromise.complete();
                    } else {
                        aPromise.fail(deployment.cause());
                    }
                });
            } else {
                aPromise.fail(listen.cause());
            }
        });
    }
/**
     * Configure a test server for running our test against.
     *
     * @param aHandler An HttpServerRequest handler
     * @param aPromise A promise to complete after the server has started
     */
Configure a test server for running our test against.
@param aHandler An HttpServerRequest handler
@param aPromise A promise to complete after the server has started
Configure a test server for running our test against . @param aHandler An HttpServerRequest handler @param aPromise A promise to complete after the server has started
private void startTestServer(final Handler<RoutingContext> aHandler, final Promise<Void> aPromise) {
        final Router router = Router.router(myVertx);
        router.route().handler(BodyHandler.create());
        router.post("/collections").handler(aHandler);
        myServer = myVertx.createHttpServer().requestHandler(router).listen(myPort, listen -> {
            if (listen.succeeded()) {
                final DeploymentOptions options = new DeploymentOptions().setConfig(myConfig);
                myVertx.deployVerticle(FesterVerticle.class.getName(), options, deployment -> {
                    if (deployment.succeeded()) {
                        aPromise.complete();
                    } else {
                        aPromise.fail(deployment.cause());
                    }
                });
            } else {
                aPromise.fail(listen.cause());
            }
        });
    }
private void startTestServer ( final Handler < RoutingContext > aHandler , final Promise < Void > aPromise ) { final Router router = Router . router ( myVertx ) ; router . route ( ) . handler ( BodyHandler . create ( ) ) ; router . post ( "/collections" ) . handler ( aHandler ) ; myServer = myVertx . createHttpServer ( ) . requestHandler ( router ) . listen ( myPort , listen -> { if ( listen . succeeded ( ) ) { final DeploymentOptions options = new DeploymentOptions ( ) . setConfig ( myConfig ) ; myVertx . deployVerticle ( FesterVerticle . class . getName ( ) , options , deployment -> { if ( deployment . succeeded ( ) ) { aPromise . complete ( ) ; } else { aPromise . fail ( deployment . cause ( ) ) ; } } ) ; } else { aPromise . fail ( listen . cause ( ) ) ; } } ) ; }
Configure a test server for running our test against.
Configure a test server for running our test against .
// We have to have a body handler or our router handling will not work // Create a route that handles POSTs from our FesterVerticle // Start the test server that's now configured with the test handler // Configure our FesterVerticle to POST to our test server's port // Deploy the verticle we want to test