/**
* Test the method setInitialRequestContext(MarinerRequestContext)
*/
public void testSetInitialRequestContext() throws Exception {
final BooleanWrapper calledMethod = new BooleanWrapper(false);
final TestMarinerRequestContext context =
new TestMarinerRequestContext();
// =====================================================================
// Create Mocks
// =====================================================================
final MarinerPageContextMock pageContextMock =
new MarinerPageContextMock("pageContextMock",
expectations);
final ProjectManagerMock projectManagerMock =
new ProjectManagerMock("projectManagerMock", expectations);
ProjectStack projectStack = new ProjectStack();
// =====================================================================
// Set Expectations
// =====================================================================
pageContextMock.expects.getRequestURL(false).returns(null);
pageContextMock.fuzzy.setBaseURLProvider(
mockFactory.expectsInstanceOf(BaseURLTracker.class));
pageContextMock.expects.getProjectManager()
.returns(projectManagerMock).any();
pageContextMock.expects.getProjectStack().returns(projectStack).any();
// =====================================================================
// Test Expectations
// ====================================================================
ContextInternals.setMarinerPageContext(context, pageContextMock);
AbstractMarlinContentHandler defaultHandler = new TestHandler() {
// Javadoc inherited from MarlinContentHandler interface
public void setInitialRequestContext(
MarinerRequestContext requestContext) {
calledMethod.setValue(true);
assertSame("Unexpected value for request context.",
context, requestContext);
}
};
NamespaceSwitchContentHandler handler =
new NamespaceSwitchContentHandler(defaultHandler);
handler.setInitialRequestContext(context);
assertTrue("Expected method to be invoked.", calledMethod.getValue());
}