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));
}
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);
}
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);
}
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);
}
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());
}
Aggregations