java-tutorials/web-modules/ninja/src/test/java/controllers/ApiControllerDocTesterUnitTest.java

28 lines
877 B
Java
Raw Normal View History

2019-12-01 18:29:04 +02:00
package controllers;
2019-12-08 14:40:42 +02:00
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
2019-12-01 18:29:04 +02:00
import org.doctester.testbrowser.Request;
import org.doctester.testbrowser.Response;
2019-12-08 14:40:42 +02:00
import org.junit.Test;
import ninja.NinjaDocTester;
2019-12-01 18:29:04 +02:00
public class ApiControllerDocTesterUnitTest extends NinjaDocTester {
2019-12-01 18:29:04 +02:00
String URL_INDEX = "/";
2019-12-08 14:40:42 +02:00
String URL_HELLO = "/hello";
2019-12-01 18:29:04 +02:00
@Test
public void testGetIndex() {
2019-12-08 14:40:42 +02:00
Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_INDEX)));
2019-12-14 16:34:34 +02:00
assertThat(response.payload, containsString("Hello, welcome to Ninja Framework!"));
2019-12-01 18:29:04 +02:00
}
@Test
2019-12-08 14:40:42 +02:00
public void testGetHello() {
Response response = makeRequest(Request.GET().url(testServerUrl().path(URL_HELLO)));
2019-12-14 16:34:34 +02:00
assertThat(response.payload, containsString("Bonjour, bienvenue dans Ninja Framework!"));
2019-12-01 18:29:04 +02:00
}
2019-12-01 18:29:04 +02:00
}