BayeuxClient client = newBayeuxClient();
client.handshake();
assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));
long maxAge = 1;
HttpCookie cookie = new HttpCookie("foo", "bar");
cookie.setMaxAge(maxAge);
client.putCookie(cookie);
assertNotNull(client.getCookie(cookie.getName()));
// Allow cookie to expire
TimeUnit.SECONDS.sleep(maxAge * 2);
assertNull(client.getCookie(cookie.getName()));
cookie = new HttpCookie("foo", "bar");
client.putCookie(cookie);
assertNotNull(client.getCookie(cookie.getName()));
TimeUnit.SECONDS.sleep(maxAge * 2);
assertNotNull(client.getCookie(cookie.getName()));
disconnectBayeuxClient(client);
}