/*
* Equivalent to IframePage.test_cacheability in sockjs-protocol-0.3.3.py.
*/
@Test
public void iframeCachability() throws Exception {
final SockJsServiceFactory factory = echoService();
EmbeddedChannel ch = channelForMockService(factory.config());
ch.writeInbound(httpRequest(factory.config().prefix() + "/iframe.html"));
final String etag1 = getEtag((FullHttpResponse) ch.readOutbound());
ch = channelForMockService(factory.config());
ch.writeInbound(httpRequest(factory.config().prefix() + "/iframe.html"));
final String etag2 = getEtag((FullHttpResponse) ch.readOutbound());
assertThat(etag1, equalTo(etag2));
final FullHttpRequest requestWithEtag = httpRequest(factory.config().prefix() + "/iframe.html");
requestWithEtag.headers().set(IF_NONE_MATCH, etag1);
ch = channelForMockService(factory.config());
ch.writeInbound(requestWithEtag);
final FullHttpResponse response = ch.readOutbound();
assertThat(response.getStatus(), equalTo(HttpResponseStatus.NOT_MODIFIED));
assertThat(response.headers().get(CONTENT_TYPE), is(nullValue()));
assertThat(response.content().isReadable(), is(false));