Search in sources :

Example 76 with Page

use of org.apache.wiki.api.core.Page in project jspwiki by apache.

the class IfPluginTest method testIfPluginUserNotAllowed.

/**
 * Checks that user access is forbidden.
 *
 * @throws WikiException test Assertions.failing.
 */
@Test
public void testIfPluginUserNotAllowed() throws WikiException {
    final String src = "[{IfPlugin user='!Janne Jalkanen'\n\nContent NOT visible for Janne Jalkanen}]";
    final String expected = "\n";
    testEngine.saveText("Test", src);
    final Page page = testEngine.getManager(PageManager.class).getPage("Test", PageProvider.LATEST_VERSION);
    final Context context = getJanneBasedWikiContextFor(page);
    final String res = testEngine.getManager(RenderingManager.class).getHTML(context, page);
    Assertions.assertEquals(expected, res);
}
Also used : Context(org.apache.wiki.api.core.Context) WikiContext(org.apache.wiki.WikiContext) PageManager(org.apache.wiki.pages.PageManager) RenderingManager(org.apache.wiki.render.RenderingManager) Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 77 with Page

use of org.apache.wiki.api.core.Page 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");
    final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
    final Context context = Wiki.context().create(m_engine, p);
    m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
    final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
    Assertions.assertEquals("FooTest", data.trim(), "no rename");
    Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage");
    Assertions.assertNull(refs, "oldpage");
    refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooTest");
    Assertions.assertEquals(1, refs.size(), "new size");
    Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) ReferenceManager(org.apache.wiki.references.ReferenceManager) Test(org.junit.jupiter.api.Test)

Example 78 with Page

use of org.apache.wiki.api.core.Page in project jspwiki by apache.

the class PageRenamerTest method testReferrerChangeMultilink.

@Test
public void testReferrerChangeMultilink() throws Exception {
    m_engine.saveText("TestPage", "foofoo");
    m_engine.saveText("TestPage2", "[TestPage] [TestPage] [linktext|TestPage] TestPage [linktext|TestPage] [TestPage#Anchor] [TestPage] TestPage [TestPage]");
    final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
    final Context context = Wiki.context().create(m_engine, p);
    m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
    final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
    Assertions.assertEquals("[FooTest] [FooTest] [linktext|FooTest] FooTest [linktext|FooTest] [FooTest#Anchor] [FooTest] FooTest [FooTest]", data.trim(), "no rename");
    Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage");
    Assertions.assertNull(refs, "oldpage");
    refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooTest");
    Assertions.assertEquals(1, refs.size(), "new size");
    Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) ReferenceManager(org.apache.wiki.references.ReferenceManager) Test(org.junit.jupiter.api.Test)

Example 79 with Page

use of org.apache.wiki.api.core.Page 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());
    final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
    final Context context = Wiki.context().create(m_engine, p);
    m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
    final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
    Assertions.assertEquals("[FooTest/foo.txt] [linktext|FooTest/bar.jpg]", data.trim(), "no rename");
    Attachment att = m_engine.getManager(AttachmentManager.class).getAttachmentInfo("FooTest/foo.txt");
    Assertions.assertNotNull(att, "footext");
    att = m_engine.getManager(AttachmentManager.class).getAttachmentInfo("FooTest/bar.jpg");
    Assertions.assertNotNull(att, "barjpg");
    att = m_engine.getManager(AttachmentManager.class).getAttachmentInfo("TestPage/bar.jpg");
    Assertions.assertNull(att, "testpage/bar.jpg exists");
    att = m_engine.getManager(AttachmentManager.class).getAttachmentInfo("TestPage/foo.txt");
    Assertions.assertNull(att, "testpage/foo.txt exists");
    Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage/bar.jpg");
    Assertions.assertNull(refs, "oldpage");
    refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooTest/bar.jpg");
    Assertions.assertEquals(1, refs.size(), "new size");
    Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) Attachment(org.apache.wiki.api.core.Attachment) AttachmentManager(org.apache.wiki.attachment.AttachmentManager) ReferenceManager(org.apache.wiki.references.ReferenceManager) Test(org.junit.jupiter.api.Test)

Example 80 with Page

use of org.apache.wiki.api.core.Page 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]");
    final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
    final Context context = Wiki.context().create(m_engine, p);
    m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", true);
    final String data = m_engine.getManager(PageManager.class).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
    Assertions.assertEquals("[FooTest]", data.trim(), "no rename");
    Collection<String> refs = m_engine.getManager(ReferenceManager.class).findReferrers("TestPage");
    Assertions.assertNull(refs, "oldpage");
    refs = m_engine.getManager(ReferenceManager.class).findReferrers("FooTest");
    Assertions.assertEquals(1, refs.size(), "new size");
    Assertions.assertEquals("TestPage2", refs.iterator().next(), "wrong ref");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) ReferenceManager(org.apache.wiki.references.ReferenceManager) Test(org.junit.jupiter.api.Test)

Aggregations

Page (org.apache.wiki.api.core.Page)181 PageManager (org.apache.wiki.pages.PageManager)106 Test (org.junit.jupiter.api.Test)71 Context (org.apache.wiki.api.core.Context)46 Engine (org.apache.wiki.api.core.Engine)30 Attachment (org.apache.wiki.api.core.Attachment)27 ProviderException (org.apache.wiki.api.exceptions.ProviderException)22 Date (java.util.Date)21 WikiPage (org.apache.wiki.WikiPage)18 ReferenceManager (org.apache.wiki.references.ReferenceManager)16 RenderingManager (org.apache.wiki.render.RenderingManager)15 AttachmentManager (org.apache.wiki.attachment.AttachmentManager)14 File (java.io.File)11 ArrayList (java.util.ArrayList)10 Calendar (java.util.Calendar)10 Hashtable (java.util.Hashtable)10 IOException (java.io.IOException)9 Vector (java.util.Vector)9 TestEngine (org.apache.wiki.TestEngine)9 PagePermission (org.apache.wiki.auth.permissions.PagePermission)8