use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class IfPluginTest method testIfPluginUserNotAllowed.
/**
* Checks that user access is forbidden.
*
* @throws WikiException test Assert.failing.
*/
@Test
public void testIfPluginUserNotAllowed() throws WikiException {
String src = "[{IfPlugin user='!Janne Jalkanen'\n" + "\n" + "Content NOT visible for Janne Jalkanen}]";
String expected = "\n";
testEngine.saveText("Test", src);
WikiPage page = testEngine.getPage("Test", WikiPageProvider.LATEST_VERSION);
WikiContext context = getJanneBasedWikiContextFor(page);
String res = testEngine.getHTML(context, page);
Assert.assertEquals(expected, res);
}
use of org.apache.wiki.WikiContext 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}]");
WikiPage page1 = testEngine.getPage("TestPage01");
WikiContext context1 = new WikiContext(testEngine, page1);
WikiPage page2 = testEngine.getPage("TestPage02");
WikiContext context2 = new WikiContext(testEngine, page2);
// generate counts:
testEngine.getHTML(context1, page1);
testEngine.getHTML(context2, page2);
testEngine.getHTML(context2, page2);
// mind the double \n in the following string:
String pageViewPageContent = "[{PageViewPlugin show='list' exclude='TestPageExcl*' '\n\n* {1} ({2} views)\n}]";
testEngine.saveText("PageViews", pageViewPageContent);
WikiPage pageviews = testEngine.getPage("PageViews");
WikiContext contextPV = new WikiContext(testEngine, pageviews);
String result = testEngine.getHTML(contextPV, pageviews);
// System.out.println( result );
Assert.assertTrue(result.contains("Test Page 01"));
// this page should not have been shown:
Assert.assertFalse(result.contains("Test Page Excluded"));
testEngine.deleteTestPage("TestPageExcluded");
}
use of org.apache.wiki.WikiContext 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}]");
WikiPage page1 = testEngine.getPage("TestPage01");
WikiContext context1 = new WikiContext(testEngine, page1);
WikiPage page2 = testEngine.getPage("TestPage02");
WikiContext context2 = new WikiContext(testEngine, page2);
WikiPage page3 = testEngine.getPage("TestPage03");
WikiContext context3 = new WikiContext(testEngine, page3);
WikiPage page4 = testEngine.getPage("TestPage04");
WikiContext context4 = new WikiContext(testEngine, page4);
// generate counts:
testEngine.getHTML(context1, page1);
testEngine.getHTML(context2, page2);
testEngine.getHTML(context2, page2);
testEngine.getHTML(context3, page3);
testEngine.getHTML(context4, page4);
// mind the double \n in the following string:
String pageViewPageContent = "[{PageViewPlugin show='list' entries=3'\n\n* {1} ({2} views)\n}]";
testEngine.saveText("PageViews", pageViewPageContent);
WikiPage pageviews = testEngine.getPage("PageViews");
WikiContext contextPV = new WikiContext(testEngine, pageviews);
String result = testEngine.getHTML(contextPV, pageviews);
// System.out.println( result );
Assert.assertTrue(result.contains("Test Page 03"));
Assert.assertFalse(result.contains("Test Page 04"));
testEngine.deleteTestPage("TestPage03");
testEngine.deleteTestPage("TestPage04");
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class ReferringPagesPluginTest method testSingleReferral.
@Test
public void testSingleReferral() throws Exception {
WikiContext context2 = new WikiContext(engine, new WikiPage(engine, "Foobar"));
String res = manager.execute(context2, "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE max=5}");
Assert.assertEquals(mkLink("TestPage") + "<br />", res);
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class ReferringUndefinedPagesPluginTest method setUp.
@Before
public void setUp() throws Exception {
CacheManager.getInstance().removeAllCaches();
testEngine = new TestEngine(props);
testEngine.saveText("TestPage01", "Some Text for testing 01 which refers [NonExistingPageA] ");
testEngine.saveText("TestPage02", "Some Text for testing 02 which refers [NonExistingPageB] ");
testEngine.saveText("TestPage03", "Some Text for testing 03 which refers [NonExistingPageC] ");
context = new WikiContext(testEngine, testEngine.newHttpRequest(), new WikiPage(testEngine, "TestPage"));
manager = new DefaultPluginManager(testEngine, props);
}
Aggregations