Search in sources :

Example 61 with WikiPage

use of org.apache.wiki.WikiPage in project jspwiki by apache.

the class CounterProvider method getPageInfo.

public WikiPage getPageInfo(String page, int version) {
    m_getPageCalls++;
    // System.out.println("GETPAGEINFO="+page);
    // TestEngine.trace();
    WikiPage p = findPage(page);
    return p;
}
Also used : WikiPage(org.apache.wiki.WikiPage)

Example 62 with WikiPage

use of org.apache.wiki.WikiPage in project jspwiki by apache.

the class FileSystemProviderTest method testSlashesInPageNamesUTF8.

/**
 * This should never happen, but let's check that we're protected anyway.
 * @throws Exception
 */
@Test
public void testSlashesInPageNamesUTF8() throws Exception {
    WikiPage page = new WikiPage(m_engine, "Test/Foobar");
    m_providerUTF8.putPageText(page, "test");
    File resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "Test%2FFoobar.txt");
    Assert.assertTrue("No such file", resultfile.exists());
    String contents = FileUtil.readContents(new FileInputStream(resultfile), "UTF-8");
    Assert.assertEquals("Wrong contents", contents, "test");
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 63 with WikiPage

use of org.apache.wiki.WikiPage in project jspwiki by apache.

the class FileSystemProviderTest method testCustomProperties.

@Test
public void testCustomProperties() throws Exception {
    String pageDir = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
    String pageName = "CustomPropertiesTest";
    String fileName = pageName + FileSystemProvider.FILE_EXT;
    File file = new File(pageDir, fileName);
    Assert.assertFalse(file.exists());
    WikiPage testPage = new WikiPage(m_engine, pageName);
    testPage.setAuthor("TestAuthor");
    testPage.setAttribute("@test", "Save Me");
    testPage.setAttribute("@test2", "Save You");
    testPage.setAttribute("test3", "Do not save");
    m_provider.putPageText(testPage, "This page has custom properties");
    Assert.assertTrue("No such file", file.exists());
    WikiPage pageRetrieved = m_provider.getPageInfo(pageName, -1);
    String value = (String) pageRetrieved.getAttribute("@test");
    String value2 = (String) pageRetrieved.getAttribute("@test2");
    String value3 = (String) pageRetrieved.getAttribute("test3");
    Assert.assertNotNull(value);
    Assert.assertNotNull(value2);
    Assert.assertNull(value3);
    Assert.assertEquals("Save Me", value);
    Assert.assertEquals("Save You", value2);
    file.delete();
    Assert.assertFalse(file.exists());
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) Test(org.junit.Test)

Example 64 with WikiPage

use of org.apache.wiki.WikiPage in project jspwiki by apache.

the class FileSystemProviderTest method testDotsInBeginning.

@Test
public void testDotsInBeginning() throws Exception {
    WikiPage page = new WikiPage(m_engine, ".Test");
    m_provider.putPageText(page, "test");
    File resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "%2ETest.txt");
    Assert.assertTrue("No such file", resultfile.exists());
    String contents = FileUtil.readContents(new FileInputStream(resultfile), "ISO-8859-1");
    Assert.assertEquals("Wrong contents", contents, "test");
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 65 with WikiPage

use of org.apache.wiki.WikiPage in project jspwiki by apache.

the class FileSystemProviderTest method testScandinavianLetters.

@Test
public void testScandinavianLetters() throws Exception {
    WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
    m_provider.putPageText(page, "test");
    File resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "%C5%E4Test.txt");
    Assert.assertTrue("No such file", resultfile.exists());
    String contents = FileUtil.readContents(new FileInputStream(resultfile), "ISO-8859-1");
    Assert.assertEquals("Wrong contents", contents, "test");
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

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