@Test public void testRemoval() throws Exception { PageData data = pageOne.getData(); WikiPageProperty symLinks = data.getProperties().set(SymbolicPage.PROPERTY_NAME); symLinks.set("SymLink", "PageTwo"); pageOne.commit(data); assertNotNull(pageOne.getChildPage("SymLink")); request.addInput("removal", "SymLink"); Response response = invokeResponder(); checkPageOneRedirectToProperties(response); assertNull(pageOne.getChildPage("SymLink")); }
@Test public void testCanFindExistingPages() throws Exception { WikiPageUtil.addPage(root, PathParser.parse("FrontPage"), "front page"); WikiPage newRoot = new FileSystemPageFactory() .makePage(new File(base, "RooT"), "RooT", null, new SystemVariableSource()); assertNotNull(newRoot.getChildPage("FrontPage")); }
@Test public void testUsernameColumnWithoutUser() throws Exception { recentChangesWikiPage.updateRecentChanges(page1); WikiPage recentChanges = rootPage.getChildPage("RecentChanges"); List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData()); String line = lines.get(0).toString(); assertSubString("|PageOne||", line); }
@Test public void testNoDuplicates() throws Exception { recentChangesWikiPage.updateRecentChanges(page1); recentChangesWikiPage.updateRecentChanges(page1); WikiPage recentChanges = rootPage.getChildPage("RecentChanges"); List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData()); assertEquals(1, lines.size()); assertHasRegexp("PageOne", lines.get(0)); }
private void prepareSymlinkOnPageOne() { PageData data = pageOne.getData(); WikiPageProperty symLinks = data.getProperties().set(SymbolicPage.PROPERTY_NAME); symLinks.set("SymLink", "PageTwo"); pageOne.commit(data); assertNotNull(pageOne.getChildPage("SymLink")); request.addInput("rename", "SymLink"); }
@Test public void testRename() throws Exception { prepareSymlinkOnPageOne(); request.addInput("newname", "NewLink"); Response response = invokeResponder(); checkPageOneRedirectToProperties(response); assertNotNull(pageOne.getChildPage("NewLink")); }
@Test public void testFirstRecentChange() throws Exception { assertEquals(false, rootPage.hasChildPage("RecentChanges")); recentChangesWikiPage.updateRecentChanges(newPage); assertEquals(true, rootPage.hasChildPage("RecentChanges")); WikiPage recentChanges = rootPage.getChildPage("RecentChanges"); List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData()); assertEquals(1, lines.size()); assertHasRegexp("SomeNewPage", lines.get(0)); }
private void executeSymbolicLinkTestWith(String linkName, String linkPath) throws Exception { request.addInput("linkName", linkName); request.addInput("linkPath", linkPath); Response response = invokeResponder(); checkPageOneRedirectToProperties(response); WikiPage symLink = pageOne.getChildPage("SymLink"); assertNotNull(symLink); assertEquals(SymbolicPage.class, symLink.getClass()); }
@Test public void testSubmitGoodFormToSibling() throws Exception { request.addInput("linkName", "SymTwo"); request.addInput("linkPath", "PageTwo"); Response response = invokeResponder(); checkPageOneRedirectToProperties(response); WikiPage symLink = pageOne.getChildPage("SymTwo"); assertNotNull(symLink); assertEquals(SymbolicPage.class, symLink.getClass()); }
public void loadVirtualChildren(String url) throws Exception { try { ProxyPage proxy = ProxyPage.retrievePage(url); virtualCoupling = new VirtualCouplingPage(hostPage, proxy); } catch (Exception e) { WikiPage page = hostPage.getChildPage("VirtualWikiNetworkError"); if (page == null) page = hostPage.addChildPage("VirtualWikiNetworkError"); PageData data = page.getData(); data.setContent("{{{" + ErrorResponder.makeExceptionString(e) + "}}}"); page.commit(data); } }
@Test public void testUsernameColumnWithUser() throws Exception { PageData data = page1.getData(); data.setAttribute(PageData.LAST_MODIFYING_USER, "Aladdin"); page1.commit(data); recentChangesWikiPage.updateRecentChanges(page1); WikiPage recentChanges = rootPage.getChildPage("RecentChanges"); List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData()); String line = lines.get(0).toString(); assertSubString("|PageOne|Aladdin|", line); }
@Test public void testMaxSize() throws Exception { for (int i = 0; i < 101; i++) { StringBuffer b = new StringBuffer("LotsOfAs"); for (int j = 0; j < i; j++) b.append("a"); WikiPage page = rootPage.addChildPage(b.toString()); recentChangesWikiPage.updateRecentChanges(page); } WikiPage recentChanges = rootPage.getChildPage("RecentChanges"); List<String> lines = recentChangesWikiPage.getRecentChangesLines(recentChanges.getData()); assertEquals(100, lines.size()); }
@Test public void testSubmitGoodFormToBackwardRelative() throws Exception { request.setResource("PageTwo.ChildTwo"); request.addInput("linkName", "SymLink"); request.addInput("linkPath", "<PageTwo.ChildThree"); Response response = invokeResponder(); checkChildTwoRedirectToProperties(response); WikiPage symLink = childTwo.getChildPage("SymLink"); assertNotNull(symLink); assertEquals(SymbolicPage.class, symLink.getClass()); }
private String doRunAndGetErrorLog(String content) throws Exception { WikiPage testPage = crawler.addPage(root, PathParser.parse("TestPage"), content); request.setResource(testPage.getName()); Response response = responder.makeResponse(context, request); MockResponseSender sender = new MockResponseSender(); sender.doSending(response); String results = sender.sentData(); assertHasRegexp("ErrorLog", results); WikiPage errorLog = errorLogsParentPage.getChildPage(testPage.getName()); return errorLog.getData().getContent(); }
@Test public void testReplaceAllowedOnSymChild() throws Exception { request.addInput("linkName", "SymLink"); request.addInput("linkPath", "PageTwo"); Response response = invokeResponder(); request.addInput("linkName", "SymLink"); request.addInput("linkPath", ">ChildOne"); response = invokeResponder(); checkPageOneRedirectToProperties(response); WikiPage symLink = pageOne.getChildPage("SymLink"); assertNotNull(symLink); assertEquals(SymbolicPage.class, symLink.getClass()); assertTrue(symLink.getHtml().contains("ChildOne")); }
private void addChildFromXml(Element pageElement, WikiPage context, XmlizerPageHandler handler) { String name = XmlUtil.getTextValue(pageElement, "name"); String modifiedDateString = XmlUtil.getTextValue(pageElement, "lastModified"); Date modifiedDate; try { modifiedDate = modifiedDateString == null ? new Date(0) : dateFormat.parse(modifiedDateString); } catch (ParseException e) { modifiedDate = new Date(0); } WikiPage childPage = context.getChildPage(name); if (childPage == null) childPage = context.addChildPage(name); handler.enterChildPage(childPage, modifiedDate); addChildrenFromXml(pageElement, childPage, handler); handler.exitPage(); }
@Test public void testSubmitFormForLinkToExternalRoot() throws Exception { // Ise canonical names, since that's how they will be resolved. fileSystem.makeDirectory(new File("/somedir")); fileSystem.makeDirectory(new File("/somedir/ExternalRoot")); request.addInput("linkName", "SymLink"); request.addInput("linkPath", "file:/somedir/ExternalRoot"); Response response = invokeResponder(); checkPageOneRedirectToProperties(response); WikiPage symLink = pageOne.getChildPage("SymLink"); assertNotNull(symLink); assertEquals(SymbolicPage.class, symLink.getClass()); WikiPage realPage = ((SymbolicPage) symLink).getRealPage(); assertEquals(WikiFilePage.class, realPage.getClass()); assertEquals( new File("/somedir/ExternalRoot"), ((FileBasedWikiPage) realPage).getFileSystemPath()); }
protected WikiPage getNormalChildPage(String name) throws Exception { WikiPage childPage = realPage.getChildPage(name); if (childPage != null) childPage = new SymbolicPage(name, childPage, this); return childPage; }
@Test public void testCanFindExistingPages() throws Exception { crawler.addPage(root, PathParser.parse("FrontPage"), "front page"); WikiPage newRoot = new FileSystemPage(defaultPath, "RooT"); assertNotNull(newRoot.getChildPage("FrontPage")); }
private void reloadPages() { pageOne = root.getChildPage("PageOne"); WikiPage pageTwo = root.addChildPage("PageTwo"); childTwo = pageTwo.addChildPage("ChildTwo"); }