Skip to content

Commit

Permalink
Fix suites consisting of symbolic pages
Browse files Browse the repository at this point in the history
If using a Suite-page that uses symlinks to link to different external
roots, starting with commit 16bb43e only the contents of the first
symlinked page was displayed in the output of "!contents".

This was regression was introduced by fixing unclebob#925.
  • Loading branch information
jan-z committed Apr 20, 2019
1 parent 624a03d commit 23f3c7e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/fitnesse/wiki/BaseWikiPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ public boolean equals(Object other) {
if (!(other instanceof WikiPage))
return false;
try {
WikiPage otherPage = (WikiPage) other;
if (isRoot() && otherPage.isRoot()) {
return getName().equals(otherPage.getName());
}
WikiPagePath path1 = getPageCrawler().getFullPath();
WikiPagePath path2 = ((WikiPage) other).getPageCrawler().getFullPath();
WikiPagePath path2 = otherPage.getPageCrawler().getFullPath();
return path1.equals(path2);
} catch (Exception e) {
return false;
Expand Down
10 changes: 6 additions & 4 deletions test/fitnesse/wiki/BaseWikiPageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import fitnesse.wiki.fs.*;
import util.FileUtil;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

public class BaseWikiPageTest {
private WikiPage linkingPage;
Expand Down Expand Up @@ -52,6 +49,11 @@ public void testGetChildUsesSymbolicPages() throws Exception {
checkSymbolicPage(linkingPage.getChildPage("SymLink"));
}

@Test
public void doesNotEqualAnotherRoot() {
WikiPage externalRoot = InMemoryPage.makeRoot("ExternalRoot", fileSystem);
assertNotEquals(root, externalRoot);
}

@Test
public void testThatSpecialCharsAreNotEscapedTwice() throws Exception {
Expand Down
22 changes: 22 additions & 0 deletions test/fitnesse/wiki/SymbolicPageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ public void testLinkage() throws Exception {
assertSame(pageTwo, symPage.getRealPage());
}

@Test
public void equalsAnotherSymbolicPageWithTheSameRealPage() {
assertEquals(symPage, new SymbolicPage("SymPage2", pageTwo, pageOne));
}

@Test
public void doesNotEqualAnotherSymbolicPageWithDifferentRealPage() {
WikiPage childPage = WikiPageUtil.addPage(pageTwo, PathParser.parse("ChildOne"), "child one");
assertNotEquals(symPage, new SymbolicPage("SymPage2", childPage, pageOne));
}

@Test
public void doesNotEqualAnotherSymbolicPageWithDifferentExternalRoot() throws Exception {
createExternalRoot();

FileUtil.createDir("testDir/ExternalRoot2");
WikiPage externalRoot2 = new FileSystemPageFactory().makePage(new File("testDir/ExternalRoot2"), "ExternalRoot2", null, new SystemVariableSource());
WikiPage symPage2 = new SymbolicPage("SymPage2", externalRoot2, pageOne);

assertNotEquals(symPage, symPage2);
}

@Test
public void testInternalData() throws Exception {
PageData data = symPage.getData();
Expand Down

0 comments on commit 23f3c7e

Please sign in to comment.