Permalink
Browse files

Tracker:1941599, Added 'latest' to the 'resultDate' argument of PageH…

…istory responder
  • Loading branch information...
1 parent a1b23a8 commit 14921cd08822d4dec09baf45e3510e63667f5892 unclebob committed Mar 2, 2010
View
4 FitNesseRoot/FitNesse/UserGuide/RestfulServices/content.txt
@@ -53,7 +53,7 @@
| |jsonp=function |Wraps the json packet into a function call for JSONP, see: RestfulPackets |
|pageData | |Returns the raw wiki-text of the page. |
|pageHistory | |Displays the test history of the specified page. |
-| |resultDate |if present the date (yyyyMMddHHmmss) of the test to show. Otherwise show a list of all dates for this page. | |
+| |resultDate |if present the date (yyyyMMddHHmmss) of the test to show, or the word "latest". Otherwise show a list of all dates for this page. | |
| |format=xml |Returns an XML report. See: >PageHistoryXml and RestfulTests |
|properties | |Displays the properties form for the selected page. |
| |format=json |shows the properties in JSON format See >JsonProperties |
@@ -103,7 +103,7 @@
| |format=xml |Returns results in XML. See RestfulTests |
| |debug |(Only works for Java fixtures.) Attempts to run the test in the same JVM that !-FitNesse-! is running in. Allows you to attach a debugger to your fixtures before you run the test. | |
| |remote_debug |Causes the REMOTE_DEBUG_COMMAND variable to be used in place of COMMAND_PATTERN when creating the command to execute the test. Defaults to !style_code(java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -cp %p %m)|
-|testHistory | |Displays the current test history below the selected page, or all history if no page is selected. |
+|testHistory | |Displays the current test history below the selected page, or all history if no page is selected. |
| |format=xml |Returns an XML report of test history. See >TestHistoryXml |
|upload | |Upload a new file into the files section. The ''resource'' is the directory into which the new file will be stored. |
| |file |An object of type !style_code(fitnesse.http.UploadedFile) |
View
4 FitNesseRoot/RecentChanges/content.txt
@@ -1,3 +1,4 @@
+|FitNesse.UserGuide.RestfulServices||16:18:38 Tue, Mar 02, 2010|
|JunkPage.JunkTest||09:08:21 Sat, Feb 27, 2010|
|JunkPage.LisasNpeBug.RollInTests.RothRollinInstructions1||22:01:05 Fri, Feb 26, 2010|
|JunkPage.LisasNpeBug||21:54:55 Fri, Feb 26, 2010|
@@ -18,7 +19,6 @@
|FitNesse.SuiteAcceptanceTests.PageFooter||08:43:11 Wed, Feb 03, 2010|
|FitNesse.UserGuide.SliM.ValueComparisons||19:06:36 Tue, Feb 02, 2010|
|FitNesse.SuiteAcceptanceTests.SuiteSlimTests.RegularExpressionMatching||19:03:43 Tue, Feb 02, 2010|
-|FitNesse.UserGuide.RestfulServices||09:34:14 Mon, Feb 01, 2010|
|JunkParent||09:50:16 Fri, Jan 29, 2010|
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.ContentsTestsIncludeWithHelp||17:33:03 Sun, Jan 17, 2010|
|FitNesse.SuiteAcceptanceTests.SuiteWidgetTests.TestContentsHelp||17:32:46 Sun, Jan 17, 2010|
@@ -98,5 +98,3 @@
|FitNesse.SuiteAcceptanceTests.SuiteSlimTests.ScenarioLibraryTestSuite.BlankCellsInNestedScenariosShouldWork||15:39:30 Sun, Oct 18, 2009|
|ErrorLogs||09:13:03 Mon, Oct 12, 2009|
|JunkParent.DotNetTests||09:11:04 Mon, Oct 12, 2009|
-|JunkParent.TableTableTest||17:52:33 Sat, Oct 10, 2009|
-|JunkPage.GivWenZen||16:40:24 Mon, Oct 05, 2009|
View
7 src/fitnesse/responders/testHistory/PageHistory.java
@@ -203,6 +203,13 @@ public static String makePageHistoryFileName(FitNesseContext context, WikiPage p
TestHistory.makeResultFileName(counts, time));
}
+ public Date getLatestDate() {
+ Set<Date> dateSet = testResultMap.keySet();
+ List<Date> dates = new ArrayList<Date>(dateSet);
+ Collections.sort(dates);
+ return dates.get(dates.size()-1);
+ }
+
public static class TestResultRecord extends TestSummary {
private File file;
View
15 src/fitnesse/responders/testHistory/PageHistoryResponder.java
@@ -20,7 +20,6 @@
import java.io.File;
import java.io.StringWriter;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -62,7 +61,13 @@ private boolean formatIsXML(Request request) {
}
private Response tryToMakeTestExecutionReport(Request request) throws Exception {
- Date resultDate = getResultDate(request);
+ Date resultDate;
+ String date = (String) request.getInput("resultDate");
+ if ("latest".equals(date)) {
+ resultDate = pageHistory.getLatestDate();
+ } else {
+ resultDate = dateFormat.parse(date);
+ }
PageHistory.TestResultRecord testResultRecord = pageHistory.get(resultDate);
try {
return makeTestExecutionReportResponse(request, resultDate, testResultRecord);
@@ -71,12 +76,6 @@ private Response tryToMakeTestExecutionReport(Request request) throws Exception
}
}
- private Date getResultDate(Request request) throws ParseException {
- String date = (String) request.getInput("resultDate");
- Date resultDate = dateFormat.parse(date);
- return resultDate;
- }
-
private Response makeCorruptFileResponse(Request request) throws Exception {
return new ErrorResponder("Corrupt Test Result File").makeResponse(context, request);
}
View
21 src/fitnesse/responders/testHistory/PageHistoryResponderTest.java
@@ -305,6 +305,27 @@ public void canGetSuiteExecutionReport() throws Exception {
assertSubString("SuitePage.TestPageOne?pageHistory&resultDate=19801205012000", response.getContent());
}
+ @Test
+ public void canGetLatestWhenOnlyOneTestResultExists() throws Exception {
+ File pageDirectory = addPageDirectory("TestPage");
+ addDummyTestResult(new File(pageDirectory, "19801205012000_30_20_3_0"));
+
+ makeResultForDate("TestPage", "latest");
+ assertSubString("Fri Dec 05 01:20:00 CST 1980", response.getContent());
+ }
+
+ @Test
+ public void canGetLatestWhenManyTestResultsExists() throws Exception {
+ File pageDirectory = addPageDirectory("TestPage");
+ addDummyTestResult(new File(pageDirectory, "19801205012000_30_20_3_0"));
+ addDummyTestResult(new File(pageDirectory, "19901205012000_30_20_3_0"));
+ addDummyTestResult(new File(pageDirectory, "19951205012000_30_20_3_0"));
+ addDummyTestResult(new File(pageDirectory, "19941205012000_30_20_3_0"));
+
+ makeResultForDate("TestPage", "latest");
+ assertSubString("Tue Dec 05 01:20:00 CST 1995", response.getContent());
+ }
+
private void addDummySuiteResult(File resultFile) throws Exception {
SuiteExecutionReport report = makeDummySuiteResponse();
report.version = "version";

0 comments on commit 14921cd

Please sign in to comment.