Search in sources :

Example 81 with WikiPage

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

Example 82 with WikiPage

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

Example 83 with WikiPage

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

Example 84 with WikiPage

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

Example 85 with WikiPage

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

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