use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class PageRenamerTest method testSimpleRename.
@Test
public void testSimpleRename() throws Exception {
// Count the number of existing references
final int refCount = m_engine.getManager(ReferenceManager.class).findCreated().size();
m_engine.saveText("TestPage", "the big lazy dog thing");
final Page p = m_engine.getManager(PageManager.class).getPage("TestPage");
final Context context = Wiki.context().create(m_engine, p);
m_engine.getManager(PageRenamer.class).renamePage(context, "TestPage", "FooTest", false);
final Page newpage = m_engine.getManager(PageManager.class).getPage("FooTest");
Assertions.assertNotNull(newpage, "no new page");
Assertions.assertNull(m_engine.getManager(PageManager.class).getPage("TestPage"), "old page not gone");
// Refmgr
final Collection<String> refs = m_engine.getManager(ReferenceManager.class).findCreated();
Assertions.assertTrue(refs.contains("FooTest"), "FooTest does not exist");
Assertions.assertFalse(refs.contains("TestPage"), "TestPage exists");
Assertions.assertEquals(refCount + 1, refs.size(), "wrong list size");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class CreoleRendererTest method render.
private String render(final String s) throws IOException {
final Page dummyPage = Wiki.contents().page(m_testEngine, "TestPage");
final Context ctx = Wiki.context().create(m_testEngine, dummyPage);
final StringReader in = new StringReader(s);
final JSPWikiMarkupParser p = new JSPWikiMarkupParser(ctx, in);
final WikiDocument d = p.parse();
final CreoleRenderer cr = new CreoleRenderer(ctx, d);
return cr.getString();
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class WysiwygEditingRendererTest method render.
private String render(final String s) throws IOException {
final Page dummyPage = Wiki.contents().page(testEngine, "TestPage");
final Context ctx = Wiki.context().create(testEngine, dummyPage);
final StringReader in = new StringReader(s);
final JSPWikiMarkupParser p = new JSPWikiMarkupParser(ctx, in);
final WikiDocument d = p.parse();
final WysiwygEditingRenderer wer = new WysiwygEditingRenderer(ctx, d);
return wer.getString();
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class SearchManagerTest method testSimpleSearch3.
@Test
public void testSimpleSearch3() throws Exception {
final String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
final MockHttpServletRequest request = m_engine.newHttpRequest();
request.getParameterMap().put("page", new String[] { "TestPage" });
final Context ctx = Wiki.context().create(m_engine, request, ContextEnum.PAGE_EDIT.getRequestContext());
m_engine.getManager(PageManager.class).saveText(ctx, txt);
m_engine.getManager(PageManager.class).saveText(ctx, "The Babylon Project was a dream given form. Its goal: to prevent another war by creating a place where humans and aliens could work out their differences peacefully.");
Collection<SearchResult> res = new ArrayList<>();
Awaitility.await("testSimpleSearch3").until(findsResultsFor(res, "Babylon"));
// check for text present in 1st m_engine.saveText() but not in 2nd
res = m_mgr.findPages("mankind", ctx);
Assertions.assertEquals(0, res.size(), "empty results");
Awaitility.await("testSimpleSearch3").until(findsResultsFor(res, "Babylon"));
Assertions.assertNotNull(res, "null result");
Assertions.assertEquals(1, res.size(), "no pages");
Assertions.assertEquals("TestPage", res.iterator().next().getPage().getName(), "page");
m_engine.deleteTestPage("TestPage");
}
use of org.apache.wiki.api.core.Context in project jspwiki by apache.
the class CounterPluginTest method translate.
private String translate(final String src) throws IOException {
final Context context = Wiki.context().create(testEngine, Wiki.contents().page(testEngine, "TestPage"));
final MarkupParser p = new JSPWikiMarkupParser(context, new StringReader(src));
final WikiDocument dom = p.parse();
final WikiRenderer r = new XHTMLRenderer(context, dom);
return r.getString();
}
Aggregations