use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class StressTestVersioningProvider method runMassiveFileTest.
private void runMassiveFileTest(final int maxpages) throws Exception {
final String text = "Testing, 1, 2, 3: ";
final String name = NAME1;
final Benchmark mark = new Benchmark();
System.out.println("Building a massive repository of " + maxpages + " pages...");
mark.start();
for (int i = 0; i < maxpages; i++) {
engine.saveText(name + i, text + i);
}
mark.stop();
System.out.println("Total time to save " + maxpages + " pages was " + mark.toString());
System.out.println("Saved " + mark.toString(maxpages) + " pages/second");
mark.reset();
mark.start();
final Collection<Page> pages = engine.getManager(PageManager.class).getAllPages();
mark.stop();
System.out.println("Got a list of all pages in " + mark);
mark.reset();
mark.start();
for (final Page page : pages) {
final String foo = engine.getManager(PageManager.class).getPureText(page);
Assertions.assertNotNull(foo);
}
mark.stop();
System.out.println("Read through all of the pages in " + mark);
System.out.println("which is " + mark.toString(maxpages) + " pages/second");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class FileSystemProviderTest method testCustomProperties.
@Test
public void testCustomProperties() throws Exception {
final String pageDir = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
final String pageName = "CustomPropertiesTest";
final String fileName = pageName + FileSystemProvider.FILE_EXT;
final File file = new File(pageDir, fileName);
Assertions.assertFalse(file.exists());
final WikiPage testPage = new WikiPage(m_engine, pageName);
testPage.setAuthor("TestAuthor");
testPage.setAttribute("@test", "Save Me");
testPage.setAttribute("@test2", "Save You");
testPage.setAttribute("test3", "Do not save");
m_provider.putPageText(testPage, "This page has custom properties");
Assertions.assertTrue(file.exists(), "No such file");
final Page pageRetrieved = m_provider.getPageInfo(pageName, -1);
final String value = pageRetrieved.getAttribute("@test");
final String value2 = pageRetrieved.getAttribute("@test2");
final String value3 = pageRetrieved.getAttribute("test3");
Assertions.assertNotNull(value);
Assertions.assertNotNull(value2);
Assertions.assertNull(value3);
Assertions.assertEquals("Save Me", value);
Assertions.assertEquals("Save You", value2);
file.delete();
Assertions.assertFalse(file.exists());
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class VerySimpleProvider method getPageInfo.
/**
* Returns always a valid WikiPage.
*/
@Override
public Page getPageInfo(final String page, final int version) {
m_latestReq = page;
m_latestVers = version;
final Page p = Wiki.contents().page(m_engine, page);
p.setVersion(5);
p.setAuthor(AUTHOR);
p.setLastModified(new Date(0L));
return p;
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class PageViewPluginTest method testShowCountsExclude.
@Test
public void testShowCountsExclude() throws Exception {
testEngine.saveText("TestPageExcluded", "this is test page that should be excluded [{PageViewPlugin}]");
final Page page1 = testEngine.getManager(PageManager.class).getPage("TestPage01");
final Context context1 = Wiki.context().create(testEngine, page1);
final Page page2 = testEngine.getManager(PageManager.class).getPage("TestPage02");
final Context context2 = Wiki.context().create(testEngine, page2);
// generate counts:
testEngine.getManager(RenderingManager.class).getHTML(context1, page1);
testEngine.getManager(RenderingManager.class).getHTML(context2, page2);
testEngine.getManager(RenderingManager.class).getHTML(context2, page2);
// mind the double \n in the following string:
final String pageViewPageContent = "[{PageViewPlugin show='list' exclude='TestPageExcl*' '\n\n* {1} ({2} views)\n}]";
testEngine.saveText("PageViews", pageViewPageContent);
final Page pageviews = testEngine.getManager(PageManager.class).getPage("PageViews");
final Context contextPV = Wiki.context().create(testEngine, pageviews);
final String result = testEngine.getManager(RenderingManager.class).getHTML(contextPV, pageviews);
// System.out.println( result );
Assertions.assertTrue(result.contains("Test Page 01"));
// this page should not have been shown:
Assertions.assertFalse(result.contains("Test Page Excluded"));
testEngine.deleteTestPage("TestPageExcluded");
}
use of org.apache.wiki.api.core.Page in project jspwiki by apache.
the class PageViewPluginTest method testShowCountEntries.
@Test
public void testShowCountEntries() throws Exception {
// create pages that should be counted
testEngine.saveText("TestPage03", "this is test page 03 [{PageViewPlugin}]");
testEngine.saveText("TestPage04", "this is test page 04 [{PageViewPlugin}]");
final Page page1 = testEngine.getManager(PageManager.class).getPage("TestPage01");
final Context context1 = Wiki.context().create(testEngine, page1);
final Page page2 = testEngine.getManager(PageManager.class).getPage("TestPage02");
final Context context2 = Wiki.context().create(testEngine, page2);
final Page page3 = testEngine.getManager(PageManager.class).getPage("TestPage03");
final Context context3 = Wiki.context().create(testEngine, page3);
final Page page4 = testEngine.getManager(PageManager.class).getPage("TestPage04");
final Context context4 = Wiki.context().create(testEngine, page4);
// generate counts:
testEngine.getManager(RenderingManager.class).getHTML(context1, page1);
testEngine.getManager(RenderingManager.class).getHTML(context2, page2);
testEngine.getManager(RenderingManager.class).getHTML(context2, page2);
testEngine.getManager(RenderingManager.class).getHTML(context3, page3);
testEngine.getManager(RenderingManager.class).getHTML(context4, page4);
// mind the double \n in the following string:
final String pageViewPageContent = "[{PageViewPlugin show='list' entries=3'\n\n* {1} ({2} views)\n}]";
testEngine.saveText("PageViews", pageViewPageContent);
final Page pageviews = testEngine.getManager(PageManager.class).getPage("PageViews");
final Context contextPV = Wiki.context().create(testEngine, pageviews);
final String result = testEngine.getManager(RenderingManager.class).getHTML(contextPV, pageviews);
// System.out.println( result );
Assertions.assertTrue(result.contains("Test Page 03"));
Assertions.assertFalse(result.contains("Test Page 04"));
testEngine.deleteTestPage("TestPage03");
testEngine.deleteTestPage("TestPage04");
}
Aggregations