Search in sources :

Example 21 with WikiContext

use of org.apache.wiki.WikiContext in project jspwiki by apache.

the class JSPWikiMarkupParserTest method testCollectingLinks2.

@Test
public void testCollectingLinks2() throws Exception {
    LinkCollector coll = new LinkCollector();
    String src = "[" + PAGE_NAME + "/Test.txt]";
    WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, PAGE_NAME));
    MarkupParser p = new JSPWikiMarkupParser(context, new BufferedReader(new StringReader(src)));
    p.addLocalLinkHook(coll);
    p.addExternalLinkHook(coll);
    p.addAttachmentLinkHook(coll);
    p.parse();
    Collection<String> links = coll.getLinks();
    Assert.assertEquals("no links found", 1, links.size());
    Assert.assertEquals("wrong link", PAGE_NAME + "/Test.txt", links.iterator().next());
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) LinkCollector(org.apache.wiki.LinkCollector) Test(org.junit.Test)

Example 22 with WikiContext

use of org.apache.wiki.WikiContext in project jspwiki by apache.

the class JSPWikiMarkupParserTest method testCollectingLinks.

/**
 *  Test collection of links.
 */
@Test
public void testCollectingLinks() throws Exception {
    LinkCollector coll = new LinkCollector();
    String src = "[Test]";
    WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, PAGE_NAME));
    MarkupParser p = new JSPWikiMarkupParser(context, new BufferedReader(new StringReader(src)));
    p.addLocalLinkHook(coll);
    p.addExternalLinkHook(coll);
    p.addAttachmentLinkHook(coll);
    p.parse();
    Collection<String> links = coll.getLinks();
    Assert.assertEquals("no links found", 1, links.size());
    Assert.assertEquals("wrong link", "Test", links.iterator().next());
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) LinkCollector(org.apache.wiki.LinkCollector) Test(org.junit.Test)

Example 23 with WikiContext

use of org.apache.wiki.WikiContext in project jspwiki by apache.

the class DefaultPluginManagerTest method setUp.

@Before
public void setUp() throws Exception {
    engine = new TestEngine(props);
    context = new WikiContext(engine, new WikiPage(engine, "Testpage"));
    manager = new DefaultPluginManager(engine, props);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) Before(org.junit.Before)

Example 24 with WikiContext

use of org.apache.wiki.WikiContext in project jspwiki by apache.

the class UndefinedPagesPluginTest method testSimpleUndefined.

/**
 *  Tests that only correct undefined links are found.
 *  We also check against plural forms here, which should not
 *  be listed as non-existent.
 */
@Test
public void testSimpleUndefined() throws Exception {
    WikiContext context2 = new WikiContext(testEngine, new WikiPage(testEngine, "Foobar"));
    String res = manager.execute(context2, "{INSERT org.apache.wiki.plugin.UndefinedPagesPlugin");
    String exp = "[Foobar 2]\\\\";
    Assert.assertEquals(wikitize(exp), res);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) Test(org.junit.Test)

Example 25 with WikiContext

use of org.apache.wiki.WikiContext 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)

Aggregations

WikiContext (org.apache.wiki.WikiContext)90 WikiPage (org.apache.wiki.WikiPage)63 Test (org.junit.Test)40 TestEngine (org.apache.wiki.TestEngine)11 StringReader (java.io.StringReader)9 WikiEngine (org.apache.wiki.WikiEngine)9 ProviderException (org.apache.wiki.api.exceptions.ProviderException)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7 Before (org.junit.Before)7 BufferedReader (java.io.BufferedReader)6 StringWriter (java.io.StringWriter)6 Collection (java.util.Collection)6 InputStreamReader (java.io.InputStreamReader)5 Date (java.util.Date)5 LinkCollector (org.apache.wiki.LinkCollector)5 Attachment (org.apache.wiki.attachment.Attachment)5 Properties (java.util.Properties)4 MockHttpServletRequest (net.sourceforge.stripes.mock.MockHttpServletRequest)4 WikiDocument (org.apache.wiki.parser.WikiDocument)4