@Test
public void testProxy() throws Exception
{
count = 0;
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(generateBaseUrl());
target.register(BrowserCacheFeature.class);
MyProxy proxy = target.proxy(MyProxy.class);
String rtn = null;
rtn = proxy.get();
Assert.assertEquals("hello world" + 1, rtn);
Assert.assertEquals(1, count);
rtn = proxy.get();
Assert.assertEquals("hello world" + 1, rtn);
Assert.assertEquals(1, count);
Thread.sleep(2000);
rtn = proxy.get();
Assert.assertEquals("hello world" + 2, rtn);
Assert.assertEquals(2, count);
rtn = proxy.get();
Assert.assertEquals("hello world" + 2, rtn);
Assert.assertEquals(2, count);
// Test always good etag
count = 0;
rtn = proxy.getAlwaysGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(1, count);
rtn = proxy.getAlwaysGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(1, count);
Thread.sleep(2000);
rtn = proxy.getAlwaysGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(2, count);
rtn = proxy.getAlwaysGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(2, count);
// Test never good etag
count = 0;
rtn = proxy.getNeverGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(1, count);
rtn = proxy.getNeverGoodEtag();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(1, count);
Thread.sleep(2000);
rtn = proxy.getNeverGoodEtag();
Assert.assertEquals("hello2", rtn);
Assert.assertEquals(2, count);
rtn = proxy.getNeverGoodEtag();
Assert.assertEquals("hello2", rtn);
Assert.assertEquals(2, count);
// Test always validate etag
count = 0;
rtn = proxy.getValidateEtagged();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(1, count);
rtn = proxy.getValidateEtagged();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(2, count);
rtn = proxy.getValidateEtagged();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(3, count);
rtn = proxy.getValidateEtagged();
Assert.assertEquals("hello1", rtn);
Assert.assertEquals(4, count);
client.close();
}