use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class IfPluginTest method testIfPluginIPNotAllowed.
/**
* Checks that IP address is granted.
*
* @throws WikiException test Assert.failing.
*/
@Test
public void testIfPluginIPNotAllowed() throws WikiException {
String src = "[{IfPlugin ip='!127.0.0.1'\n" + "\n" + "Content NOT visible for 127.0.0.1}]";
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.WikiPage 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.WikiPage 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.WikiPage 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.WikiPage 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);
}
Aggregations