All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.java.AppTest Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
import com.jetdrone.vertx.yoke.Yoke;
import com.jetdrone.vertx.yoke.Middleware;
import com.jetdrone.vertx.yoke.middleware.YokeRequest;
import com.jetdrone.vertx.yoke.test.Response;
import com.jetdrone.vertx.yoke.test.YokeTester;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.vertx.java.core.Handler;
import org.vertx.testtools.TestVerticle;

import static org.vertx.testtools.VertxAssert.*;

public class AppTest extends TestVerticle {

    @Test
    public void testApp() {
        final Yoke yoke = new Yoke(this);
        yoke.use(new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler next) {
                request.response().end("OK");
            }
        });

        final YokeTester yokeAssert = new YokeTester(yoke);

        yokeAssert.request("GET", "/", new Handler() {
            @Override
            public void handle(Response response) {
                assertEquals("OK", response.body.toString());
                testComplete();
            }
        });
    }
}