SampleETagResource { @GET("/etag/{name}") public ETagSampleObject get(String name) { return new ETagSampleObject(name); }  @GET("/etag/{name}") ETagSampleObject get(String name);  }
@Test public void should_provide_etag() throws Exception { HttpRequest request = client().GET("/api/etag/test1"); assertHttpResponse(request, 200, "{\n \"name\" : \"test1\"\n}"); assertThat(request.header("ETag")).isEqualTo("5a105e8b9d40e1329780d62ea2265d8a"); }
@Test public void should_304_on_provided_etag() throws Exception { HttpRequest request = client().GET("/api/etag/test1").header("If-None-Match", "5a105e8b9d40e1329780d62ea2265d8a"); assertThat(request.code()).isEqualTo(304); }
@Test public void should_reply_on_bad_provided_etag() throws Exception { HttpRequest request = client().GET("/api/etag/test1").header("If-None-Match", "123456"); assertHttpResponse(request, 200, "{\n \"name\" : \"test1\"\n}"); }