Search in sources :

Example 61 with Context

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");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) Page(org.apache.wiki.api.core.Page) ReferenceManager(org.apache.wiki.references.ReferenceManager) Test(org.junit.jupiter.api.Test)

Example 62 with Context

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();
}
Also used : Context(org.apache.wiki.api.core.Context) JSPWikiMarkupParser(org.apache.wiki.parser.JSPWikiMarkupParser) StringReader(java.io.StringReader) Page(org.apache.wiki.api.core.Page) WikiDocument(org.apache.wiki.parser.WikiDocument)

Example 63 with Context

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();
}
Also used : Context(org.apache.wiki.api.core.Context) JSPWikiMarkupParser(org.apache.wiki.parser.JSPWikiMarkupParser) StringReader(java.io.StringReader) Page(org.apache.wiki.api.core.Page) WikiDocument(org.apache.wiki.parser.WikiDocument)

Example 64 with Context

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");
}
Also used : Context(org.apache.wiki.api.core.Context) PageManager(org.apache.wiki.pages.PageManager) MockHttpServletRequest(net.sourceforge.stripes.mock.MockHttpServletRequest) ArrayList(java.util.ArrayList) SearchResult(org.apache.wiki.api.search.SearchResult) Test(org.junit.jupiter.api.Test)

Example 65 with Context

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();
}
Also used : Context(org.apache.wiki.api.core.Context) JSPWikiMarkupParser(org.apache.wiki.parser.JSPWikiMarkupParser) StringReader(java.io.StringReader) WikiRenderer(org.apache.wiki.render.WikiRenderer) XHTMLRenderer(org.apache.wiki.render.XHTMLRenderer) WikiDocument(org.apache.wiki.parser.WikiDocument) JSPWikiMarkupParser(org.apache.wiki.parser.JSPWikiMarkupParser) MarkupParser(org.apache.wiki.parser.MarkupParser)

Aggregations

Context (org.apache.wiki.api.core.Context)81 Page (org.apache.wiki.api.core.Page)46 PageManager (org.apache.wiki.pages.PageManager)42 Test (org.junit.jupiter.api.Test)40 RenderingManager (org.apache.wiki.render.RenderingManager)15 PageContext (javax.servlet.jsp.PageContext)11 Engine (org.apache.wiki.api.core.Engine)9 ReferenceManager (org.apache.wiki.references.ReferenceManager)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 ServletContext (javax.servlet.ServletContext)6 ProviderException (org.apache.wiki.api.exceptions.ProviderException)6 WikiContext (org.apache.wiki.WikiContext)5 StringReader (java.io.StringReader)4 Properties (java.util.Properties)4 MockHttpServletRequest (net.sourceforge.stripes.mock.MockHttpServletRequest)4 WikiSessionTest (org.apache.wiki.WikiSessionTest)4 Attachment (org.apache.wiki.api.core.Attachment)4 SearchResult (org.apache.wiki.api.search.SearchResult)4