1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.doc

File XWikiDocumentRenderingTest.java

 

Code metrics

0
168
16
1
475
303
16
0.1
10.5
16
1

Classes

Class Line # Actions
XWikiDocumentRenderingTest 60 168 0% 16 0
1.0100%
 

Contributing tests

This file is covered by 13 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.doc;
21   
22    import java.io.Reader;
23    import java.io.Writer;
24    import java.util.ArrayList;
25    import java.util.Arrays;
26    import java.util.Locale;
27    import java.util.Properties;
28   
29    import org.apache.velocity.VelocityContext;
30    import org.jmock.Mock;
31    import org.jmock.core.Invocation;
32    import org.jmock.core.stub.CustomStub;
33    import org.junit.Test;
34    import org.xwiki.display.internal.DisplayConfiguration;
35    import org.xwiki.model.reference.DocumentReference;
36    import org.xwiki.rendering.syntax.Syntax;
37    import org.xwiki.test.internal.MockConfigurationSource;
38    import org.xwiki.velocity.VelocityEngine;
39    import org.xwiki.velocity.VelocityFactory;
40    import org.xwiki.velocity.VelocityManager;
41    import org.xwiki.velocity.internal.jmx.JMXVelocityEngine;
42    import org.xwiki.velocity.internal.jmx.JMXVelocityEngineMBean;
43   
44    import com.xpn.xwiki.XWiki;
45    import com.xpn.xwiki.XWikiException;
46    import com.xpn.xwiki.api.Document;
47    import com.xpn.xwiki.objects.BaseObject;
48    import com.xpn.xwiki.objects.classes.BaseClass;
49    import com.xpn.xwiki.objects.classes.TextAreaClass;
50    import com.xpn.xwiki.store.XWikiStoreInterface;
51    import com.xpn.xwiki.store.XWikiVersioningStoreInterface;
52    import com.xpn.xwiki.test.AbstractBridgedXWikiComponentTestCase;
53    import com.xpn.xwiki.user.api.XWikiRightService;
54   
55    /**
56    * Unit tests for {@link XWikiDocument}.
57    *
58    * @version $Id: 9ed195a68a076aa250d06b8ae98d54d0780e5ca5 $
59    */
 
60    public class XWikiDocumentRenderingTest extends AbstractBridgedXWikiComponentTestCase
61    {
62    private static final String DOCWIKI = "xwiki";
63   
64    private static final String DOCSPACE = "Space";
65   
66    private static final String DOCNAME = "Page";
67   
68    private static final String DOCFULLNAME = DOCSPACE + "." + DOCNAME;
69   
70    private static final String CLASSNAME = DOCFULLNAME;
71   
72    private XWikiDocument document;
73   
74    private XWikiDocument translatedDocument;
75   
76    private Mock mockXWiki;
77   
78    private Mock mockXWikiVersioningStore;
79   
80    private Mock mockXWikiStoreInterface;
81   
82    private Mock mockXWikiRightService;
83   
84    private Mock mockDisplayConfiguration;
85   
86    private BaseClass baseClass;
87   
88    private BaseObject baseObject;
89   
 
90  13 toggle @Override
91    protected void setUp() throws Exception
92    {
93  13 super.setUp();
94   
95    // Mock xwiki.cfg
96  13 getComponentManager().registerComponent(MockConfigurationSource.getDescriptor("xwikicfg"),
97    getConfigurationSource());
98   
99  13 DocumentReference documentReference = new DocumentReference(DOCWIKI, DOCSPACE, DOCNAME);
100  13 this.document = new XWikiDocument(documentReference);
101  13 this.document.setSyntax(Syntax.XWIKI_2_1);
102  13 this.document.setLanguage("en");
103  13 this.document.setDefaultLanguage("en");
104  13 this.document.setNew(false);
105   
106  13 getContext().setDoc(this.document);
107   
108  13 this.translatedDocument = new XWikiDocument();
109  13 this.translatedDocument.setSyntax(Syntax.XWIKI_2_1);
110  13 this.translatedDocument.setLanguage("fr");
111  13 this.translatedDocument.setNew(false);
112   
113  13 getContext().put("isInRenderingEngine", true);
114   
115  13 this.mockXWiki = mock(XWiki.class);
116  13 this.mockXWiki.stubs().method("Param").will(returnValue(null));
117   
118  13 this.mockXWikiVersioningStore = mock(XWikiVersioningStoreInterface.class);
119  13 this.mockXWikiVersioningStore.stubs().method("getXWikiDocumentArchive").will(returnValue(null));
120   
121  13 this.mockXWikiRightService = mock(XWikiRightService.class);
122  13 this.mockXWikiRightService.stubs().method("hasProgrammingRights").will(returnValue(true));
123   
124  13 this.mockXWikiStoreInterface = mock(XWikiStoreInterface.class);
125  13 this.mockXWikiStoreInterface.stubs().method("search").will(returnValue(new ArrayList<XWikiDocument>()));
126   
127  13 this.document.setStore((XWikiStoreInterface) this.mockXWikiStoreInterface.proxy());
128   
129  13 this.mockXWiki.stubs().method("getVersioningStore").will(returnValue(this.mockXWikiVersioningStore.proxy()));
130  13 this.mockXWiki.stubs().method("getStore").will(returnValue(this.mockXWikiStoreInterface.proxy()));
131  13 this.mockXWiki.stubs().method("getRightService").will(returnValue(this.mockXWikiRightService.proxy()));
132  13 this.mockXWiki.stubs().method("getDocument").will(returnValue(this.document));
133  13 this.mockXWiki.stubs().method("getDocumentReference").will(returnValue(documentReference));
134  13 this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue("en"));
135  13 this.mockXWiki.stubs().method("exists").will(returnValue(false));
136    // Called from MessageToolVelocityContextInitializer.
137  13 this.mockXWiki.stubs().method("prepareResources");
138    // The next 3 stubs are needed to properly initialize the Velocity engine.
139  13 this.mockXWiki.stubs().method("getSkin").will(returnValue("default"));
140  13 this.mockXWiki.stubs().method("getSkinFile").will(returnValue(null));
141  13 this.mockXWiki.stubs().method("Param").with(eq("xwiki.render.velocity.macrolist")).will(returnValue(""));
142  13 this.mockXWiki.stubs().method("exists").will(returnValue(false));
143  13 this.mockXWiki.stubs().method("evaluateTemplate").will(returnValue(""));
144   
145  13 getContext().setWiki((XWiki) this.mockXWiki.proxy());
146   
147  13 this.baseClass = this.document.getXClass();
148  13 this.baseClass.addTextField("string", "String", 30);
149  13 this.baseClass.addTextAreaField("area", "Area", 10, 10);
150  13 this.baseClass.addTextAreaField("puretextarea", "Pure text area", 10, 10);
151    // set the text areas an non interpreted content
152  13 ((TextAreaClass) this.baseClass.getField("puretextarea")).setContentType("puretext");
153  13 this.baseClass.addPasswordField("passwd", "Password", 30);
154  13 this.baseClass.addBooleanField("boolean", "Boolean", "yesno");
155  13 this.baseClass.addNumberField("int", "Int", 10, "integer");
156  13 this.baseClass.addStaticListField("stringlist", "StringList", "value1, value2");
157   
158  13 this.mockXWiki.stubs().method("getXClass").will(returnValue(this.baseClass));
159   
160  13 this.baseObject = this.document.newObject(CLASSNAME, getContext());
161  13 this.baseObject.setStringValue("string", "string");
162  13 this.baseObject.setLargeStringValue("area", "area");
163  13 this.baseObject.setStringValue("passwd", "passwd");
164  13 this.baseObject.setIntValue("boolean", 1);
165  13 this.baseObject.setIntValue("int", 42);
166  13 this.baseObject.setStringListValue("stringlist", Arrays.asList("VALUE1", "VALUE2"));
167    }
168   
 
169  13 toggle @Override
170    protected void registerComponents() throws Exception
171    {
172  13 super.registerComponents();
173   
174    // Setup display configuration.
175  13 this.mockDisplayConfiguration = registerMockComponent(DisplayConfiguration.class);
176  13 this.mockDisplayConfiguration.stubs().method("getDocumentDisplayerHint").will(returnValue("default"));
177  13 this.mockDisplayConfiguration.stubs().method("getTitleHeadingDepth").will(returnValue(2));
178    }
179   
 
180  1 toggle public void testCurrentDocumentVariableIsInjectedBeforeRendering() throws XWikiException
181    {
182    // Verifies we can access the doc variable from a groovy macro.
183  1 this.document.setContent("{{groovy}}print(doc);{{/groovy}}");
184  1 this.document.setSyntax(Syntax.XWIKI_2_0);
185   
186  1 assertEquals("<p>Space.Page</p>", this.document.getRenderedContent(getContext()));
187    }
188   
 
189  1 toggle public void testGetRenderedTitleWithTitle()
190    {
191  1 this.document.setSyntax(Syntax.XWIKI_2_0);
192   
193  1 this.document.setTitle("title");
194   
195  1 assertEquals("title", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
196   
197  1 this.document.setTitle("**title**");
198   
199  1 assertEquals("**title**", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
200   
201  1 this.document.setTitle("<strong>ti<em>tle</strong>");
202   
203    // The title is parsed as plain text after the Velocity code is evaluated so the HTML have no meaning.
204  1 assertEquals("&lt;strong&gt;ti&lt;em&gt;tle&lt;/strong&gt;",
205    this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
206  1 assertEquals("<strong>ti<em>tle</strong>", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
207   
208  1 this.document.setTitle("#set($key = \"title\")$key");
209   
210  1 assertEquals("title", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
211    }
212   
 
213  1 toggle public void testGetRenderedTitleWithoutTitleHTML()
214    {
215  1 this.document.setSyntax(Syntax.XWIKI_2_0);
216   
217  1 this.document.setContent(
218    "content not in section\n" + "= header 1=\nheader 1 content\n" + "== header 2==\nheader 2 content");
219   
220  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
221   
222  1 assertEquals("header 1", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
223   
224  1 this.document.setContent(
225    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
226   
227  1 assertEquals("<strong>header 1</strong>", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
228   
229  1 this.document.setContent(
230    "content not in section\n" + "= [[Space.Page]]=\nheader 1 content\n" + "== header 2==\nheader 2 content");
231   
232  1 this.mockXWiki.stubs().method("getURL").will(returnValue("/reference"));
233   
234  1 assertEquals("<span class=\"wikicreatelink\"><a href=\"/reference\"><span class=\"wikigeneratedlinkcontent\">"
235    + "Page" + "</span></a></span>", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
236   
237  1 this.document.setContent("content not in section\n" + "= #set($var ~= \"value\")=\nheader 1 content\n"
238    + "== header 2==\nheader 2 content");
239   
240  1 assertEquals("#set($var = \"value\")", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
241   
242  1 this.document.setContent("content not in section\n"
243    + "= {{groovy}}print \"value\"{{/groovy}}=\nheader 1 content\n" + "== header 2==\nheader 2 content");
244   
245  1 assertEquals("value", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
246   
247  1 this.document.setContent("content not in section\n=== header 3===");
248   
249  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
250    }
251   
 
252  1 toggle public void testGetRenderedTitleWithoutTitlePLAIN()
253    {
254  1 this.document.setSyntax(Syntax.XWIKI_2_0);
255   
256  1 this.document.setContent(
257    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
258   
259  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
260   
261  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
262   
263  1 this.document.setContent(
264    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
265   
266  1 assertEquals("header 1", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
267   
268  1 this.document.setContent("content not in section\n"
269    + "= {{groovy}}print \"value\"{{/groovy}}=\nheader 1 content\n" + "== header 2==\nheader 2 content");
270   
271  1 assertEquals("value", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
272    }
273   
 
274  1 toggle public void testGetRenderedTitleNoTitleAndContent()
275    {
276  1 this.document.setSyntax(Syntax.XWIKI_2_0);
277   
278  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
279    }
280   
281    /**
282    * Make sure title extracted from content is protected from cycles
283    */
 
284  1 toggle public void testGetRenderedTitleRecursive()
285    {
286  1 this.document.setSyntax(Syntax.XWIKI_2_0);
287  1 this.document.setContent("= {{groovy}}print doc.getDisplayTitle(){{/groovy}}");
288   
289  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
290    }
291   
292    /**
293    * See XWIKI-5277 for details.
294    */
 
295  1 toggle public void testGetRenderedContentCleansVelocityMacroCache() throws Exception
296    {
297    // Make sure we start not in the rendering engine since this is what happens in real: a document is
298    // called by a template thus outside of the rendering engine.
299  1 getContext().remove("isInRenderingEngine");
300   
301    // We display a text area since we know that rendering a text area will call getRenderedContent inside our top
302    // level getRenderedContent call, thus testing that velocity macros are not removed during nested calls to
303    // getRenderedContent.
304  1 this.baseObject.setLargeStringValue("area", "{{velocity}}#macro(testmacrocache)ok#end{{/velocity}}");
305  1 this.document.setContent("{{velocity}}$doc.display(\"area\")#testmacrocache{{/velocity}}");
306  1 this.document.setSyntax(Syntax.XWIKI_2_0);
307   
308    // We need to put the current doc in the Velocity Context since it's normally set before the rendering is
309    // called in the execution flow.
310  1 VelocityManager originalVelocityManager = getComponentManager().getInstance(VelocityManager.class);
311  1 VelocityContext vcontext = originalVelocityManager.getVelocityContext();
312  1 vcontext.put("doc", new Document(this.document, getContext()));
313   
314    // Register a Mock for the VelocityManager to bypass skin APIs that we would need to mock otherwise.
315  1 Mock mockVelocityManager = registerMockComponent(VelocityManager.class);
316  1 mockVelocityManager.stubs().method("getCurrentVelocityContext").will(returnValue(vcontext));
317   
318  1 VelocityFactory velocityFactory = getComponentManager().getInstance(VelocityFactory.class);
319  1 VelocityEngine vengine = velocityFactory.createVelocityEngine("default", new Properties());
320    // Save the number of cached macro templates in the Velocity engine so that we can compare after the
321    // document is rendered.
322  1 JMXVelocityEngineMBean mbean = new JMXVelocityEngine(vengine);
323  1 int cachedMacroNamespaceSize = mbean.getTemplates().values().size();
324  1 assertTrue(cachedMacroNamespaceSize > 0);
325   
326  1 mockVelocityManager.stubs().method("getVelocityEngine").will(returnValue(vengine));
327  1 mockVelocityManager.stubs().method("evaluate").will(new CustomStub("evaluate")
328    {
 
329  2 toggle @Override
330    public Object invoke(Invocation invocation) throws Throwable
331    {
332  2 return vengine.evaluate(vcontext, (Writer) invocation.parameterValues.get(0),
333    (String) invocation.parameterValues.get(1), (Reader) invocation.parameterValues.get(2));
334    }
335    });
336   
337    // $doc.display will ask for the syntax of the current document so we need to mock it.
338  1 this.mockXWiki.stubs().method("getCurrentContentSyntaxId").with(eq("xwiki/2.0"), ANYTHING)
339    .will(returnValue("xwiki/2.0"));
340   
341    // Verify that the macro located inside the TextArea has been taken into account when executing the doc's
342    // content.
343  1 assertEquals("<p>ok</p>", this.document.getRenderedContent(getContext()));
344   
345    // Now verify that the Velocity Engine doesn't contain any more cached macro namespace to prove that
346    // getRenderedContent has correctly cleaned the Velocity macro cache.
347  1 assertEquals(cachedMacroNamespaceSize, mbean.getTemplates().values().size());
348    }
349   
 
350  1 toggle @Test
351    public void testGetRenderedTitleWhenMatchingTitleHeaderDepth()
352    {
353  1 this.document.setContent("=== level3");
354  1 this.document.setSyntax(Syntax.XWIKI_2_0);
355   
356  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
357   
358    // Overwrite the title heading depth.
359  1 this.mockDisplayConfiguration.stubs().method("getTitleHeadingDepth").will(returnValue(3));
360   
361  1 assertEquals("level3", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
362    }
363   
 
364  1 toggle @Test
365    public void testGetRenderedTitleWhenNotMatchingTitleHeaderDepth()
366    {
367  1 this.document.setContent("=== level3");
368  1 this.document.setSyntax(Syntax.XWIKI_2_0);
369   
370  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
371    }
372   
 
373  1 toggle public void testGetRenderedContent() throws XWikiException
374    {
375  1 this.document.setContent("**bold**");
376  1 this.document.setSyntax(Syntax.XWIKI_2_0);
377   
378  1 assertEquals("<p><strong>bold</strong></p>", this.document.getRenderedContent(getContext()));
379   
380  1 this.translatedDocument = new XWikiDocument(this.document.getDocumentReference(), Locale.FRENCH);
381  1 this.translatedDocument.setContent("//italic//");
382  1 this.translatedDocument.setSyntax(Syntax.XWIKI_1_0);
383  1 this.translatedDocument.setNew(false);
384   
385  1 this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue(Locale.FRENCH.toString()));
386  1 this.mockXWiki.stubs().method("getDocument").with(eq(
387    new DocumentReference(this.translatedDocument.getDocumentReference(), this.translatedDocument.getLocale())),
388    ANYTHING).will(returnValue(this.translatedDocument));
389   
390  1 assertEquals("<p><em>italic</em></p>", this.document.getRenderedContent(getContext()));
391    }
392   
 
393  1 toggle public void testGetRenderedContentRights() throws XWikiException
394    {
395  1 getContext().remove("sdoc");
396   
397  1 this.document.setContent("{{velocity}}$xcontext.sdoc{{/velocity}}");
398  1 this.document.setSyntax(Syntax.XWIKI_2_1);
399   
400  1 assertEquals("<p>Space.Page</p>", this.document.getRenderedContent(getContext()));
401    }
402   
 
403  1 toggle public void testGetRenderedContentTextWithSourceSyntax()
404    {
405  1 this.document.setSyntax(Syntax.XWIKI_1_0);
406   
407  1 assertEquals("<p><strong>bold</strong></p>",
408    this.document.getRenderedContent("**bold**", "xwiki/2.0", getContext()));
409    }
410   
 
411  1 toggle public void testGetRenderedContentTextRights() throws XWikiException
412    {
413  1 XWikiDocument otherDocument = new XWikiDocument(new DocumentReference("otherwiki", "otherspace", "otherpage"));
414  1 otherDocument.setContentAuthorReference(new DocumentReference("otherwiki", "XWiki", "othercontentauthor"));
415  1 XWikiDocument sdoc = new XWikiDocument(new DocumentReference("callerwiki", "callerspace", "callerpage"));
416  1 sdoc.setContentAuthorReference(new DocumentReference("callerwiki", "XWiki", "calleruser"));
417  1 Document apiDocument = this.document.newDocument(getContext());
418   
419  1 getContext().setDoc(null);
420   
421  1 String content =
422    "{{velocity}}" + "$xcontext.sdoc.contentAuthorReference $xcontext.doc $xcontext.doc.contentAuthorReference"
423    + "{{/velocity}}";
424   
425  1 this.document.setContentAuthorReference(new DocumentReference("authorwiki", "XWiki", "contentauthor"));
426   
427  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
428    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
429   
430  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
431    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
432   
433  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
434    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
435   
436  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
437    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), false, otherDocument,
438    getContext()));
439   
440  1 getContext().setDoc(otherDocument);
441   
442  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
443    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
444   
445  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
446    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
447   
448  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
449    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
450   
451  1 getContext().put("sdoc", sdoc);
452  1 getContext().setDoc(this.document);
453   
454  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
455    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
456   
457  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
458    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
459   
460  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
461    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
462   
463  1 getContext().setDoc(otherDocument);
464   
465  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
466    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
467   
468  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
469    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
470   
471  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
472    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
473   
474    }
475    }