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);
}
}
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());
}
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");
}
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) {
}
}
}
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");
}
Aggregations