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