Search in sources :

Example 61 with WikiContext

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

the class RecentChangesPluginTest method testNoRecentChanges.

/**
 * Test an empty recent changes table
 *
 * @throws Exception
 */
@Test
public void testNoRecentChanges() throws Exception {
    context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage04"));
    String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin since='-1'}");
    Assert.assertTrue("<table class=\"recentchanges\" cellpadding=\"4\"></table>".equals(res));
    Assert.assertFalse("<table class=\"recentchanges\" cellpadding=\"4\" />".equals(res));
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) Test(org.junit.Test)

Example 62 with WikiContext

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

the class ReferringPagesPluginTest method setUp.

@Before
public void setUp() throws Exception {
    props.setProperty("jspwiki.breakTitleWithSpaces", "false");
    engine = new TestEngine(props);
    engine.saveText("TestPage", "Reference to [Foobar].");
    engine.saveText("Foobar", "Reference to [TestPage].");
    engine.saveText("Foobar2", "Reference to [TestPage].");
    engine.saveText("Foobar3", "Reference to [TestPage].");
    engine.saveText("Foobar4", "Reference to [TestPage].");
    engine.saveText("Foobar5", "Reference to [TestPage].");
    engine.saveText("Foobar6", "Reference to [TestPage].");
    engine.saveText("Foobar7", "Reference to [TestPage].");
    context = new WikiContext(engine, engine.newHttpRequest(), 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 63 with WikiContext

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

the class ReferringPagesPluginTest method testReferenceWidth.

@Test
public void testReferenceWidth() throws Exception {
    WikiContext context2 = new WikiContext(engine, new WikiPage(engine, "Foobar"));
    String res = manager.execute(context2, "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE maxwidth=5}");
    Assert.assertEquals(mkFullLink("TestP...", "TestPage") + "<br />", res);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) Test(org.junit.Test)

Example 64 with WikiContext

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

the class RPCHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    CacheManager.getInstance().removeAllCaches();
    m_engine = new TestEngine(m_props);
    m_handler = new RPCHandler();
    WikiContext ctx = new WikiContext(m_engine, new WikiPage(m_engine, "Dummy"));
    m_handler.initialize(ctx);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) Before(org.junit.Before)

Example 65 with WikiContext

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

the class AttachmentManagerTest method testSimpleStoreByVersion.

@Test
public void testSimpleStoreByVersion() throws Exception {
    Attachment att = new Attachment(m_engine, NAME1, "test1.txt");
    att.setAuthor("FirstPost");
    m_manager.storeAttachment(att, makeAttachmentFile());
    Attachment att2 = m_manager.getAttachmentInfo(new WikiContext(m_engine, new WikiPage(m_engine, NAME1)), "test1.txt", 1);
    Assert.assertNotNull("attachment disappeared", att2);
    Assert.assertEquals("version", 1, att2.getVersion());
    Assert.assertEquals("name", att.getName(), att2.getName());
    Assert.assertEquals("author", att.getAuthor(), att2.getAuthor());
    Assert.assertEquals("size", c_fileContents.length(), att2.getSize());
    InputStream in = m_manager.getAttachmentStream(att2);
    Assert.assertNotNull("stream", in);
    StringWriter sout = new StringWriter();
    FileUtil.copyContents(new InputStreamReader(in), sout);
    in.close();
    sout.close();
    Assert.assertEquals("contents", c_fileContents, sout.toString());
}
Also used : WikiContext(org.apache.wiki.WikiContext) StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) WikiPage(org.apache.wiki.WikiPage) 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