forked from playframework/playframework
/
ControllerTest.java
44 lines (34 loc) · 1.13 KB
/
ControllerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (C) Lightbend Inc. <https://www.lightbend.com>
*/
package javaguide.tests;
// #test-controller-test
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static play.mvc.Http.Status.OK;
import static play.test.Helpers.*;
import javaguide.tests.controllers.HomeController;
import org.junit.Test;
import play.mvc.Result;
import play.twirl.api.Content;
public class ControllerTest {
@Test
public void testIndex() {
Result result = new HomeController().index();
assertEquals(OK, result.status());
assertEquals("text/html", result.contentType().get());
assertEquals("utf-8", result.charset().get());
assertTrue(contentAsString(result).contains("Welcome"));
}
// ###replace: }
// #test-controller-test
// #test-template
@Test
public void renderTemplate() {
// ###replace: Content html = views.html.index.render("Welcome to Play!");
Content html = javaguide.tests.html.index.render("Welcome to Play!");
assertEquals("text/html", html.contentType());
assertTrue(contentAsString(html).contains("Welcome to Play!"));
}
// #test-template
}