1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.doc

File XWikiDocumentRenderingTest.java

 

Code metrics

0
166
16
1
473
301
16
0.1
10.38
16
1

Classes

Class Line # Actions
XWikiDocumentRenderingTest 60 166 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: 9c94c04f8218d6f1935dd1cf9b5516760b0a4e31 $
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 this.document = new XWikiDocument(new DocumentReference(DOCWIKI, DOCSPACE, DOCNAME));
100  13 this.document.setSyntax(Syntax.XWIKI_2_1);
101  13 this.document.setLanguage("en");
102  13 this.document.setDefaultLanguage("en");
103  13 this.document.setNew(false);
104   
105  13 getContext().setDoc(this.document);
106   
107  13 this.translatedDocument = new XWikiDocument();
108  13 this.translatedDocument.setSyntax(Syntax.XWIKI_2_1);
109  13 this.translatedDocument.setLanguage("fr");
110  13 this.translatedDocument.setNew(false);
111   
112  13 getContext().put("isInRenderingEngine", true);
113   
114  13 this.mockXWiki = mock(XWiki.class);
115  13 this.mockXWiki.stubs().method("Param").will(returnValue(null));
116   
117  13 this.mockXWikiVersioningStore = mock(XWikiVersioningStoreInterface.class);
118  13 this.mockXWikiVersioningStore.stubs().method("getXWikiDocumentArchive").will(returnValue(null));
119   
120  13 this.mockXWikiRightService = mock(XWikiRightService.class);
121  13 this.mockXWikiRightService.stubs().method("hasProgrammingRights").will(returnValue(true));
122   
123  13 this.mockXWikiStoreInterface = mock(XWikiStoreInterface.class);
124  13 this.mockXWikiStoreInterface.stubs().method("search").will(returnValue(new ArrayList<XWikiDocument>()));
125   
126  13 this.document.setStore((XWikiStoreInterface) this.mockXWikiStoreInterface.proxy());
127   
128  13 this.mockXWiki.stubs().method("getVersioningStore").will(returnValue(this.mockXWikiVersioningStore.proxy()));
129  13 this.mockXWiki.stubs().method("getStore").will(returnValue(this.mockXWikiStoreInterface.proxy()));
130  13 this.mockXWiki.stubs().method("getRightService").will(returnValue(this.mockXWikiRightService.proxy()));
131  13 this.mockXWiki.stubs().method("getDocument").will(returnValue(this.document));
132  13 this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue("en"));
133  13 this.mockXWiki.stubs().method("exists").will(returnValue(false));
134    // Called from MessageToolVelocityContextInitializer.
135  13 this.mockXWiki.stubs().method("prepareResources");
136    // The next 3 stubs are needed to properly initialize the Velocity engine.
137  13 this.mockXWiki.stubs().method("getSkin").will(returnValue("default"));
138  13 this.mockXWiki.stubs().method("getSkinFile").will(returnValue(null));
139  13 this.mockXWiki.stubs().method("Param").with(eq("xwiki.render.velocity.macrolist")).will(returnValue(""));
140  13 this.mockXWiki.stubs().method("exists").will(returnValue(false));
141  13 this.mockXWiki.stubs().method("evaluateTemplate").will(returnValue(""));
142   
143  13 getContext().setWiki((XWiki) this.mockXWiki.proxy());
144   
145  13 this.baseClass = this.document.getXClass();
146  13 this.baseClass.addTextField("string", "String", 30);
147  13 this.baseClass.addTextAreaField("area", "Area", 10, 10);
148  13 this.baseClass.addTextAreaField("puretextarea", "Pure text area", 10, 10);
149    // set the text areas an non interpreted content
150  13 ((TextAreaClass) this.baseClass.getField("puretextarea")).setContentType("puretext");
151  13 this.baseClass.addPasswordField("passwd", "Password", 30);
152  13 this.baseClass.addBooleanField("boolean", "Boolean", "yesno");
153  13 this.baseClass.addNumberField("int", "Int", 10, "integer");
154  13 this.baseClass.addStaticListField("stringlist", "StringList", "value1, value2");
155   
156  13 this.mockXWiki.stubs().method("getXClass").will(returnValue(this.baseClass));
157   
158  13 this.baseObject = this.document.newObject(CLASSNAME, getContext());
159  13 this.baseObject.setStringValue("string", "string");
160  13 this.baseObject.setLargeStringValue("area", "area");
161  13 this.baseObject.setStringValue("passwd", "passwd");
162  13 this.baseObject.setIntValue("boolean", 1);
163  13 this.baseObject.setIntValue("int", 42);
164  13 this.baseObject.setStringListValue("stringlist", Arrays.asList("VALUE1", "VALUE2"));
165    }
166   
 
167  13 toggle @Override
168    protected void registerComponents() throws Exception
169    {
170  13 super.registerComponents();
171   
172    // Setup display configuration.
173  13 this.mockDisplayConfiguration = registerMockComponent(DisplayConfiguration.class);
174  13 this.mockDisplayConfiguration.stubs().method("getDocumentDisplayerHint").will(returnValue("default"));
175  13 this.mockDisplayConfiguration.stubs().method("getTitleHeadingDepth").will(returnValue(2));
176    }
177   
 
178  1 toggle public void testCurrentDocumentVariableIsInjectedBeforeRendering() throws XWikiException
179    {
180    // Verifies we can access the doc variable from a groovy macro.
181  1 this.document.setContent("{{groovy}}print(doc);{{/groovy}}");
182  1 this.document.setSyntax(Syntax.XWIKI_2_0);
183   
184  1 assertEquals("<p>Space.Page</p>", this.document.getRenderedContent(getContext()));
185    }
186   
 
187  1 toggle public void testGetRenderedTitleWithTitle()
188    {
189  1 this.document.setSyntax(Syntax.XWIKI_2_0);
190   
191  1 this.document.setTitle("title");
192   
193  1 assertEquals("title", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
194   
195  1 this.document.setTitle("**title**");
196   
197  1 assertEquals("**title**", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
198   
199  1 this.document.setTitle("<strong>ti<em>tle</strong>");
200   
201    // The title is parsed as plain text after the Velocity code is evaluated so the HTML have no meaning.
202  1 assertEquals("&lt;strong&gt;ti&lt;em&gt;tle&lt;/strong&gt;",
203    this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
204  1 assertEquals("<strong>ti<em>tle</strong>", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
205   
206  1 this.document.setTitle("#set($key = \"title\")$key");
207   
208  1 assertEquals("title", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
209    }
210   
 
211  1 toggle public void testGetRenderedTitleWithoutTitleHTML()
212    {
213  1 this.document.setSyntax(Syntax.XWIKI_2_0);
214   
215  1 this.document.setContent(
216    "content not in section\n" + "= header 1=\nheader 1 content\n" + "== header 2==\nheader 2 content");
217   
218  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
219   
220  1 assertEquals("header 1", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
221   
222  1 this.document.setContent(
223    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
224   
225  1 assertEquals("<strong>header 1</strong>", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
226   
227  1 this.document.setContent(
228    "content not in section\n" + "= [[Space.Page]]=\nheader 1 content\n" + "== header 2==\nheader 2 content");
229   
230  1 this.mockXWiki.stubs().method("getURL").will(returnValue("/reference"));
231   
232  1 assertEquals("<span class=\"wikicreatelink\"><a href=\"/reference\"><span class=\"wikigeneratedlinkcontent\">"
233    + "Page" + "</span></a></span>", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
234   
235  1 this.document.setContent("content not in section\n" + "= #set($var ~= \"value\")=\nheader 1 content\n"
236    + "== header 2==\nheader 2 content");
237   
238  1 assertEquals("#set($var = \"value\")", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
239   
240  1 this.document.setContent("content not in section\n"
241    + "= {{groovy}}print \"value\"{{/groovy}}=\nheader 1 content\n" + "== header 2==\nheader 2 content");
242   
243  1 assertEquals("value", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
244   
245  1 this.document.setContent("content not in section\n=== header 3===");
246   
247  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
248    }
249   
 
250  1 toggle public void testGetRenderedTitleWithoutTitlePLAIN()
251    {
252  1 this.document.setSyntax(Syntax.XWIKI_2_0);
253   
254  1 this.document.setContent(
255    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
256   
257  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
258   
259  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
260   
261  1 this.document.setContent(
262    "content not in section\n" + "= **header 1**=\nheader 1 content\n" + "== header 2==\nheader 2 content");
263   
264  1 assertEquals("header 1", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
265   
266  1 this.document.setContent("content not in section\n"
267    + "= {{groovy}}print \"value\"{{/groovy}}=\nheader 1 content\n" + "== header 2==\nheader 2 content");
268   
269  1 assertEquals("value", this.document.getRenderedTitle(Syntax.PLAIN_1_0, getContext()));
270    }
271   
 
272  1 toggle public void testGetRenderedTitleNoTitleAndContent()
273    {
274  1 this.document.setSyntax(Syntax.XWIKI_2_0);
275   
276  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
277    }
278   
279    /**
280    * Make sure title extracted from content is protected from cycles
281    */
 
282  1 toggle public void testGetRenderedTitleRecursive()
283    {
284  1 this.document.setSyntax(Syntax.XWIKI_2_0);
285  1 this.document.setContent("= {{groovy}}print doc.getDisplayTitle(){{/groovy}}");
286   
287  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
288    }
289   
290    /**
291    * See XWIKI-5277 for details.
292    */
 
293  1 toggle public void testGetRenderedContentCleansVelocityMacroCache() throws Exception
294    {
295    // Make sure we start not in the rendering engine since this is what happens in real: a document is
296    // called by a template thus outside of the rendering engine.
297  1 getContext().remove("isInRenderingEngine");
298   
299    // We display a text area since we know that rendering a text area will call getRenderedContent inside our top
300    // level getRenderedContent call, thus testing that velocity macros are not removed during nested calls to
301    // getRenderedContent.
302  1 this.baseObject.setLargeStringValue("area", "{{velocity}}#macro(testmacrocache)ok#end{{/velocity}}");
303  1 this.document.setContent("{{velocity}}$doc.display(\"area\")#testmacrocache{{/velocity}}");
304  1 this.document.setSyntax(Syntax.XWIKI_2_0);
305   
306    // We need to put the current doc in the Velocity Context since it's normally set before the rendering is
307    // called in the execution flow.
308  1 VelocityManager originalVelocityManager = getComponentManager().getInstance(VelocityManager.class);
309  1 VelocityContext vcontext = originalVelocityManager.getVelocityContext();
310  1 vcontext.put("doc", new Document(this.document, getContext()));
311   
312    // Register a Mock for the VelocityManager to bypass skin APIs that we would need to mock otherwise.
313  1 Mock mockVelocityManager = registerMockComponent(VelocityManager.class);
314  1 mockVelocityManager.stubs().method("getCurrentVelocityContext").will(returnValue(vcontext));
315   
316  1 VelocityFactory velocityFactory = getComponentManager().getInstance(VelocityFactory.class);
317  1 VelocityEngine vengine = velocityFactory.createVelocityEngine("default", new Properties());
318    // Save the number of cached macro templates in the Velocity engine so that we can compare after the
319    // document is rendered.
320  1 JMXVelocityEngineMBean mbean = new JMXVelocityEngine(vengine);
321  1 int cachedMacroNamespaceSize = mbean.getTemplates().values().size();
322  1 assertTrue(cachedMacroNamespaceSize > 0);
323   
324  1 mockVelocityManager.stubs().method("getVelocityEngine").will(returnValue(vengine));
325  1 mockVelocityManager.stubs().method("evaluate").will(new CustomStub("evaluate")
326    {
 
327  2 toggle @Override
328    public Object invoke(Invocation invocation) throws Throwable
329    {
330  2 return vengine.evaluate(vcontext, (Writer) invocation.parameterValues.get(0),
331    (String) invocation.parameterValues.get(1), (Reader) invocation.parameterValues.get(2));
332    }
333    });
334   
335    // $doc.display will ask for the syntax of the current document so we need to mock it.
336  1 this.mockXWiki.stubs().method("getCurrentContentSyntaxId").with(eq("xwiki/2.0"), ANYTHING)
337    .will(returnValue("xwiki/2.0"));
338   
339    // Verify that the macro located inside the TextArea has been taken into account when executing the doc's
340    // content.
341  1 assertEquals("<p>ok</p>", this.document.getRenderedContent(getContext()));
342   
343    // Now verify that the Velocity Engine doesn't contain any more cached macro namespace to prove that
344    // getRenderedContent has correctly cleaned the Velocity macro cache.
345  1 assertEquals(cachedMacroNamespaceSize, mbean.getTemplates().values().size());
346    }
347   
 
348  1 toggle @Test
349    public void testGetRenderedTitleWhenMatchingTitleHeaderDepth()
350    {
351  1 this.document.setContent("=== level3");
352  1 this.document.setSyntax(Syntax.XWIKI_2_0);
353   
354  1 getConfigurationSource().setProperty("xwiki.title.compatibility", "1");
355   
356    // Overwrite the title heading depth.
357  1 this.mockDisplayConfiguration.stubs().method("getTitleHeadingDepth").will(returnValue(3));
358   
359  1 assertEquals("level3", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
360    }
361   
 
362  1 toggle @Test
363    public void testGetRenderedTitleWhenNotMatchingTitleHeaderDepth()
364    {
365  1 this.document.setContent("=== level3");
366  1 this.document.setSyntax(Syntax.XWIKI_2_0);
367   
368  1 assertEquals("Page", this.document.getRenderedTitle(Syntax.XHTML_1_0, getContext()));
369    }
370   
 
371  1 toggle public void testGetRenderedContent() throws XWikiException
372    {
373  1 this.document.setContent("**bold**");
374  1 this.document.setSyntax(Syntax.XWIKI_2_0);
375   
376  1 assertEquals("<p><strong>bold</strong></p>", this.document.getRenderedContent(getContext()));
377   
378  1 this.translatedDocument = new XWikiDocument(this.document.getDocumentReference(), Locale.FRENCH);
379  1 this.translatedDocument.setContent("//italic//");
380  1 this.translatedDocument.setSyntax(Syntax.XWIKI_1_0);
381  1 this.translatedDocument.setNew(false);
382   
383  1 this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue(Locale.FRENCH.toString()));
384  1 this.mockXWiki.stubs().method("getDocument").with(eq(
385    new DocumentReference(this.translatedDocument.getDocumentReference(), this.translatedDocument.getLocale())),
386    ANYTHING).will(returnValue(this.translatedDocument));
387   
388  1 assertEquals("<p><em>italic</em></p>", this.document.getRenderedContent(getContext()));
389    }
390   
 
391  1 toggle public void testGetRenderedContentRights() throws XWikiException
392    {
393  1 getContext().remove("sdoc");
394   
395  1 this.document.setContent("{{velocity}}$xcontext.sdoc{{/velocity}}");
396  1 this.document.setSyntax(Syntax.XWIKI_2_1);
397   
398  1 assertEquals("<p>Space.Page</p>", this.document.getRenderedContent(getContext()));
399    }
400   
 
401  1 toggle public void testGetRenderedContentTextWithSourceSyntax()
402    {
403  1 this.document.setSyntax(Syntax.XWIKI_1_0);
404   
405  1 assertEquals("<p><strong>bold</strong></p>",
406    this.document.getRenderedContent("**bold**", "xwiki/2.0", getContext()));
407    }
408   
 
409  1 toggle public void testGetRenderedContentTextRights() throws XWikiException
410    {
411  1 XWikiDocument otherDocument = new XWikiDocument(new DocumentReference("otherwiki", "otherspace", "otherpage"));
412  1 otherDocument.setContentAuthorReference(new DocumentReference("otherwiki", "XWiki", "othercontentauthor"));
413  1 XWikiDocument sdoc = new XWikiDocument(new DocumentReference("callerwiki", "callerspace", "callerpage"));
414  1 sdoc.setContentAuthorReference(new DocumentReference("callerwiki", "XWiki", "calleruser"));
415  1 Document apiDocument = this.document.newDocument(getContext());
416   
417  1 getContext().setDoc(null);
418   
419  1 String content =
420    "{{velocity}}" + "$xcontext.sdoc.contentAuthorReference $xcontext.doc $xcontext.doc.contentAuthorReference"
421    + "{{/velocity}}";
422   
423  1 this.document.setContentAuthorReference(new DocumentReference("authorwiki", "XWiki", "contentauthor"));
424   
425  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
426    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
427   
428  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
429    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
430   
431  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
432    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
433   
434  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
435    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), false, otherDocument,
436    getContext()));
437   
438  1 getContext().setDoc(otherDocument);
439   
440  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
441    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
442   
443  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
444    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
445   
446  1 assertEquals("<p>otherwiki:XWiki.othercontentauthor Space.Page authorwiki:XWiki.contentauthor</p>",
447    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
448   
449  1 getContext().put("sdoc", sdoc);
450  1 getContext().setDoc(this.document);
451   
452  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
453    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
454   
455  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
456    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
457   
458  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
459    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
460   
461  1 getContext().setDoc(otherDocument);
462   
463  1 assertEquals("<p>$xcontext.sdoc.contentAuthorReference Space.Page authorwiki:XWiki.contentauthor</p>",
464    this.document.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), getContext()));
465   
466  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
467    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString()));
468   
469  1 assertEquals("<p>callerwiki:XWiki.calleruser Space.Page authorwiki:XWiki.contentauthor</p>",
470    apiDocument.getRenderedContent(content, Syntax.XWIKI_2_1.toIdString(), Syntax.XHTML_1_0.toIdString()));
471   
472    }
473    }