use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class PageRenamerTest method testReferrerChangeMultilink.
@Test
public void testReferrerChangeMultilink() throws Exception {
m_engine.saveText("TestPage", "foofoo");
m_engine.saveText("TestPage2", "[TestPage] [TestPage] [linktext|TestPage] TestPage [linktext|TestPage] [TestPage#Anchor] [TestPage] TestPage [TestPage]");
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "TestPage", "FooTest", true);
String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assert.assertEquals("no rename", "[FooTest] [FooTest] [linktext|FooTest] FooTest [linktext|FooTest] [FooTest#Anchor] [FooTest] FooTest [FooTest]", data.trim());
Collection<String> refs = m_engine.getReferenceManager().findReferrers("TestPage");
Assert.assertNull("oldpage", refs);
refs = m_engine.getReferenceManager().findReferrers("FooTest");
Assert.assertEquals("new size", 1, refs.size());
Assert.assertEquals("wrong ref", "TestPage2", (String) refs.iterator().next());
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class ContextualDiffProviderTest method diffTest.
// FIXME: This test Assert.fails; must be enabled again asap.
/*
@Test
public void testKnownProblemCases() throws NoRequiredPropertyException, IOException
{
//These all Assert.fail...
//make two consequtive changes
diffTest(null, "A B C D", "A b c D", "A |^b c^-B C-| D");
//acually returns -> "A |^b^-B-| |^c^-C-| D"
//collapse adjacent elements...
diffTest(null, "A B C D", "A BC D", "A |^BC^-B C-| D");
//acually returns -> "A |^BC^-B-| |-C -|D"
//These Assert.failures are all due to how we process the diff results, we need to collapse
//adjacent edits into one...
}
*/
private void diffTest(String contextLimit, String oldText, String newText, String expectedDiff) throws IOException, WikiException {
ContextualDiffProvider diff = new ContextualDiffProvider();
specializedNotation(diff);
Properties props = TestEngine.getTestProperties();
if (null != contextLimit)
props.put(ContextualDiffProvider.PROP_UNCHANGED_CONTEXT_LIMIT, contextLimit);
diff.initialize(null, props);
PropertyConfigurator.configure(props);
TestEngine engine = new TestEngine(props);
WikiContext ctx = new WikiContext(engine, new WikiPage(engine, "Dummy"));
String actualDiff = diff.makeDiffHtml(ctx, oldText, newText);
Assert.assertEquals(expectedDiff, actualDiff);
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class TableOfContentsTest method getI18nHTML.
/**
* TableOfContents plugin produces some i18n text, so we enforce english locale in order to
* be able to compare properly to assertion texts.
*
* @param pagename name of the page.
* @return (english) contents corresponding to the given page name.
*/
String getI18nHTML(String pagename) {
WikiPage page = testEngine.getPage(pagename, WikiPageProvider.LATEST_VERSION);
WikiContext context = new WikiContext(testEngine, testEngine.newHttpRequest(), page);
context.setRequestContext(WikiContext.NONE);
return testEngine.getHTML(context, page);
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class UndefinedPagesPluginTest method setUp.
@Before
public void setUp() throws Exception {
CacheManager.getInstance().removeAllCaches();
testEngine = new TestEngine(props);
testEngine.saveText("TestPage", "Reference to [Foobar].");
testEngine.saveText("Foobar", "Reference to [Foobar 2], [Foobars]");
context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage"));
manager = new DefaultPluginManager(testEngine, props);
}
use of org.apache.wiki.WikiPage in project jspwiki by apache.
the class CachingProviderTest method testSneakyAdd.
@Test
public void testSneakyAdd() throws Exception {
Properties props = TestEngine.getTestProperties();
props.setProperty("jspwiki.cachingProvider.cacheCheckInterval", "2");
TestEngine engine = new TestEngine(props);
String dir = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
File f = new File(dir, "Testi.txt");
String content = "[fuufaa]";
PrintWriter out = new PrintWriter(new FileWriter(f));
FileUtil.copyContents(new StringReader(content), out);
out.close();
// Make sure we wait long enough
Thread.sleep(4000L);
WikiPage p = engine.getPage("Testi");
Assert.assertNotNull("page did not exist?", p);
String text = engine.getText("Testi");
Assert.assertEquals("text", "[fuufaa]", text);
// TODO: ReferenceManager check as well
}
Aggregations