// Set up the common test environment
TestMarinerPageContext pageContext = new TestMarinerPageContext();
MarinerRequestContext requestContext = new TestMarinerRequestContext();
ProtocolBuilder builder = new ProtocolBuilder();
DOMProtocol protocol = (DOMProtocol) builder.build(
new TestProtocolRegistry.TestDOMProtocolFactory(),
InternalDeviceTestHelper.createTestDevice());
// Set up the protocol (needed for OutputBuffer management)
// The test implementation avoids the need for an initialized volantis
// bean, which is jolly handy in this case
pageContext.setProtocol(protocol);
// Set the Layout (needed for FormatReference and panes)
CanvasLayout layout = new CanvasLayout();
// Activate the device layout.
RuntimeDeviceLayout runtimeDeviceLayout =
RuntimeDeviceLayoutTestHelper.activate(layout);
pageContext.setDeviceLayout(runtimeDeviceLayout);
final PolicyReferenceResolverMock referenceResolverMock =
new PolicyReferenceResolverMock("referenceResolverMock",
expectations);
pageContext.setPolicyReferenceResolver(referenceResolverMock);
// Link everything together
ContextInternals.setMarinerPageContext(requestContext, pageContext);
pageContext.pushRequestContext(requestContext);
protocol.setMarinerPageContext(pageContext);
// Finally, test the required method
command.execute(pageContext, element);
}