/**
* Tests if the definitions factory has been used.
*/
public void testDefinitionsFactoryUse() {
TilesRequestContext request = EasyMock.createMock(TilesRequestContext.class);
Map<String, Object> requestScope = new HashMap<String, Object>();
Map<String, Object> sessionScope = new HashMap<String, Object>();
EasyMock.expect(request.getRequestScope()).andReturn(requestScope)
.anyTimes();
EasyMock.expect(request.getSessionScope()).andReturn(sessionScope)
.anyTimes();
EasyMock.expect(request.getRequestLocale()).andReturn(null).anyTimes();
EasyMock.replay(request);
assertTrue(container.isValidDefinition("test.def1", request));
assertFalse(container.isValidDefinition("test.def.one", request));
assertFalse(container.isValidDefinition("test.def.two", request));
EasyMock.reset(request);
requestScope.clear();
requestScope.put(
DefaultKeyExtractor.DEFINITIONS_FACTORY_KEY_ATTRIBUTE_NAME,
"one");
EasyMock.expect(request.getRequestScope()).andReturn(requestScope)
.anyTimes();
EasyMock.expect(request.getSessionScope()).andReturn(sessionScope)
.anyTimes();
EasyMock.expect(request.getRequestLocale()).andReturn(null).anyTimes();
EasyMock.replay(request);
assertTrue(container.isValidDefinition("test.def1", request));
assertTrue(container.isValidDefinition("test.def.one", request));
assertFalse(container.isValidDefinition("test.def.two", request));
EasyMock.reset(request);
requestScope.clear();
requestScope.put(
DefaultKeyExtractor.DEFINITIONS_FACTORY_KEY_ATTRIBUTE_NAME,
"two");
EasyMock.expect(request.getRequestScope()).andReturn(requestScope)
.anyTimes();
EasyMock.expect(request.getSessionScope()).andReturn(sessionScope)
.anyTimes();
EasyMock.expect(request.getRequestLocale()).andReturn(null).anyTimes();
EasyMock.replay(request);
assertTrue(container.isValidDefinition("test.def1", request));
assertFalse(container.isValidDefinition("test.def.one", request));
assertTrue(container.isValidDefinition("test.def.two", request));
}