use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class StressTestVersioningProvider method testMillionChanges.
public void testMillionChanges() throws Exception {
String text = "";
String name = NAME1;
// Save 2000 versions.
int maxver = 2000;
Benchmark mark = new Benchmark();
mark.start();
for (int i = 0; i < maxver; i++) {
text = text + ".";
engine.saveText(name, text);
}
mark.stop();
System.out.println("Benchmark: " + mark.toString(2000) + " pages/second");
WikiPage pageinfo = engine.getPage(NAME1);
assertEquals("wrong version", maxver, pageinfo.getVersion());
// +2 comes from \r\n.
assertEquals("wrong text", maxver + 2, engine.getText(NAME1).length());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class StressTestVersioningProvider method runMassiveFileTest.
private void runMassiveFileTest(int maxpages) throws Exception {
String text = "Testing, 1, 2, 3: ";
String name = NAME1;
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();
Collection<WikiPage> pages = engine.getPageManager().getAllPages();
mark.stop();
System.out.println("Got a list of all pages in " + mark);
mark.reset();
mark.start();
for (WikiPage page : pages) {
String foo = engine.getPureText(page);
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.WikiPage in project jspwiki by apache.
the class CommandResolverTest method testFindWikiActionWithParams.
@Test
public void testFindWikiActionWithParams() throws Exception {
Command a;
WikiPage page = m_engine.getPage("SinglePage");
// Passing an EDIT request with page param yields a wrapped action
MockHttpServletRequest request = m_engine.newHttpRequest("/Edit.jsp?page=SinglePage");
request.getParameterMap().put("page", new String[] { "SinglePage" });
a = resolver.findCommand(request, WikiContext.EDIT);
Assert.assertNotSame(PageCommand.EDIT, a);
Assert.assertEquals("EditContent.jsp", a.getContentTemplate());
Assert.assertEquals("Edit.jsp", a.getJSP());
Assert.assertEquals("%uEdit.jsp?page=%n", a.getURLPattern());
Assert.assertEquals(page, a.getTarget());
// Passing an EDIT request with page=Search yields FIND action, *not* edit
request.setContextPath("/Edit.jsp?page=Search");
request.getParameterMap().put("page", new String[] { "Search" });
a = resolver.findCommand(request, WikiContext.EDIT);
Assert.assertEquals(WikiCommand.FIND, a);
Assert.assertEquals("FindContent.jsp", a.getContentTemplate());
Assert.assertEquals("Search.jsp", a.getJSP());
Assert.assertEquals("%uSearch.jsp", a.getURLPattern());
Assert.assertNull(a.getTarget());
// Passing an EDIT request with group="Foo" yields wrapped VIEW_GROUP
request = m_engine.newHttpRequest("/Group.jsp?group=Foo");
request.getParameterMap().put("group", new String[] { "Foo" });
a = resolver.findCommand(request, WikiContext.EDIT);
Assert.assertNotSame(GroupCommand.VIEW_GROUP, a);
Assert.assertEquals("GroupContent.jsp", a.getContentTemplate());
Assert.assertEquals("Group.jsp", a.getJSP());
Assert.assertEquals("%uGroup.jsp?group=%n", a.getURLPattern());
Assert.assertEquals(new GroupPrincipal("Foo"), a.getTarget());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class FilterBeanTest method testDoGet.
@Test
public void testDoGet() throws WikiException, NotCompliantMBeanException {
testEngine = new TestEngine(props);
WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage01"));
FilterBean pb = new FilterBean(testEngine);
String expectedHtml = "<div>" + "<h4>Filters</h4>" + "<table border=\"1\">" + "<tr><th>Name</th><th>Author</th><th>Notes</th></tr>" + "<tr><td>org.apache.wiki.filters.SpamFilter</td><td>Janne Jalkanen</td><td></td></tr>" + "</table>" + "</div>";
Assert.assertEquals(expectedHtml, pb.doGet(context));
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VerySimpleProvider method getPageInfo.
/**
* Returns always a valid WikiPage.
*/
public WikiPage getPageInfo(String page, int version) {
m_latestReq = page;
m_latestVers = version;
WikiPage p = new WikiPage(m_engine, page);
p.setVersion(5);
p.setAuthor(AUTHOR);
p.setLastModified(new Date(0L));
return p;
}
Aggregations