Search in sources :

Example 1 with DefaultRenderingConfiguration

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");
}
Also used : DefaultRenderingConfiguration(org.xwiki.rendering.internal.configuration.DefaultRenderingConfiguration) ArrayList(java.util.ArrayList) XWiki(com.xpn.xwiki.XWiki) XWikiContext(com.xpn.xwiki.XWikiContext) TextAreaClass(com.xpn.xwiki.objects.classes.TextAreaClass) XWikiStoreInterface(com.xpn.xwiki.store.XWikiStoreInterface) XWikiVersioningStoreInterface(com.xpn.xwiki.store.XWikiVersioningStoreInterface) XWikiRightService(com.xpn.xwiki.user.api.XWikiRightService) TextAreaClass(com.xpn.xwiki.objects.classes.TextAreaClass) PropertyClass(com.xpn.xwiki.objects.classes.PropertyClass) BaseClass(com.xpn.xwiki.objects.classes.BaseClass) ResourceBundle(java.util.ResourceBundle) BaseObject(com.xpn.xwiki.objects.BaseObject) XWikiMessageTool(com.xpn.xwiki.web.XWikiMessageTool) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 PropertyClass (com.xpn.xwiki.objects.classes.PropertyClass)1 TextAreaClass (com.xpn.xwiki.objects.classes.TextAreaClass)1 XWikiStoreInterface (com.xpn.xwiki.store.XWikiStoreInterface)1 XWikiVersioningStoreInterface (com.xpn.xwiki.store.XWikiVersioningStoreInterface)1 XWikiRightService (com.xpn.xwiki.user.api.XWikiRightService)1 XWikiMessageTool (com.xpn.xwiki.web.XWikiMessageTool)1 ArrayList (java.util.ArrayList)1 ResourceBundle (java.util.ResourceBundle)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 DefaultRenderingConfiguration (org.xwiki.rendering.internal.configuration.DefaultRenderingConfiguration)1