use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class ReferringUndefinedPagesPluginTest method setUp.
@Before
public void setUp() throws Exception {
CacheManager.getInstance().removeAllCaches();
testEngine = new TestEngine(props);
testEngine.saveText("TestPage01", "Some Text for testing 01 which refers [NonExistingPageA] ");
testEngine.saveText("TestPage02", "Some Text for testing 02 which refers [NonExistingPageB] ");
testEngine.saveText("TestPage03", "Some Text for testing 03 which refers [NonExistingPageC] ");
context = new WikiContext(testEngine, testEngine.newHttpRequest(), new WikiPage(testEngine, "TestPage"));
manager = new DefaultPluginManager(testEngine, props);
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class PageRenamerTest method testReferrerChange.
@Test
public void testReferrerChange() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "[TestPage]");
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "TestPage", "FooTest", true);
String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assert.assertEquals("no rename", "[FooTest]", data.trim());
Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
Assert.assertNull("oldpage", refs);
refs = m_engine.getReferenceManager().findReferrers("FooTest");
Assert.assertEquals("new size", 1, refs.size());
Assert.assertEquals("wrong ref", "TestPage2", (String) refs.iterator().next());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class PageRenamerTest method testAttachmentChange.
@Test
public void testAttachmentChange() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "[TestPage/foo.txt] [linktext|TestPage/bar.jpg]");
m_engine.addAttachment("TestPage", "foo.txt", "testing".getBytes());
m_engine.addAttachment("TestPage", "bar.jpg", "pr0n".getBytes());
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "TestPage", "FooTest", true);
String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assert.assertEquals("no rename", "[FooTest/foo.txt] [linktext|FooTest/bar.jpg]", data.trim());
Attachment att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/foo.txt");
Assert.assertNotNull("footext", att);
att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/bar.jpg");
Assert.assertNotNull("barjpg", att);
att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/bar.jpg");
Assert.assertNull("testpage/bar.jpg exists", att);
att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/foo.txt");
Assert.assertNull("testpage/foo.txt exists", att);
Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage/bar.jpg");
Assert.assertNull("oldpage", refs);
refs = m_engine.getReferenceManager().findReferrers("FooTest/bar.jpg");
Assert.assertEquals("new size", 1, refs.size());
Assert.assertEquals("wrong ref", "TestPage2", (String) refs.iterator().next());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class PageRenamerTest method testReferrerChangeCC.
@Test
public void testReferrerChangeCC() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "TestPage");
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "TestPage", "FooTest", true);
String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assert.assertEquals("no rename", "FooTest", data.trim());
Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
Assert.assertNull("oldpage", refs);
refs = m_engine.getReferenceManager().findReferrers("FooTest");
Assert.assertEquals("new size", 1, refs.size());
Assert.assertEquals("wrong ref", "TestPage2", (String) refs.iterator().next());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class PageRenamerTest method rename.
private void rename(String src, String dst) throws WikiException {
WikiPage p = m_engine.getPage(src);
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, src, dst, true);
}
Aggregations