@Test
public void testIsPermitted() {

    Attribute attribute = new Attribute("myvalue");
    Request requestContext = createMock(Request.class);
    expect(requestContext.isUserInRole("first")).andReturn(Boolean.TRUE)
            .anyTimes();
    expect(requestContext.isUserInRole("second")).andReturn(Boolean.FALSE)
            .anyTimes();
    replay(requestContext);
    assertTrue(attribute.isPermitted(requestContext));
    Set<String> roles = new HashSet<String>();
    roles.add("first");
    attribute.setRoles(roles);
    assertTrue("The role is not permitted", attribute.isPermitted(
            requestContext));
    roles.clear();
    roles.add("second");
    assertFalse("The role is not permitted", attribute.isPermitted(
            requestContext));
    verify(requestContext);
}