@Test
 public void testGetAllUserNamesSorted() throws Exception {
   dao.setUsernameComparator(new DefaultUsernameComparator());
   List<String> usernames = dao.getAllUsers();
   if (logger.isDebugEnabled()) {
     logger.debug("testGetAllUserNamesSorted(): Usernames: " + usernames); // $NON-NLS-1$
   }
   assertTrue(usernames.indexOf("marissa") < usernames.indexOf("scott"));
 }
 @Before
 public void setUp() throws Exception {
   dao = new InMemoryUserRoleListService();
   dao.setUserRoleListEnhancedUserMap(makeUserRoleListEnhancedUserMap());
   dao.setAllRoles(makeAllAuthorities());
   InMemoryDaoImpl wrapped = new InMemoryDaoImpl();
   wrapped.setUserMap(makeUserMap());
   wrapped.afterPropertiesSet();
   dao.setUserDetailsService(wrapped);
   dao.afterPropertiesSet();
 }
 @Test
 public void testGetAllAuthoritiesSorted() throws Exception {
   dao.setRoleComparator(new DefaultRoleComparator());
   List<String> authorities = dao.getAllRoles();
   if (logger.isDebugEnabled()) {
     logger.debug("testGetAllAuthoritiesSorted(): Authorities: " + authorities); // $NON-NLS-1$
   }
   assertTrue(
       authorities.indexOf(new GrantedAuthorityImpl("ROLE_THREE"))
           < authorities.indexOf(new GrantedAuthorityImpl("ROLE_TWO")));
 }
 @Test
 public void testGetRolesForUser() throws Exception {
   List<String> userAuths = dao.getRolesForUser(null, "marissa"); // $NON-NLS-1$
   if (logger.isDebugEnabled()) {
     logger.debug("testGetRolesForUser(): Roles: " + userAuths); // $NON-NLS-1$
   }
   assertNotNull(userAuths);
   assertTrue(userAuths.size() == 2);
   assertEquals(userAuths.get(0), "ROLE_ONE"); // $NON-NLS-1$
   assertEquals(userAuths.get(1), "ROLE_TWO"); // $NON-NLS-1$
 }
 @Test
 public void testGetAllUserNames() throws Exception {
   List<String> allUserNames = dao.getAllUsers();
   assertTrue("User list should not be empty", allUserNames.size() > 0); // $NON-NLS-1$
   for (String username : allUserNames) {
     if (logger.isDebugEnabled()) {
       logger.debug("testGetAllUserNames(): User name: " + username); // $NON-NLS-1$
     }
     assertTrue(
         "User name must be marissa or scott",
         (username.equals("marissa")
             || username.equals("scott"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   }
 }
 @Test
 public void testGetAllUserNamesInRole() throws Exception {
   List<String> allUserNames = dao.getUsersInRole(null, "ROLE_ONE"); // $NON-NLS-1$
   assertTrue("Two users should be in the role ROLE_ONE", allUserNames.size() == 2); // $NON-NLS-1$
   for (String username : allUserNames) {
     if (logger.isDebugEnabled()) {
       logger.debug("testGetAllUserNamesInRole(): User name: " + username); // $NON-NLS-1$
     }
     assertTrue(
         "User name must be marissa or scott",
         (username.equals("marissa")
             || username.equals("scott"))); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   }
 }
 @Test
 public void testGetAllAuthorities() throws Exception {
   List<String> allAuthorities = dao.getAllRoles();
   assertTrue(
       "Authority list should contain three roles", allAuthorities.size() == 3); // $NON-NLS-1$
   for (String role : allAuthorities) {
     if (logger.isDebugEnabled()) {
       logger.debug("testGetAllAuthorities(): Authority: " + role); // $NON-NLS-1$
     }
     assertTrue(
         "Authority name must be ROLE_ONE, ROLE_TWO or ROLE_THREE",
         ( //$NON-NLS-1$
         role.equals("ROLE_ONE") // $NON-NLS-1$
             || role.equals("ROLE_TWO") // $NON-NLS-1$
             || role.equals("ROLE_THREE") // $NON-NLS-1$
         ));
   }
 }