Search in sources :

Example 71 with Page

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

the class JSPWikiMarkupParserTest method testSet3.

@Test
public void testSet3() throws Exception {
    final String src = "Foobar.[{SET name= Janne Jalkanen}]";
    final Page p = Wiki.contents().page(testEngine, PAGE_NAME);
    final String res = translate(p, src);
    Assertions.assertEquals("Foobar.", res, "Page text");
    Assertions.assertEquals("Janne Jalkanen", p.getAttribute("name"));
}
Also used : Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 72 with Page

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

the class JSPWikiMarkupParserTest method testSet1.

/**
 * Metadata tests
 */
@Test
public void testSet1() throws Exception {
    final String src = "Foobar.[{SET name=foo}]";
    final Page p = Wiki.contents().page(testEngine, PAGE_NAME);
    final String res = translate(p, src);
    Assertions.assertEquals("Foobar.", res, "Page text");
    Assertions.assertEquals("foo", p.getAttribute("name"));
}
Also used : Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 73 with Page

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

the class JSPWikiMarkupParserTest method testHTMLWhenAllowed.

@Test
public void testHTMLWhenAllowed() throws Exception {
    final String src = "<p>";
    testEngine = TestEngine.build(with("jspwiki.translatorReader.allowHTML", "true"));
    final Page page = Wiki.contents().page(testEngine, PAGE_NAME);
    final String out = translate(testEngine, page, src);
    Assertions.assertEquals("<p>", out);
}
Also used : Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 74 with Page

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

the class JSPWikiMarkupParserTest method testSetHTML.

@Test
public void testSetHTML() throws Exception {
    final String src = "Foobar.[{SET name='<b>danger</b>'}] [{$name}]";
    final Page p = Wiki.contents().page(testEngine, PAGE_NAME);
    final String res = translate(p, src);
    Assertions.assertEquals("Foobar. &lt;b&gt;danger&lt;/b&gt;", res, "Page text");
    Assertions.assertEquals("<b>danger</b>", p.getAttribute("name"));
}
Also used : Page(org.apache.wiki.api.core.Page) Test(org.junit.jupiter.api.Test)

Example 75 with Page

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

the class IfPluginTest method testIfPluginIPNotAllowed.

/**
 * Checks that IP address is granted.
 *
 * @throws WikiException test Assertions.failing.
 */
@Test
public void testIfPluginIPNotAllowed() throws WikiException {
    final String src = "[{IfPlugin ip='!127.0.0.1'\n\nContent NOT visible for 127.0.0.1}]";
    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)

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