}
};
PAPIElement element = createTestablePAPIElement();
TestMarinerRequestContext requestContext = new TestMarinerRequestContext();
TestMarinerPageContext pageContext = new TestMarinerPageContext();
XFTextInputAttributes attributes = new XFTextInputAttributes();
com.volantis.mcs.protocols.XFTextInputAttributes pattributes =
new com.volantis.mcs.protocols.XFTextInputAttributes();
attributes.setId("ID");
attributes.setStyleClass("StyleClass");
attributes.setTitle("Title");
attributes.setCaption("Caption");
attributes.setHelp("Help");
attributes.setName("Name");
attributes.setPrompt("Prompt");
attributes.setShortcut("Shortcut");
attributes.setTabindex("1");
XFFormFieldElementImpl xfElement = (XFFormFieldElementImpl) element;
pageContext.setPolicyReferenceResolver(
PolicyReferenceResolverTestHelper.getCommonExpectations(
expectations, mockFactory));
MyVolantisProtocolStub protocol = new MyVolantisProtocolStub();
pageContext.setProtocol(protocol);
ContextInternals.setMarinerPageContext(requestContext, pageContext);
pageContext.pushRequestContext(requestContext);
protocol.setMarinerPageContext(pageContext);
// Subset of initial values should be null
assertNotNull(pattributes);
assertNull(pattributes.getCaptionContainerInstance());
assertNull(pattributes.getEntryContainerInstance());
assertNull(pattributes.getId());
assertNull(pattributes.getTitle());
assertEquals(protocol.writeInitialFocusCalled, false);
xfElement.doField(pageContext, attributes, pattributes);
assertEquals(protocol.writeInitialFocusCalled, true);
// After some values should be match the values set.
assertNotNull(pattributes);
assertNull(pattributes.getCaptionContainerInstance());
assertNull(pattributes.getEntryContainerInstance());
assertEquals(pattributes.getId(), attributes.getId());
assertEquals(pattributes.getTitle(), attributes.getTitle());
assertEquals(pattributes.getCaption().getText(TextEncoding.PLAIN),
attributes.getCaption());
assertEquals(pattributes.getHelp().getText(TextEncoding.PLAIN),
attributes.getHelp());
assertEquals(pattributes.getName(), attributes.getName());
assertEquals(pattributes.getPrompt().getText(TextEncoding.PLAIN),
attributes.getPrompt());
assertEquals(pattributes.getShortcut().getText(TextEncoding.PLAIN),
attributes.getShortcut());
assertNull(pattributes.getFieldDescriptor());
assertEquals(pattributes.getTabindex(), attributes.getTabindex());
}