* Tests is attributes are rendered correctly according to users roles.
*
* @throws IOException If a problem arises during rendering or writing in the writer.
*/
public void testAttributeCredentials() throws IOException {
TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
EasyMock.expect(request.isUserInRole("myrole")).andReturn(Boolean.TRUE);
EasyMock.replay(request);
Attribute attribute = new Attribute((Object) "This is the value", "myrole");
attribute.setRenderer("string");
StringWriter writer = new StringWriter();
container.render(attribute, writer, request);
writer.close();
assertEquals("The attribute should have been rendered",
"This is the value", writer.toString());
EasyMock.reset(request);
request = EasyMock.createMock(TilesRequestContext.class);
EasyMock.expect(request.isUserInRole("myrole")).andReturn(Boolean.FALSE);
EasyMock.replay(request);
writer = new StringWriter();
container.render(attribute, writer, request);
writer.close();
assertNotSame("The attribute should have not been rendered",