use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class SearchManagerTest method testSimpleSearch3.
@Test
public void testSimpleSearch3() throws Exception {
String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
MockHttpServletRequest request = m_engine.newHttpRequest();
request.getParameterMap().put("page", new String[] { "TestPage" });
WikiContext ctx = m_engine.createContext(request, WikiContext.EDIT);
m_engine.saveText(ctx, txt);
m_engine.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.");
Thread.yield();
// wait until 2nd m_engine.saveText() takes effect
Collection res = waitForIndex("Babylon", "testSimpleSearch3");
// check for text present in 1st m_engine.saveText() but not in 2nd
res = m_mgr.findPages("mankind", ctx);
Assert.assertNotNull("found results", res);
Assert.assertEquals("empty results", 0, res.size());
res = m_mgr.findPages("Babylon", ctx);
Assert.assertNotNull("null result", res);
Assert.assertEquals("no pages", 1, res.size());
Assert.assertEquals("page", "TestPage", ((SearchResult) res.iterator().next()).getPage().getName());
m_engine.deleteTestPage("TestPage");
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class InputValidatorTest method setUp.
@Before
public void setUp() throws Exception {
Properties props = TestEngine.getTestProperties();
testEngine = new TestEngine(props);
WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, "dummyPage"));
val = new InputValidator(TEST, context);
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class PluginBeanTest method testDoGet.
@Test
public void testDoGet() throws WikiException, NotCompliantMBeanException {
testEngine = new TestEngine(props);
WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage01"));
PluginBean pb = new PluginBean(testEngine);
String expectedHtml = "<div>" + "<h4>Plugins</h4>" + "<table border=\"1\">" + "<tr><th>Name</th><th>Alias</th><th>Author</th><th>Notes</th></tr>" + "<tr><td>IfPlugin</td><td>If</td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>Note</td><td></td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>SamplePlugin</td><td>samplealias</td><td>Janne Jalkanen</td><td></td></tr>" + "<tr><td>SamplePlugin2</td><td>samplealias2</td><td>Janne Jalkanen</td><td></td></tr>" + "</table>" + "</div>";
Assert.assertEquals(expectedHtml, pb.doGet(context));
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class IfPluginTest method testIfPluginUserAllowed.
/**
* Checks that user access is granted.
*
* @throws WikiException test Assert.failing.
*/
@Test
public void testIfPluginUserAllowed() throws WikiException {
String src = "[{IfPlugin user='Janne Jalkanen'\n" + "\n" + "Content visible for Janne Jalkanen}]";
String expected = "<p>Content visible for Janne Jalkanen</p>\n";
testEngine.saveText("Test", src);
WikiPage page = testEngine.getPage("Test", WikiPageProvider.LATEST_VERSION);
WikiContext context = getJanneBasedWikiContextFor(page);
String res = testEngine.getHTML(context, page);
Assert.assertEquals(expected, res);
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class IfPluginTest method testIfPluginIPAllowed.
/**
* Checks that IP address is granted.
*
* @throws WikiException test Assert.failing.
*/
@Test
public void testIfPluginIPAllowed() throws WikiException {
String src = "[{IfPlugin ip='127.0.0.1'\n" + "\n" + "Content visible for 127.0.0.1}]";
String expected = "<p>Content visible for 127.0.0.1</p>\n";
testEngine.saveText("Test", src);
WikiPage page = testEngine.getPage("Test", WikiPageProvider.LATEST_VERSION);
WikiContext context = getJanneBasedWikiContextFor(page);
String res = testEngine.getHTML(context, page);
Assert.assertEquals(expected, res);
}
Aggregations