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"));
}
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");
}
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
}
}
Aggregations