TicketContainer { public boolean isValid(String principal, String ticket) { if ("anonymous".equals(principal) && "anonymous".equals(ticket)) return true; Entry entry = sessions.get(principal); return entry != null && entry.ticket.equals(ticket); }  boolean isValid(String principal, String ticket); synchronized String getTicket(String principal); static final TicketContainer instance; }
@Test public void isValidAnonymous() throws UnknownHostException { boolean ok = container.isValid("anonymous", "anonymous"); assertTrue(ok); }
@Test public void isValidNonExistingPrincipal() throws UnknownHostException { boolean ok = container.isValid("unknownuser", "someticket"); assertFalse(ok); }