/** * Checks that IP address is granted. * * @throws WikiException test failing. */ 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); assertEquals(expected, res); }
/** * Checks that user access is granted. * * @throws WikiException test failing. */ public void testIfPluginUserAllowed() throws WikiException { String src = "[{IfPlugin user='******'\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); assertEquals(expected, res); }
public void testMillionChanges() throws Exception { String text = ""; String name = NAME1; int maxver = 2000; // Save 2000 versions. Benchmark mark = new Benchmark(); mark.start(); for (int i = 0; i < maxver; i++) { text = text + "."; engine.saveText(name, text); } mark.stop(); System.out.println("Benchmark: " + mark.toString(2000) + " pages/second"); WikiPage pageinfo = engine.getPage(NAME1); assertEquals("wrong version", maxver, pageinfo.getVersion()); // +2 comes from \r\n. assertEquals("wrong text", maxver + 2, engine.getText(NAME1).length()); }