context.setVolantis(volantis);
context.setRequestURL(new MarinerURL("http://a.url"));
FormDescriptor fd = new FormDescriptor();
fd.setName(formName);
final FormDataManager formDataManager = context.getFormDataManager();
String formSpecifier = formDataManager.getFormSpecifier(fd);
context.setPolicyReferenceResolver(referenceResolverMock);
context.pushDeviceLayoutContext(new DeviceLayoutContext());
PageGenerationCache pageGenerationCache = new PageGenerationCache();
pageGenerationCache.createFormFragmentationStates(form.getName());
context.setPageGenerationCache(pageGenerationCache);
protocol.setMarinerPageContext(context);
if(protocol.getPageHead()==null) {
protocol.initialisePageHead();
}
context.setProtocol(protocol);
TestDeviceLayoutContext dlc = new TestDeviceLayoutContext();
Pane pane = new Pane(layout);
FormFragmentInstance ffInstance = new FormFragmentInstance(
NDimensionalIndex.ZERO_DIMENSIONS) {
protected boolean isEmptyImpl() {
return false;
}
};
pane.setName("pane");
// Activate the device layout.
RuntimeDeviceLayout runtimeDeviceLayout =
RuntimeDeviceLayoutTestHelper.activate(layout);
context.setDeviceLayout(runtimeDeviceLayout);
context.setDevice(InternalDeviceTestHelper.createTestDevice());
context.setCurrentPane(pane);
dlc.setFormatInstance(pane, NDimensionalIndex.ZERO_DIMENSIONS,
ffInstance);
dlc.setMarinerPageContext(context);
dlc.setDeviceLayout(runtimeDeviceLayout);
//dlc.initialise();
context.pushDeviceLayoutContext(dlc);
MarinerRequestContext requestContext = new TestMarinerRequestContext();
ContextInternals.setEnvironmentContext(requestContext, new TestEnvironmentContext());
context.pushRequestContext(requestContext);
ContextInternals.setMarinerPageContext(requestContext, context);
DOMOutputBuffer dom = new DOMOutputBuffer();
dom.initialise();
XFFormAttributes attributes = new XFFormAttributes();
final Styles styles = StylesBuilder.getInitialValueStyles();
attributes.setStyles(styles);
attributes.setFormData(formInstance);
attributes.setAction(new LiteralLinkAssetReference("testaction"));
attributes.setMethod("post");
attributes.setFormSpecifier(formSpecifier);
attributes.setFormDescriptor(fd);
FormFragment formFragment = new FormFragment(layout);
formFragment.setName(fragmentName);
FormFragmentInstance formFragmentInstance = new FormFragmentInstance(
NDimensionalIndex.ZERO_DIMENSIONS);
formFragmentInstance.setFormat(formFragment);
Link link = new Link(fragmentName, URLConstants.NEXT_FORM_FRAGMENT, styles);
link.setFormFragment(formFragmentInstance);
protocol.doFormLink(dom, attributes, link);
SessionFormData retrievedFormData =
formDataManager.getSessionFormData(formSpecifier);
assertEquals("Unexpected FormFragmentData in the SessionContext " +
fragmentName + " field.", testURL,
retrievedFormData.getFieldValue(URLConstants.NEXT_FORM_FRAGMENT));
}