use of org.apache.wiki.WikiContext 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.WikiContext 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.WikiContext 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.WikiContext in project jspwiki by apache.
the class VersioningFileProviderTest method testChangeNote.
@Test
public void testChangeNote() throws Exception {
WikiPage p = new WikiPage(engine, NAME1);
p.setAttribute(WikiPage.CHANGENOTE, "Test change");
WikiContext context = new WikiContext(engine, p);
engine.saveText(context, "test");
WikiPage p2 = engine.getPage(NAME1);
Assert.assertEquals("Test change", p2.getAttribute(WikiPage.CHANGENOTE));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class VersioningFileProviderTest method testChangeNoteOldVersion.
@Test
public void testChangeNoteOldVersion() throws Exception {
WikiPage p = new WikiPage(engine, NAME1);
WikiContext context = new WikiContext(engine, p);
context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change");
engine.saveText(context, "test");
context.getPage().setAttribute(WikiPage.CHANGENOTE, "Change 2");
engine.saveText(context, "test2");
WikiPage p2 = engine.getPage(NAME1, 1);
Assert.assertEquals("Test change", p2.getAttribute(WikiPage.CHANGENOTE));
WikiPage p3 = engine.getPage(NAME1, 2);
Assert.assertEquals("Change 2", p3.getAttribute(WikiPage.CHANGENOTE));
}
Aggregations