Search in sources :

Example 1 with PageProvider

use of org.apache.wiki.api.providers.PageProvider in project jspwiki by apache.

the class WikiProviderAdaptersTest method testPageProvider.

@Test
public void testPageProvider() throws Exception {
    final PageProvider pageProvider = engine.getManager(PageManager.class).getProvider();
    final QueryItem qi = new QueryItem();
    qi.word = "blablablabla";
    qi.type = QueryItem.REQUESTED;
    Assertions.assertEquals("com.example.providers.TwoXWikiPageProvider", pageProvider.getProviderInfo());
    Assertions.assertEquals(3, pageProvider.getAllChangedSince(new Date(0L)).size());
    Assertions.assertEquals(3, pageProvider.getAllPages().size());
    Assertions.assertEquals(3, pageProvider.getPageCount());
    Assertions.assertTrue(pageProvider.pageExists("page1"));
    Assertions.assertTrue(pageProvider.pageExists("page1", 0));
    pageProvider.movePage("page1", "page0");
    Assertions.assertTrue(pageProvider.pageExists("page0"));
    Assertions.assertFalse(pageProvider.pageExists("page1"));
    pageProvider.putPageText(new WikiPage(engine, "page4"), "bloblobloblo");
    Assertions.assertTrue(pageProvider.pageExists("page4"));
    Assertions.assertEquals(1, pageProvider.findPages(new QueryItem[] { qi }).size());
    pageProvider.putPageText(new WikiPage(engine, "page4"), "blublublublu");
    Assertions.assertEquals(2, pageProvider.getVersionHistory("page4").size());
    Assertions.assertEquals("bloblobloblo", pageProvider.getPageText("page4", 0));
    Assertions.assertEquals("blublublublu", pageProvider.getPageText("page4", 1));
    pageProvider.deleteVersion("page4", 1);
    Assertions.assertEquals(1, pageProvider.getVersionHistory("page4").size());
    pageProvider.deletePage("page4");
    Assertions.assertFalse(pageProvider.pageExists("page4"));
}
Also used : QueryItem(org.apache.wiki.api.search.QueryItem) PageManager(org.apache.wiki.pages.PageManager) PageProvider(org.apache.wiki.api.providers.PageProvider) WikiPage(org.apache.wiki.WikiPage) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 2 with PageProvider

use of org.apache.wiki.api.providers.PageProvider in project jspwiki by apache.

the class VersioningFileProviderTest method testDelete.

@Test
public void testDelete() throws Exception {
    engine.saveText(NAME1, "v1");
    engine.saveText(NAME1, "v2");
    engine.saveText(NAME1, "v3");
    final PageManager mgr = engine.getManager(PageManager.class);
    final PageProvider provider = mgr.getProvider();
    provider.deletePage(NAME1);
    final File f = new File(files, NAME1 + AbstractFileProvider.FILE_EXT);
    Assertions.assertFalse(f.exists(), "file exists");
}
Also used : PageManager(org.apache.wiki.pages.PageManager) PageProvider(org.apache.wiki.api.providers.PageProvider) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with PageProvider

use of org.apache.wiki.api.providers.PageProvider in project jspwiki by apache.

the class VersioningFileProviderTest method testDeleteVersion.

@Test
public void testDeleteVersion() throws Exception {
    engine.saveText(NAME1, "v1\r\n");
    engine.saveText(NAME1, "v2\r\n");
    engine.saveText(NAME1, "v3\r\n");
    final PageManager mgr = engine.getManager(PageManager.class);
    final PageProvider provider = mgr.getProvider();
    List<Page> l = provider.getVersionHistory(NAME1);
    Assertions.assertEquals(3, l.size(), "wrong # of versions");
    provider.deleteVersion(NAME1, 2);
    l = provider.getVersionHistory(NAME1);
    Assertions.assertEquals(2, l.size(), "wrong # of versions");
    Assertions.assertEquals("v1\r\n", provider.getPageText(NAME1, 1), "v1");
    Assertions.assertEquals("v3\r\n", provider.getPageText(NAME1, 3), "v3");
    try {
        provider.getPageText(NAME1, 2);
        Assertions.fail("v2");
    } catch (final NoSuchVersionException e) {
    // This is expected
    }
}
Also used : PageManager(org.apache.wiki.pages.PageManager) PageProvider(org.apache.wiki.api.providers.PageProvider) WikiPage(org.apache.wiki.WikiPage) Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Aggregations

PageProvider (org.apache.wiki.api.providers.PageProvider)3 PageManager (org.apache.wiki.pages.PageManager)3 Test (org.junit.jupiter.api.Test)3 WikiPage (org.apache.wiki.WikiPage)2 File (java.io.File)1 Date (java.util.Date)1 Page (org.apache.wiki.api.core.Page)1 QueryItem (org.apache.wiki.api.search.QueryItem)1