use of org.xwiki.rendering.internal.configuration.DefaultRenderingConfiguration in project xwiki-platform by xwiki.
the class XWikiDocumentTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
this.defaultEntityReferenceSerializer = getComponentManager().getInstance(EntityReferenceSerializer.TYPE_STRING);
this.document = new XWikiDocument(new DocumentReference(DOCWIKI, DOCSPACE, DOCNAME));
this.document.setSyntax(Syntax.XWIKI_2_0);
this.document.setLanguage("en");
this.document.setDefaultLanguage("en");
this.document.setNew(false);
this.translatedDocument = new XWikiDocument();
this.translatedDocument.setSyntax(Syntax.XWIKI_2_0);
this.translatedDocument.setLanguage("fr");
this.translatedDocument.setNew(false);
getContext().put("isInRenderingEngine", true);
this.mockXWiki = mock(XWiki.class);
this.mockXWikiVersioningStore = mock(XWikiVersioningStoreInterface.class);
this.mockXWikiVersioningStore.stubs().method("getXWikiDocumentArchive").will(returnValue(null));
this.mockXWikiStoreInterface = mock(XWikiStoreInterface.class);
this.document.setStore((XWikiStoreInterface) this.mockXWikiStoreInterface.proxy());
this.mockXWikiMessageTool = mock(XWikiMessageTool.class, new Class[] { ResourceBundle.class, XWikiContext.class }, new Object[] { null, getContext() });
this.mockXWikiMessageTool.stubs().method("get").will(returnValue("message"));
this.mockXWikiRightService = mock(XWikiRightService.class);
this.mockXWikiRightService.stubs().method("hasProgrammingRights").will(returnValue(true));
this.mockXWiki.stubs().method("getVersioningStore").will(returnValue(this.mockXWikiVersioningStore.proxy()));
this.mockXWiki.stubs().method("getStore").will(returnValue(this.mockXWikiStoreInterface.proxy()));
this.mockXWiki.stubs().method("getDocument").will(returnValue(this.document));
this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue("en"));
this.mockXWiki.stubs().method("getSectionEditingDepth").will(returnValue(2L));
this.mockXWiki.stubs().method("getRightService").will(returnValue(this.mockXWikiRightService.proxy()));
getContext().setWiki((XWiki) this.mockXWiki.proxy());
getContext().put("msg", this.mockXWikiMessageTool.proxy());
this.baseClass = this.document.getxWikiClass();
this.baseClass.addTextField("string", "String", 30);
this.baseClass.addTextAreaField("area", "Area", 10, 10);
this.baseClass.addTextAreaField("puretextarea", "Pure text area", 10, 10);
// set the text areas an non interpreted content
((TextAreaClass) this.baseClass.getField("puretextarea")).setContentType("puretext");
this.baseClass.addPasswordField("passwd", "Password", 30);
this.baseClass.addBooleanField("boolean", "Boolean", "yesno");
this.baseClass.addNumberField("int", "Int", 10, "integer");
this.baseClass.addStaticListField("stringlist", "StringList", "value1, value2");
this.mockXWiki.stubs().method("getClass").will(returnValue(this.baseClass));
this.mockXWiki.stubs().method("getXClass").will(returnValue(this.baseClass));
this.baseObject = this.document.newObject(CLASSNAME, getContext());
this.baseObject.setStringValue("string", "string");
this.baseObject.setLargeStringValue("area", "area");
this.baseObject.setStringValue("passwd", "passwd");
this.baseObject.setIntValue("boolean", 1);
this.baseObject.setIntValue("int", 42);
this.baseObject.setStringListValue("stringlist", Arrays.asList("VALUE1", "VALUE2"));
this.mockXWikiStoreInterface.stubs().method("search").will(returnValue(new ArrayList<XWikiDocument>()));
// Set the default link label generator format to %np for some tests below.
// We need to do this since we don't depend on xwiki-platform-rendering-configuration-default (which contains
// an overridden RenderingConfiguration impl that sets the format to %np by default).
DefaultRenderingConfiguration renderingConfiguration = getComponentManager().getInstance(RenderingConfiguration.class);
renderingConfiguration.setLinkLabelFormat("%np");
}
Aggregations