Search in sources :

Example 71 with WikiPage

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());
}
Also used : WikiPage(org.apache.wiki.WikiPage)

Example 72 with WikiPage

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");
}
Also used : WikiPage(org.apache.wiki.WikiPage)

Example 73 with WikiPage

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());
}
Also used : GroupPrincipal(org.apache.wiki.auth.GroupPrincipal) MockHttpServletRequest(net.sourceforge.stripes.mock.MockHttpServletRequest) WikiPage(org.apache.wiki.WikiPage) Test(org.junit.Test)

Example 74 with WikiPage

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));
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) Test(org.junit.Test)

Example 75 with WikiPage

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;
}
Also used : WikiPage(org.apache.wiki.WikiPage) Date(java.util.Date)

Aggregations

WikiPage (org.apache.wiki.WikiPage)186 Test (org.junit.Test)77 WikiContext (org.apache.wiki.WikiContext)63 WikiEngine (org.apache.wiki.WikiEngine)29 Attachment (org.apache.wiki.attachment.Attachment)26 ProviderException (org.apache.wiki.api.exceptions.ProviderException)22 Date (java.util.Date)17 File (java.io.File)16 Collection (java.util.Collection)16 TestEngine (org.apache.wiki.TestEngine)15 Iterator (java.util.Iterator)13 StringReader (java.io.StringReader)9 Hashtable (java.util.Hashtable)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 Calendar (java.util.Calendar)8 Vector (java.util.Vector)8 StringWriter (java.io.StringWriter)7 InternalWikiException (org.apache.wiki.InternalWikiException)7 PagePermission (org.apache.wiki.auth.permissions.PagePermission)7