Search in sources :

Example 91 with WikiPage

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

the class CounterProvider method initialize.

public void initialize(WikiEngine engine, Properties props) {
    m_pages = new WikiPage[] { new WikiPage(engine, "Foo"), new WikiPage(engine, "Bar"), new WikiPage(engine, "Blat"), new WikiPage(engine, "Blaa") };
    m_initCalls++;
    for (int i = 0; i < m_pages.length; i++) {
        m_pages[i].setAuthor("Unknown");
        m_pages[i].setLastModified(new Date(0L));
        m_pages[i].setVersion(1);
    }
}
Also used : WikiPage(org.apache.wiki.WikiPage) Date(java.util.Date)

Example 92 with WikiPage

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

the class FileSystemProviderTest method testDelete.

@Test
public void testDelete() throws Exception {
    String files = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
    WikiPage p = new WikiPage(m_engine, "Test");
    p.setAuthor("AnonymousCoward");
    m_provider.putPageText(p, "v1");
    File f = new File(files, "Test" + FileSystemProvider.FILE_EXT);
    Assert.assertTrue("file does not exist", f.exists());
    f = new File(files, "Test.properties");
    Assert.assertTrue("property file does not exist", f.exists());
    m_provider.deletePage("Test");
    f = new File(files, "Test" + FileSystemProvider.FILE_EXT);
    Assert.assertFalse("file exists", f.exists());
    f = new File(files, "Test.properties");
    Assert.assertFalse("properties exist", f.exists());
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) Test(org.junit.Test)

Example 93 with WikiPage

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

the class FileSystemProviderTest method testScandinavianLettersUTF8.

@Test
public void testScandinavianLettersUTF8() throws Exception {
    WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
    m_providerUTF8.putPageText(page, "test\u00d6");
    File resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "%C3%85%C3%A4Test.txt");
    Assert.assertTrue("No such file", resultfile.exists());
    String contents = FileUtil.readContents(new FileInputStream(resultfile), "UTF-8");
    Assert.assertEquals("Wrong contents", contents, "test\u00d6");
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 94 with WikiPage

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

the class FileSystemProviderTest method testAuthor.

@Test
public void testAuthor() throws Exception {
    try {
        WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
        page.setAuthor("Min\u00e4");
        m_provider.putPageText(page, "test");
        WikiPage page2 = m_provider.getPageInfo("\u00c5\u00e4Test", 1);
        Assert.assertEquals("Min\u00e4", page2.getAuthor());
    } finally {
        File resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "%C5%E4Test.txt");
        try {
            resultfile.delete();
        } catch (Exception e) {
        }
        resultfile = new File(props.getProperty(FileSystemProvider.PROP_PAGEDIR), "%C5%E4Test.properties");
        try {
            resultfile.delete();
        } catch (Exception e) {
        }
    }
}
Also used : WikiPage(org.apache.wiki.WikiPage) File(java.io.File) IOException(java.io.IOException) Test(org.junit.Test)

Example 95 with WikiPage

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

the class FileSystemProviderTest method testSlashesInPageNames.

@Test
public void testSlashesInPageNames() throws Exception {
    WikiPage page = new WikiPage(m_engine, "Test/Foobar");
    m_provider.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), "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