getUtil().createPage(getTestClassName(), getTestMethodName() + "Sheet",
"{{velocity}}$doc.display('color'){{/velocity}}", "");
// Bind the class to the sheet.
ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class");
ObjectEditPane objectEditPane = objectEditor.addObject("XWiki.ClassSheetBinding");
objectEditPane.setFieldValue(objectEditPane.byPropertyName("sheet"), getTestClassName() + "."
+ getTestMethodName() + "Sheet");
objectEditor.clickSaveAndContinue();
// Create the template.
String classFullName = getTestClassName() + "." + getTestMethodName() + "Class";
getUtil().deletePage(getTestClassName(), getTestMethodName() + "Template");
objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Template");
objectEditPane = objectEditor.addObject(classFullName);
objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "red");
objectEditor.clickSaveAndContinue();
// Create the test instance.
getUtil().deletePage(getTestClassName(), getTestMethodName());
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit",
"template=" + getTestClassName() + "." + getTestMethodName() + "Template");
objectEditPane = new ObjectEditPane(new InlinePage().getForm(), classFullName, 0);
objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "green");
// Test the preview when the page is not yet saved.
PreviewableEditPage editPage = new PreviewableEditPage();
PreviewEditPage previewPage = editPage.clickPreview();
assertEquals("green", previewPage.getContent());