java-tutorials/web-modules/play-modules/routing-in-play/test/controllers/HomeControllerUnitTest.java

37 lines
980 B
Java
Raw Normal View History

package controllers;
import org.junit.Test;
import play.Application;
import play.inject.guice.GuiceApplicationBuilder;
import play.mvc.Http;
import play.mvc.Result;
import play.test.WithApplication;
import play.twirl.api.Html;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static play.mvc.Http.Status.*;
import static play.test.Helpers.GET;
import static play.test.Helpers.route;
public class HomeControllerUnitTest extends WithApplication {
@Override
protected Application provideApplication() {
return new GuiceApplicationBuilder().build();
}
@Test
public void givenRequest_whenRootPath_ThenStatusOkay() {
Http.RequestBuilder request = new Http.RequestBuilder()
.method(GET)
.uri("/");
Result result = route(app, request);
assertEquals(OK, result.status());
}
}