use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersion.
@Test
public void testGetOldVersion() throws Exception {
final String text = "diddo\r\n";
final String text2 = "barbar\r\n";
final String text3 = "Barney\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
final Page res = engine.getManager(PageManager.class).getPage(NAME1);
Assertions.assertEquals(3, res.getVersion(), "wrong version");
Assertions.assertEquals(text, engine.getManager(PageManager.class).getText(NAME1, 1), "ver1");
Assertions.assertEquals(text2, engine.getManager(PageManager.class).getText(NAME1, 2), "ver2");
Assertions.assertEquals(text3, engine.getManager(PageManager.class).getText(NAME1, 3), "ver3");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersionUTF8.
/**
* 2.0.7 and before got this wrong.
*/
@Test
public void testGetOldVersionUTF8() throws Exception {
final String text = "\u00e5\u00e4\u00f6\r\n";
final String text2 = "barbar\u00f6\u00f6\r\n";
final String text3 = "Barney\u00e4\u00e4\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
final Page res = engine.getManager(PageManager.class).getPage(NAME1);
Assertions.assertEquals(3, res.getVersion(), "wrong version");
Assertions.assertEquals(text, engine.getManager(PageManager.class).getText(NAME1, 1), "ver1");
Assertions.assertEquals(text2, engine.getManager(PageManager.class).getText(NAME1, 2), "ver2");
Assertions.assertEquals(text3, engine.getManager(PageManager.class).getText(NAME1, 3), "ver3");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersion2.
@Test
public void testGetOldVersion2() throws Exception {
final String text = "diddo\r\n";
final String text2 = "barbar\r\n";
final String text3 = "Barney\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
final Page res = engine.getManager(PageManager.class).getPage(NAME1);
Assertions.assertEquals(3, res.getVersion(), "wrong version");
Assertions.assertEquals(1, engine.getManager(PageManager.class).getPage(NAME1, 1).getVersion(), "ver1");
Assertions.assertEquals(2, engine.getManager(PageManager.class).getPage(NAME1, 2).getVersion(), "ver2");
Assertions.assertEquals(3, engine.getManager(PageManager.class).getPage(NAME1, 3).getVersion(), "ver3");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class RSSGeneratorTest method testBlogRSS.
@Test
public void testBlogRSS() 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");
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 RSS10Feed(context);
final String blog = gen.generateBlogRSS(context, entries, feed);
Assertions.assertTrue(blog.contains("<description>Foo</description>"), "has Foo");
Assertions.assertTrue(blog.contains("<b>Bar</b>"), "has proper Bar");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class StressTestVersioningProvider method testMillionChanges.
public void testMillionChanges() throws Exception {
String text = "";
final String name = NAME1;
// Save 2000 versions.
final int maxver = 2000;
final Benchmark mark = new Benchmark();
mark.start();
for (int i = 0; i < maxver; i++) {
text = text + ".";
engine.saveText(name, text);
}
mark.stop();
System.out.println("Benchmark: " + mark.toString(2000) + " pages/second");
final Page pageinfo = engine.getManager(PageManager.class).getPage(NAME1);
Assertions.assertEquals(maxver, pageinfo.getVersion(), "wrong version");
// +2 comes from \r\n.
Assertions.assertEquals(maxver + 2, engine.getManager(PageManager.class).getText(NAME1).length(), "wrong text");
}
Aggregations