@Test
@SuppressWarnings("unchecked")
public void testFindRoles() {

  List<Role> roles = directory.findRoles("%2012%", Role.Target.ALL, 0, 0);
  Assert.assertEquals(2, roles.size());
  Assert.assertTrue("ROLE_MATH_2012".equals(roles.get(0).getName())
          || "ROLE_MATH_2012".equals(roles.get(1).getName()));
  Assert.assertTrue("ROLE_ASTRO_2012".equals(roles.get(0).getName())
          || "ROLE_ASTRO_2012".equals(roles.get(1).getName()));
  // Test limit and offset
  roles = directory.findRoles("%2012%", Role.Target.ALL, 1, 1);
  Assert.assertEquals(1, roles.size());
  Assert.assertTrue("ROLE_ASTRO_2012".equals(roles.get(0).getName())
          || "ROLE_MATH_2012".equals(roles.get(0).getName()));
}