use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class VersioningFileProviderTest method testChangeNoteOldVersion2.
@Test
public void testChangeNoteOldVersion2() throws Exception {
WikiPage p = new WikiPage(engine, NAME1);
WikiContext context = new WikiContext(engine, p);
context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change");
engine.saveText(context, "test");
for (int i = 0; i < 5; i++) {
WikiPage p2 = (WikiPage) engine.getPage(NAME1).clone();
p2.removeAttribute(WikiPage.CHANGENOTE);
context.setPage(p2);
engine.saveText(context, "test" + i);
}
WikiPage p3 = engine.getPage(NAME1, -1);
Assert.assertEquals(null, p3.getAttribute(WikiPage.CHANGENOTE));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class CreoleRendererTest method render.
private String render(String s) throws IOException {
WikiPage dummyPage = new WikiPage(m_testEngine, "TestPage");
WikiContext ctx = new WikiContext(m_testEngine, dummyPage);
StringReader in = new StringReader(s);
JSPWikiMarkupParser p = new JSPWikiMarkupParser(ctx, in);
WikiDocument d = p.parse();
CreoleRenderer cr = new CreoleRenderer(ctx, d);
return cr.getString();
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RenderingManagerTest method testCache.
/**
* Tests the relative speed of the DOM cache with respect to
* page being parsed every single time.
* @throws Exception
*/
@Test
public void testCache() throws Exception {
m_engine.saveText("TestPage", TEST_TEXT);
StopWatch sw = new StopWatch();
// System.out.println("DOM cache speed test:");
sw.start();
for (int i = 0; i < 300; i++) {
WikiPage page = m_engine.getPage("TestPage");
String pagedata = m_engine.getPureText(page);
WikiContext context = new WikiContext(m_engine, page);
MarkupParser p = m_manager.getParser(context, pagedata);
WikiDocument d = p.parse();
String html = m_manager.getHTML(context, d);
Assert.assertNotNull("noncached got null response", html);
}
sw.stop();
// System.out.println(" Nocache took "+sw);
long nocachetime = sw.getTime();
sw.reset();
sw.start();
for (int i = 0; i < 300; i++) {
WikiPage page = m_engine.getPage("TestPage");
String pagedata = m_engine.getPureText(page);
WikiContext context = new WikiContext(m_engine, page);
String html = m_manager.getHTML(context, pagedata);
Assert.assertNotNull("cached got null response", html);
}
sw.stop();
// System.out.println(" Cache took "+sw);
long speedup = nocachetime / sw.getTime();
// System.out.println(" Approx speedup: "+speedup+"x");
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class WysiwygEditingRendererTest method render.
private String render(String s) throws IOException {
WikiPage dummyPage = new WikiPage(testEngine, "TestPage");
WikiContext ctx = new WikiContext(testEngine, dummyPage);
StringReader in = new StringReader(s);
JSPWikiMarkupParser p = new JSPWikiMarkupParser(ctx, in);
WikiDocument d = p.parse();
WysiwygEditingRenderer wer = new WysiwygEditingRenderer(ctx, d);
return wer.getString();
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RSSGeneratorTest method testBlogRSS2.
@Test
public void testBlogRSS2() throws Exception {
WeblogEntryPlugin plugin = new WeblogEntryPlugin();
m_testEngine.saveText("TestBlog", "Foo1");
String newPage = plugin.getNewEntryPage(m_testEngine, "TestBlog");
m_testEngine.saveText(newPage, "!Title1\r\nFoo \"blah\".");
newPage = plugin.getNewEntryPage(m_testEngine, "TestBlog");
m_testEngine.saveText(newPage, "!Title2\r\n__Bar__");
RSSGenerator gen = m_testEngine.getRSSGenerator();
WikiContext context = new WikiContext(m_testEngine, m_testEngine.getPage("TestBlog"));
WeblogPlugin blogplugin = new WeblogPlugin();
List<?> entries = blogplugin.findBlogEntries(m_testEngine, "TestBlog", new Date(0), new Date(Long.MAX_VALUE));
Feed feed = new RSS20Feed(context);
String blog = gen.generateBlogRSS(context, entries, feed);
Assert.assertTrue("has Foo", blog.indexOf("<description>Foo &quot;blah&quot;.</description>") != -1);
Assert.assertTrue("has proper Bar", blog.indexOf("<b>Bar</b>") != -1);
}
Aggregations