use of play.mvc.Http.Response in project play-cookbook by spinscale.
the class UserRightTest method testSecretsAreDeniedForUnknownUser.
@Test
public void testSecretsAreDeniedForUnknownUser() {
Response response = GET("/secret");
assertStatus(404, response);
}
use of play.mvc.Http.Response in project play-cookbook by spinscale.
the class JsonRenderTest method testThatJsonRenderingWorks.
@Test
public void testThatJsonRenderingWorks() {
Response response = GET("/user/1");
assertIsOk(response);
User user = new Gson().fromJson(getContent(response), User.class);
assertNotNull(user);
assertNull(user.password);
assertNull(user.secrets);
assertEquals(user.login, "alex");
assertEquals(user.address.city, "Munich");
assertContentMatch("\"uri\":\"/user/1\"", response);
}
use of play.mvc.Http.Response in project play-cookbook by spinscale.
the class FeedTest method testThatRss10Works.
@Test
public void testThatRss10Works() throws Exception {
Response response = GET("/feed/posts.rss");
assertIsOk(response);
assertContentType("application/rss+xml", response);
assertCharset("utf-8", response);
SyndFeed feed = getFeed(response);
assertEquals("rss_1.0", feed.getFeedType());
}
use of play.mvc.Http.Response in project play-cookbook by spinscale.
the class CachingTest method testThatCachingWholePageWorks.
@Test
public void testThatCachingWholePageWorks() throws Exception {
Response response = GET("/cacheFor");
String content = getContent(response);
response = GET("/cacheFor");
assertEquals(content, getContent(response));
Thread.sleep(6000);
response = GET("/cacheFor");
assertNotSame(content, getContent(response));
}
use of play.mvc.Http.Response in project play-cookbook by spinscale.
the class CachingTest method testThatEtagCachingWorks.
@Test
public void testThatEtagCachingWorks() {
Response response = GET("/etagCache/123");
assertIsOk(response);
assertContentEquals("Learn to use etags, dumbass!", response);
Request request = newRequest();
String etag = String.valueOf("123".hashCode());
Header noneMatchHeader = new Header("if-none-match", etag);
request.headers.put("if-none-match", noneMatchHeader);
DateTime ago = new DateTime().minusHours(12);
String agoStr = Utils.getHttpDateFormatter().format(ago.toDate());
Header modifiedHeader = new Header("if-modified-since", agoStr);
request.headers.put("if-modified-since", modifiedHeader);
response = GET(request, "/etagCache/123");
assertStatus(304, response);
}
Aggregations