use of org.apache.wiki.api.core.Context 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.
*/
@Test
public void testCache() throws Exception {
m_engine.saveText("TestPage", TEST_TEXT);
final StopWatch sw = new StopWatch();
// System.out.println("DOM cache speed test:");
sw.start();
for (int i = 0; i < 300; i++) {
final Page page = m_engine.getManager(PageManager.class).getPage("TestPage");
final String pagedata = m_engine.getManager(PageManager.class).getPureText(page);
final Context context = Wiki.context().create(m_engine, page);
final MarkupParser p = m_manager.getParser(context, pagedata);
final WikiDocument d = p.parse();
final String html = m_manager.getHTML(context, d);
Assertions.assertNotNull(html, "noncached got null response");
}
sw.stop();
sw.reset();
sw.start();
for (int i = 0; i < 300; i++) {
final Page page = m_engine.getManager(PageManager.class).getPage("TestPage");
final String pagedata = m_engine.getManager(PageManager.class).getPureText(page);
final Context context = Wiki.context().create(m_engine, page);
final String html = m_manager.getHTML(context, pagedata);
Assertions.assertNotNull(html, "cached got null response");
}
sw.stop();
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class RSSGeneratorTest method testBlogRSS2.
@Test
public void testBlogRSS2() throws Exception {
final 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__");
final RSSGenerator gen = m_testEngine.getManager(RSSGenerator.class);
final Context context = Wiki.context().create(m_testEngine, m_testEngine.getManager(PageManager.class).getPage("TestBlog"));
final WeblogPlugin blogplugin = new WeblogPlugin();
final List<Page> entries = blogplugin.findBlogEntries(m_testEngine, "TestBlog", new Date(0), new Date(Long.MAX_VALUE));
final Feed feed = new RSS20Feed(context);
final String blog = gen.generateBlogRSS(context, entries, feed);
Assertions.assertTrue(blog.contains("<description>Foo &quot;blah&quot;.</description>"), "has Foo");
Assertions.assertTrue(blog.contains("<b>Bar</b>"), "has proper Bar");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class PageRenamerTest method testReferrerChangeMultiRename2.
@Test
public void testReferrerChangeMultiRename2() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "[Test|TestPage]");
final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
final Context context = Wiki.context().create(m_engine, p);
m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
m_engine.getManager(PageRenamer.class).renamePage(context, "FooTest", "BarTest", true);
final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assertions.assertEquals("[Test|BarTest]", data.trim(), "no rename");
Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage");
Assertions.assertNull(refs, "oldpage");
refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooPage");
Assertions.assertNull(refs, "oldpage");
refs = m_engine.getManager(ReferenceManager.class).findReferrers("BarTest");
Assertions.assertEquals(1, refs.size(), "new size");
Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class PageRenamerTest method testReferrerChangeAnchor.
@Test
public void testReferrerChangeAnchor() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "[TestPage#heading1]");
final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
final Context context = Wiki.context().create(m_engine, p);
m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assertions.assertEquals("[FooTest#heading1]", data.trim(), "no rename");
Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage");
Assertions.assertNull(refs, "oldpage");
refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooTest");
Assertions.assertEquals(1, refs.size(), "new size");
Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class PageRenamerTest method testReferrerNoWikiName.
@Test
public void testReferrerNoWikiName() throws Exception {
m_engine.saveText("Test", "foo");
m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
final Context context = Wiki.context().create(m_engine, p);
m_engine.getManager(PageRenamer.class).renamePage(context, "Test", "TestPage", true);
final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assertions.assertEquals("[TestPage] [TestPage#anchor] test Test [TestPage] [link|TestPage] [link|TestPage]", data.trim(), "wrong data");
}
Aggregations