LoginTicketManager { public long getSize() { long size; synchronized (tickets) { size = tickets.size(); } return size; } LoginTicketManager(); int getTicketCountThreashold(); void setTicketCountThreashold(int ticketCountThreashold); int getTicketValiditySeconds(); void setTicketValiditySeconds(int ticketValiditySeconds); UsernameProvider getUsernameProvider(); void setUsernameProvider(UsernameProvider usernameProvider); LoginTicket generateNewTicket(String requestingApplicationName, String requestingApplicationUsername); LoginTicket removeTicket(String ticketId); void deleteExpired(); long getSize(); void resetTickets(); static final int DEFAULT_TICKET_VALIDITY_SECONDS; static final int TICKETS_CLEANING_THRESHOLD; }
@Test public void testGetSize() throws LoginTicketNotFoundException, ExternalAppNotMappedException { ArrayList<String> toRemove = new ArrayList<>(); long initialSize = manager.getSize(); assertTrue(initialSize >= 0); for (int i = 0; i < 10; i++) { LoginTicket ticket = manager.generateNewTicket("test", "testUser"); assertEquals(i + 1 + initialSize, manager.getSize()); toRemove.add(ticket.getIdAsString()); } for (String id : toRemove) { manager.removeTicket(id); } assertTrue(manager.getSize() == initialSize); }