use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RSSGeneratorTest method testBlogRSS.
@Test
public void testBlogRSS() throws Exception {
WeblogEntryPlugin plugin = new WeblogEntryPlugin();
m_testEngine.saveText("TestBlog", "Foo1");
String newPage = plugin.getNewEntryPage(m_testEngine, "TestBlog");
m_testEngine.saveText(newPage, "!Title1\r\nFoo");
newPage = plugin.getNewEntryPage(m_testEngine, "TestBlog");
m_testEngine.saveText(newPage, "!Title2\r\n__Bar__");
RSSGenerator gen = m_testEngine.getRSSGenerator();
WikiContext context = new WikiContext(m_testEngine, m_testEngine.getPage("TestBlog"));
WeblogPlugin blogplugin = new WeblogPlugin();
List<?> entries = blogplugin.findBlogEntries(m_testEngine, "TestBlog", new Date(0), new Date(Long.MAX_VALUE));
Feed feed = new RSS10Feed(context);
String blog = gen.generateBlogRSS(context, entries, feed);
Assert.assertTrue("has Foo", blog.indexOf("<description>Foo</description>") != -1);
Assert.assertTrue("has proper Bar", blog.indexOf("<b>Bar</b>") != -1);
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class SearchManagerTest method testSimpleSearch4.
@Test
public void testSimpleSearch4() 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);
Thread.yield();
Collection res = waitForIndex("mankind", "testSimpleSearch4");
Assert.assertNotNull("found results", res);
Assert.assertEquals("result not found", 1, res.size());
m_engine.saveText(ctx, "[{ALLOW view Authenticated}] It was the dawn of the third age of mankind... page is blocked");
res = m_mgr.findPages("mankind", ctx);
Assert.assertNotNull("null result", res);
Assert.assertEquals("result found, should be blocked", 0, res.size());
m_engine.deleteTestPage("TestPage");
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class SearchManagerTest method waitForIndex.
/**
* Should cover for both index and initial delay
*/
Collection waitForIndex(String text, String testName) throws Exception {
Collection res = null;
for (long l = 0; l < SLEEP_COUNT; l++) {
if (res == null || res.isEmpty()) {
Thread.sleep(SLEEP_TIME);
} else {
break;
}
MockHttpServletRequest request = m_engine.newHttpRequest();
WikiContext ctx = m_engine.createContext(request, WikiContext.EDIT);
res = m_mgr.findPages(text, ctx);
// debugSearchResults( res );
}
return res;
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class IfPluginTest method testIfPluginIPNotAllowed.
/**
* Checks that IP address is granted.
*
* @throws WikiException test Assert.failing.
*/
@Test
public void testIfPluginIPNotAllowed() throws WikiException {
String src = "[{IfPlugin ip='!127.0.0.1'\n" + "\n" + "Content NOT visible for 127.0.0.1}]";
String expected = "\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 getJanneBasedWikiContextFor.
/**
* Returns a {@link WikiContext} for the given page, with user {@link Users#JANNE} logged in.
*
* @param page given {@link WikiPage}.
* @return {@link WikiContext} associated to given {@link WikiPage}.
* @throws WikiException problems while logging in.
*/
WikiContext getJanneBasedWikiContextFor(WikiPage page) throws WikiException {
MockHttpServletRequest request = testEngine.newHttpRequest();
WikiSession session = WikiSession.getWikiSession(testEngine, request);
testEngine.getAuthenticationManager().login(session, request, Users.JANNE, Users.JANNE_PASS);
return new WikiContext(testEngine, request, page);
}
Aggregations