Search in sources :

Example 51 with Page

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");
}
Also used : PageManager(org.apache.wiki.pages.PageManager) WikiPage(org.apache.wiki.WikiPage) Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 52 with Page

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");
}
Also used : PageManager(org.apache.wiki.pages.PageManager) WikiPage(org.apache.wiki.WikiPage) Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 53 with Page

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");
}
Also used : PageManager(org.apache.wiki.pages.PageManager) WikiPage(org.apache.wiki.WikiPage) Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 54 with Page

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("&lt;b&gt;Bar&lt;/b&gt;"), "has proper Bar");
}
Also used : Context(org.apache.wiki.api.core.Context) WeblogPlugin(org.apache.wiki.plugin.WeblogPlugin) Page(org.apache.wiki.api.core.Page) WeblogEntryPlugin(org.apache.wiki.plugin.WeblogEntryPlugin) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 55 with Page

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");
}
Also used : PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page)

Aggregations

Page (org.apache.wiki.api.core.Page)181 PageManager (org.apache.wiki.pages.PageManager)106 Test (org.junit.jupiter.api.Test)71 Context (org.apache.wiki.api.core.Context)46 Engine (org.apache.wiki.api.core.Engine)30 Attachment (org.apache.wiki.api.core.Attachment)27 ProviderException (org.apache.wiki.api.exceptions.ProviderException)22 Date (java.util.Date)21 WikiPage (org.apache.wiki.WikiPage)18 ReferenceManager (org.apache.wiki.references.ReferenceManager)16 RenderingManager (org.apache.wiki.render.RenderingManager)15 AttachmentManager (org.apache.wiki.attachment.AttachmentManager)14 File (java.io.File)11 ArrayList (java.util.ArrayList)10 Calendar (java.util.Calendar)10 Hashtable (java.util.Hashtable)10 IOException (java.io.IOException)9 Vector (java.util.Vector)9 TestEngine (org.apache.wiki.TestEngine)9 PagePermission (org.apache.wiki.auth.permissions.PagePermission)8