Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/MarkusGaertner/fitnesseback…

…logfixes
  • Loading branch information...
commit 36cd6085c030d7c7a3c2901f9a80f3fe2dbb3b5f 2 parents 4a8cd35 + bdd83a8
unclebob authored
17 ...esseRoot/FitNesse/SuiteAcceptanceTests/SuiteWidgetTests/TestIncludeSetUpTearDownWithPageName/content.txt
View
@@ -0,0 +1,17 @@
+!*< test page content definition
+!define pageContent (!include -setup SetUp
+!include IncludedPage
+Including page name is !-${PAGE_NAME}-!
+!include -teardown TearDown)
+
+*!
+
+!|script|
+|create page|SetUp|with content|Set Up page name is !-${PAGE_NAME}-!|
+|create page|TearDown|with content|Tear Down page name is !-${PAGE_NAME}-!|
+|create page|IncludedPage|with content|Included page name is !-${PAGE_NAME}-!|
+|given page|IncludingPage|with content|${pageContent}|
+|it should contain|Included page name is <a href="IncludedPage">IncludedPage|
+|it should contain|Including page name is <a href="IncludingPage">IncludingPage|
+|it should contain|Set Up page name is <a href="IncludingPage">IncludingPage|
+|it should contain|Tear Down page name is <a href="IncludingPage">IncludingPage|
15 ...eRoot/FitNesse/SuiteAcceptanceTests/SuiteWidgetTests/TestIncludeSetUpTearDownWithPageName/properties.xml
View
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<properties>
+ <Edit>true</Edit>
+ <Files>true</Files>
+ <LastModified>20090319152813</LastModified>
+ <Properties>true</Properties>
+ <RecentChanges>true</RecentChanges>
+ <Refactor>true</Refactor>
+ <Search>true</Search>
+ <Test>true</Test>
+ <Versions>true</Versions>
+ <WhereUsed>true</WhereUsed>
+ <saveId>1237470268676</saveId>
+ <ticketId>-6178655714902395693</ticketId>
+</properties>
19 build.xml
View
@@ -28,7 +28,7 @@
<target name="testbuild" depends="clean, unit_test, execute_fitnesse_tests"
description="builds code from scratch, runs all the unit tests and acceptance tests"/>
- <target name="build_distribution" depends="zip_src, zip_bin"
+ <target name="build_distribution" depends="zip_bin"
description="The thing you do when distributing a new release."/>
<target name="assemble_bin" depends="clean_dist, jar, copy_distribution"
@@ -62,23 +62,6 @@
<zip zipfile="fitnesse${DSTAMP}.zip" basedir="dist" includes="fitnesse/**" excludes="**/Thumbs.db"/>
</target>
- <target name="zip_src" depends="clean_dist" description="Packages all the source into a .zip file">
- <tstamp/>
- <zip zipfile="fitnesse_src${DSTAMP}.zip">
- <fileset dir=".">
- <include name="src/**"/>
- <include name="srcFitServerTests/**"/>
- <include name="lib/**"/>
- <include name="extra/**"/>
- <include name="build.xml"/>
- <include name="dotnet/**"/>
- <include name="BUILD_README.txt"/>
- <include name="templates/**"/>
- <exclude name="**/fitnesse*.zip"/>
- </fileset>
- </zip>
- </target>
-
<target name="jar" depends="build, copyResources" description="generate the jar file">
<mkdir dir="dist"/>
<delete file="dist/fitnesse.jar"/>
30 src/fitnesse/wikitext/widgets/IncludeWidget.java
View
@@ -91,12 +91,12 @@ private String getPageName(Matcher match) {
//TODO MDM I know this is bad... But it seems better then creating two new widgets.
private void buildWidget(String option) throws Exception {
- String widgetText = processLiterals(getIncludedPageContent());
+ String widgetText = processLiterals(getIncludedPageContent(option));
//Create imposter root with alias = this if included page found.
ParentWidget incRoot = (includedPage == null) ? this : new WidgetRoot(includedPage, this);
- if ("-seamless".equals(option) || getRoot().isGatheringInfo()) { //Use the imposter if found.
+ if (isSeamLess(option) || getRoot().isGatheringInfo()) { //Use the imposter if found.
incRoot.addChildWidgets(widgetText + "\n");
} else { //Use new constructor with dual scope.
new CollapsableWidget(incRoot, this, getPrefix(option) + pageName, widgetText, getCssClass(option), isCollapsed(
@@ -106,6 +106,26 @@ private void buildWidget(String option) throws Exception {
}
}
+ //TODO MG There was no better way to nest in this behaviour. As future evolution point we can
+ // expand the if clause to also accept regular includes and replace PAGE_NAME all the time.
+ private String getIncludedPageContent(String option) throws Exception {
+
+ if (isSetup(option) || isTeardown(option)) {
+ return replaceSpecialVariables(getIncludedPageContent());
+ }
+
+ return getIncludedPageContent();
+ }
+
+ //TODO MG What about PAGE_PATH?
+ private String replaceSpecialVariables(String includedPageContent) throws Exception {
+ return includedPageContent.replaceAll("\\$\\{PAGE_NAME\\}", includingPage.getName());
+ }
+
+ private boolean isSeamLess(String option) {
+ return "-seamless".equals(option);
+ }
+
private String getCssClass(String option) {
return optionCssMap.get(option);
}
@@ -174,4 +194,10 @@ public WikiPage getReferencedPage() throws Exception {
public String asWikiText() throws Exception {
return "";
}
+
+ @Override
+ public String processLiterals(String value) throws Exception {
+ // TODO Auto-generated method stub
+ return super.processLiterals(value);
+ }
}
22 src/fitnesse/wikitext/widgets/IncludeWidgetTest.java
View
@@ -165,6 +165,28 @@ private void verifyLiteralsGetRendered(String option, String pageName)
assertEquals("three", widgetRoot.getLiteral(2));
}
+ public void testPageNameOnSetUpPage() throws Exception {
+ verifyPageNameResolving("-setup ", "IncludingPage");
+ }
+
+ public void testPageNameOnTearDownPage() throws Exception {
+ verifyPageNameResolving("-teardown ", "IncludingPage");
+ }
+
+ public void testPageNameOnRegularPage() throws Exception {
+ verifyPageNameResolving("", "IncludedPage");
+ }
+
+ private void verifyPageNameResolving(String option, String expectedPageName) throws Exception {
+ crawler.addPage(root, PathParser.parse("IncludedPage"), "This is IncludedPage\nincluded page name is ${PAGE_NAME}\n");
+ crawler.addPage(root, PathParser.parse("IncludingPage"));
+ ParentWidget widgetRoot = new WidgetRoot("This is IncludingPage\n" + "!include " + option + "IncludedPage",
+ root.getChildPage("IncludingPage"), WidgetBuilder.htmlWidgetBuilder);
+ String content = widgetRoot.render();
+ assertHasRegexp("included page name is <a href=\"" + expectedPageName + "\">" + expectedPageName , content);
+ }
+
+
public void testRenderWhenMissing() throws Exception {
verifyRenderWhenMissing("MissingPage");
}
Please sign in to comment.
Something went wrong with that request. Please try again.