use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class SaveWikiPageTaskTest method testSaveWikiPageTaskWithVersioningFileProvider.
@Test
public void testSaveWikiPageTaskWithVersioningFileProvider() throws Exception {
final TestEngine engine = TestEngine.build(with("jspwiki.pageProvider", "VersioningFileProvider"), with("jspwiki.lucene.initialdelay", "0"), with("jspwiki.lucene.indexdelay", "1"));
final String pageName = "TestSaveWikiPageTestPageWithVersioningFileProvider";
final Page page = Wiki.contents().page(engine, pageName);
engine.saveText(pageName, "initial text on first revision");
final Context context = Wiki.context().create(engine, engine.newHttpRequest(), page);
final SaveWikiPageTask task = new SaveWikiPageTask();
task.setWorkflow(1, new HashMap<>());
task.getWorkflowContext().put(WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, "It is based on ties of history, culture, language, ethnicity, kinship and geography");
final Collection<SearchResult> res = new ArrayList<>();
Assertions.assertEquals(Outcome.STEP_COMPLETE, task.execute(context));
Awaitility.await("ensure latest version of page gets indexed").until(findsResultsFor(context, res, "kinship"));
Assertions.assertEquals(1, res.size(), "no pages found");
Assertions.assertEquals(pageName, res.iterator().next().getPage().getName(), "page");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class FilterBeanTest method testDoGet.
@Test
public void testDoGet() throws WikiException, NotCompliantMBeanException {
final Context context = Wiki.context().create(testEngine, Wiki.contents().page(testEngine, "TestPage01"));
final FilterBean pb = new FilterBean(testEngine);
final String expectedHtml = "<div>" + "<h4>Filters</h4>" + "<table border=\"1\">" + "<tr><th>Name</th><th>Author</th><th>Notes</th></tr>" + "<tr><td>org.apache.wiki.filters.SpamFilter</td><td>Janne Jalkanen</td><td></td></tr>" + "</table>" + "</div>";
Assertions.assertEquals(expectedHtml, pb.doGet(context));
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class ApprovalWorkflowTest method testSaveWikiPageWithApproval.
@Test
public void testSaveWikiPageWithApproval() throws WikiException {
// Create a sample test page and try to save it
final String pageName = "SaveWikiPageWorkflow-Test" + System.currentTimeMillis();
final String text = "This is a test!";
// Expected exception...
Assertions.assertThrows(DecisionRequiredException.class, () -> m_engine.saveTextAsJanne(pageName, text));
// How do we know the workflow works? Well, first of all the page shouldn't exist yet...
Assertions.assertFalse(m_engine.getManager(PageManager.class).wikiPageExists(pageName));
// Second, GroupPrincipal Admin should see a Decision in its queue
Collection<Decision> decisions = m_dq.getActorDecisions(m_engine.adminSession());
Assertions.assertEquals(1, decisions.size());
// Now, approve the decision and it should go away, and page should appear.
final Context context = Wiki.context().create(m_engine, Wiki.contents().page(m_engine, pageName));
final Decision decision = decisions.iterator().next();
decision.decide(Outcome.DECISION_APPROVE, context);
Assertions.assertTrue(m_engine.getManager(PageManager.class).wikiPageExists(pageName));
decisions = m_dq.getActorDecisions(m_engine.adminSession());
Assertions.assertEquals(0, decisions.size());
// Delete the page we created
m_engine.getManager(PageManager.class).deletePage(pageName);
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class UndefinedPagesPluginTest method testSimpleUndefined.
/**
* Tests that only correct undefined links are found.
* We also check against plural forms here, which should not
* be listed as non-existent.
*/
@Test
public void testSimpleUndefined() throws Exception {
final Context context2 = Wiki.context().create(testEngine, Wiki.contents().page(testEngine, "Foobar"));
final String res = manager.execute(context2, "{INSERT org.apache.wiki.plugin.UndefinedPagesPlugin");
final String exp = "[Foobar 2]\\\\";
Assertions.assertEquals(wikitize(exp), res);
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class UndefinedPagesPluginTest method testUndefinedWithColumns.
@Test
public void testUndefinedWithColumns() throws Exception {
final Context context2 = Wiki.context().create(testEngine, Wiki.contents().page(testEngine, "Foobar"));
final String res = manager.execute(context2, "{UndefinedPagesPlugin columns=2");
Assertions.assertTrue(res.startsWith("<div style=\"columns:2;-moz-columns:2;-webkit-columns:2;\"><a "));
}
Aggregations