public void testUserCookie() throws Exception {
    assertNull(info.getUserCookie());

    Cookie[] cookies = new Cookie[] {createCookie("name", "value", 1)};
    info.setUserCookie(cookies);

    assertEquals("name=value", info.getUserCookie());

    // wait for cookie expiration
    Thread.sleep(SLEEP_TIME);
    assertNull(info.getUserCookie()); // we shouldn't have a cookie now

    cookies = new Cookie[] {createCookie("name1", "value1", 1), createCookie("name2", "value2", 3)};
    info.setUserCookie(cookies);
    assertEquals("name1=value1,name2=value2", info.getUserCookie());

    Thread.sleep(SLEEP_TIME);
    assertEquals("name2=value2", info.getUserCookie());

    try {
      info.setUserCookie(null);
      fail("Should have thrown an IllegalArgumentException");
    } catch (IllegalArgumentException e) {
      // expected
    }
  }
  public void testReplaceUserCookies() throws Exception {
    info.setUserCookie(new Cookie[] {createCookie("name", "value", 1)});

    info.replaceUserCookiesWith(null);
    assertEquals("name=value", info.getUserCookie());

    ProducerSessionInformation other = new ProducerSessionInformation();

    info.replaceUserCookiesWith(other);
    assertEquals("name=value", info.getUserCookie());

    other.setUserCookie(new Cookie[] {createCookie("name2", "value2", 1)});
    info.replaceUserCookiesWith(other);
    assertEquals("name2=value2", info.getUserCookie());

    Thread.sleep(SLEEP_TIME);
    info.replaceUserCookiesWith(other);
    assertNull(info.getUserCookie());
  }