public void testSwitchOrderOfRenderers() throws Exception { String text = "#set($x = '<' + '% println(\"hello world\"); %' + '>')\n$x"; String velocityFirst = "hello world"; String groovyFirst = "<% println(\"hello world\"); %>"; XWikiDocument document = new XWikiDocument(); // Prove that the renderers are in the right order by default. assertEquals( engine.getRendererNames(), new ArrayList<String>() { { add("mapping"); add("groovy"); add("velocity"); add("plugin"); add("wiki"); add("xwiki"); } }); assertEquals(groovyFirst, engine.renderText(text, document, getContext())); xwiki .getConfig() .put( "xwiki.render.renderingorder", "macromapping, velocity, groovy, plugin, wiki, wikiwiki"); DefaultXWikiRenderingEngine myEngine = new DefaultXWikiRenderingEngine(xwiki, getContext()); assertEquals( myEngine.getRendererNames(), new ArrayList<String>() { { add("mapping"); add("velocity"); add("groovy"); add("plugin"); add("wiki"); add("xwiki"); } }); assertEquals(velocityFirst, myEngine.renderText(text, document, getContext())); }
/** Test that links are preserved after rendering. XWIKI-2672 */ public void testLinksAndCache() throws Exception { String link = "http://some:123/link"; String text = "$context.setCacheDuration(1800)\n" + link; XWikiDocument document = new XWikiDocument(); Utils.enablePlaceholders(getContext()); String out = engine.renderText(text, document, getContext()); assertTrue(out.contains(link)); }
public void testRenderTextWhenUsingCodeMacro() throws Exception { // We verify that the code macro doesn't render wiki markup, velocity, HTML, or other radeox // macros. // We also ensure that any Radeox macro coming after the code macro is rendered properly. // Last we also ensure that a second code macro works too. String text = "{code:none}\n" + "1 Title\n" + "c:\\dev\n" + "#info(\"test\")\n" + "<pre>hello</pre>\n" + "$xwiki.getVersion()\n" + "{style}style{style}\n" + "{code}nested{code}\n" + "<% print(\"hello\") %>\n" + "{code}\n" + "{table}\n" + "a | b\n" + "c | d\n" + "{table}\n" + "#set ($var = 'dummy')\n" + "{code:none}\n" + "1 Something\n" + "{code}"; String expectedText = "<div class=\"code\"><pre>1 Title\n" + "c:\dev\n" + "#info(\"test\")\n" + "<pre>hello</pre>\n" + "$xwiki.getVersion()\n" + "{style}style{style}\n" + "&#123;code}nested&#123;code}\n" + "<% print(\"hello\") %></pre></div>\n" + "<table class=\"wiki-table\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><th>a</th>" + "<th>b</th></tr><tr class=\"table-odd\"><td>c</td><td>d</td></tr></table>\n" + "<div class=\"code\"><pre>1 Something</pre></div>"; XWikiDocument document = new XWikiDocument(); assertEquals(expectedText, engine.renderText(text, document, getContext())); }
public void testRenderGroovy() throws Exception { assertEquals( "hello world", engine.renderText("<% println(\"hello world\"); %>", new XWikiDocument(), getContext())); }