use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class PageViewPluginTest method testShowCountsSorted.
@Test
public void testShowCountsSorted() throws Exception {
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' sort=count '\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 );
int start1 = result.indexOf("Test Page 01");
int start2 = result.indexOf("Test Page 02");
// page2 should be showed before page1
Assert.assertTrue(start2 < start1);
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class PageViewPluginTest method testShowCountsBasic.
@Test
public void testShowCountsBasic() throws Exception {
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''\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 (2 views)"));
Assert.assertTrue(result.contains("Test Page 02 (3 views)"));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RecentChangesPluginTest method testSimple.
/**
* Plain test without parameters
*
* @throws Exception
*/
@Test
public void testSimple() throws Exception {
context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage01"));
String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin}");
// we don't want to compare the complete html returned, but check if
// certain Strings are present and other Strings are not present
Assert.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage01\">Test Page 01</a>"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage02\">Test Page 02</a>"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage03\">Test Page 03</a>"));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RecentChangesPluginTest method testParmExClude.
/**
* Test with the exclude parameter
*
* @throws Exception
*/
@Test
public void testParmExClude() throws Exception {
context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage03"));
String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin exclude='TestPage03*'}");
Assert.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage01\">Test Page 01</a>"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage02\">Test Page 02</a>"));
Assert.assertFalse(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage03\">Test Page 03</a>"));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RecentChangesPluginTest method testParmInClude.
/**
* Test with the include parameter
*
* @throws Exception
*/
@Test
public void testParmInClude() throws Exception {
context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage02"));
String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin include='TestPage02*'}");
Assert.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
Assert.assertFalse(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage01\">Test Page 01</a>"));
Assert.assertTrue(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage02\">Test Page 02</a>"));
Assert.assertFalse(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage03\">Test Page 03</a>"));
}
Aggregations