use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VersioningFileProviderTest method testMigrationInfoAvailable.
/*
* Checks if a page created or last modified by FileSystemProvider
* will be seen by VersioningFileProvider as the "first" version.
*/
@Test
public void testMigrationInfoAvailable() throws IOException {
// we cannot switch PageProviders within a single test, so the
// initial FileSystemProvider wiki page must be faked.
final String fakeWikiPage = "foobar";
injectFile(NAME1 + AbstractFileProvider.FILE_EXT, fakeWikiPage);
// also create an associated properties file with some history
injectFile(NAME1 + FileSystemProvider.PROP_EXT, FAKE_HISTORY);
String res = engine.getText(NAME1);
Assert.assertEquals("fetch latest should work", fakeWikiPage, res);
WikiPage page = engine.getPage(NAME1, 1);
Assert.assertEquals("original version expected", 1, page.getVersion());
Assert.assertEquals("original author", OLD_AUTHOR, page.getAuthor());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersionUTF8.
/**
* 2.0.7 and before got this wrong.
*/
@Test
public void testGetOldVersionUTF8() throws Exception {
String text = "\u00e5\u00e4\u00f6\r\n";
String text2 = "barbar\u00f6\u00f6\r\n";
String text3 = "Barney\u00e4\u00e4\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
WikiPage res = engine.getPage(NAME1);
Assert.assertEquals("wrong version", 3, res.getVersion());
Assert.assertEquals("ver1", text, engine.getText(NAME1, 1));
Assert.assertEquals("ver2", text2, engine.getText(NAME1, 2));
Assert.assertEquals("ver3", text3, engine.getText(NAME1, 3));
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersion.
@Test
public void testGetOldVersion() throws Exception {
String text = "diddo\r\n";
String text2 = "barbar\r\n";
String text3 = "Barney\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
WikiPage res = engine.getPage(NAME1);
Assert.assertEquals("wrong version", 3, res.getVersion());
Assert.assertEquals("ver1", text, engine.getText(NAME1, 1));
Assert.assertEquals("ver2", text2, engine.getText(NAME1, 2));
Assert.assertEquals("ver3", text3, engine.getText(NAME1, 3));
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VersioningFileProviderTest method testMigrationChangesHistory.
/*
* Checks if migration from FileSystemProvider to VersioningFileProvider
* works when a simple text file and its associated properties exist, but
* when there is not yet any corresponding history content in OLD/.
* Update the wiki page and confirm the original simple history was
* assimilated into the newly-created properties.
*/
@Test
public void testMigrationChangesHistory() throws Exception {
// we cannot switch PageProviders within a single test, so the
// initial FileSystemProvider wiki page must be faked.
final String fakeWikiPage = "foobar";
injectFile(NAME1 + AbstractFileProvider.FILE_EXT, fakeWikiPage);
// also create an associated properties file with some history
injectFile(NAME1 + FileSystemProvider.PROP_EXT, FAKE_HISTORY);
String result1 = engine.getText(NAME1);
Assert.assertEquals("latest should be initial", fakeWikiPage, result1);
// now update the wiki page to create a new version
final String text = "diddo\r\n";
engine.saveText(NAME1, text);
// confirm the right number of versions have been recorded
Collection versionHistory = engine.getVersionHistory(NAME1);
Assert.assertEquals("number of versions", 2, versionHistory.size());
// fetch the updated page
String result2 = engine.getText(NAME1);
Assert.assertEquals("latest should be new version", text, result2);
// Should be the 2nd version.
String result3 = engine.getText(NAME1, 2);
Assert.assertEquals("fetch new by version did not work", text, result3);
// now confirm the original page has been archived
String result4 = engine.getText(NAME1, 1);
Assert.assertEquals("fetch original by version Assert.failed", fakeWikiPage, result4);
WikiPage pageNew = engine.getPage(NAME1, 2);
Assert.assertEquals("new version", 2, pageNew.getVersion());
Assert.assertEquals("new author", "Guest", pageNew.getAuthor());
WikiPage pageOld = engine.getPage(NAME1, 1);
Assert.assertEquals("old version", 1, pageOld.getVersion());
Assert.assertEquals("old author", OLD_AUTHOR, pageOld.getAuthor());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class VersioningFileProviderTest method testGetOldVersion2.
@Test
public void testGetOldVersion2() throws Exception {
String text = "diddo\r\n";
String text2 = "barbar\r\n";
String text3 = "Barney\r\n";
engine.saveText(NAME1, text);
engine.saveText(NAME1, text2);
engine.saveText(NAME1, text3);
WikiPage res = engine.getPage(NAME1);
Assert.assertEquals("wrong version", 3, res.getVersion());
Assert.assertEquals("ver1", 1, engine.getPage(NAME1, 1).getVersion());
Assert.assertEquals("ver2", 2, engine.getPage(NAME1, 2).getVersion());
Assert.assertEquals("ver3", 3, engine.getPage(NAME1, 3).getVersion());
}
Aggregations