Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

HTML fixes for JavaFormatter #165

Merged
merged 4 commits into from

3 participants

@awulder
  • Fixed JavaScript errors by adding jQuery
  • Updated HTML (added header and article tags) because some bindings defined in fitnesse.js failed. The collapsible functionality on the result page will work again.
Arjan Wulder added some commits
Arjan Wulder HTML fixes for JavaFormatter
- Fixed JavaScript errors by adding jQuery
- Updated HTML (added header and article tags) because some bindings
defined in fitnesse.js failed. The collapsible on the result page will
work again.
19c144f
Arjan Wulder HTML fixes for JavaFormatter
Forget to commit failing Unit test
9e12f72
Arjan Wulder Moved static files to folders
The arrows didn't show because the relative paths were incorrect. By
moving the static files to folders it works as expected.
7382620
@benilovj

Hi,

Because your editor reformatted the code, it's very hard to see from the diff what's changed. Also, I believe that the standard for this project is a 2-space indent. Would it be possible to update your changes with that in mind?

thanks

Arjan Wulder 2-space indent fix
Now using 2-space indent instead of 4-spaces
7123c94
@benilovj

thats much better, thanks!

@awulder

I had the wong coding style template selected

@amolenaar
Collaborator

I would have preferred if Velocity had been used to render the page.

@awulder

@amolenaar I think it's a good idea to use Velocity. I will refactor the JavaFormatter. Consider this as a quick fix for the bug.

@amolenaar amolenaar merged commit e442778 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 21, 2012
  1. HTML fixes for JavaFormatter

    Arjan Wulder authored
    - Fixed JavaScript errors by adding jQuery
    - Updated HTML (added header and article tags) because some bindings
    defined in fitnesse.js failed. The collapsible on the result page will
    work again.
  2. HTML fixes for JavaFormatter

    Arjan Wulder authored
    Forget to commit failing Unit test
  3. Moved static files to folders

    Arjan Wulder authored
    The arrows didn't show because the relative paths were incorrect. By
    moving the static files to folders it works as expected.
Commits on Dec 23, 2012
  1. 2-space indent fix

    Arjan Wulder authored
    Now using 2-space indent instead of 4-spaces
This page is out of date. Refresh to see the latest.
View
62 src/fitnesse/responders/run/JavaFormatter.java
@@ -1,5 +1,10 @@
package fitnesse.responders.run;
+import fitnesse.responders.run.formatters.BaseFormatter;
+import fitnesse.wiki.WikiPage;
+import fitnesse.wiki.WikiPagePath;
+import util.TimeMeasurement;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -12,11 +17,6 @@
import java.util.List;
import java.util.Map;
-import util.TimeMeasurement;
-import fitnesse.responders.run.formatters.BaseFormatter;
-import fitnesse.wiki.WikiPage;
-import fitnesse.wiki.WikiPagePath;
-
/**
* Used to run tests from a JUnit test suite.
*
@@ -46,13 +46,6 @@ public FolderResultsRepository(String outputPath, String fitNesseRoot) throws IO
initFolder(fitNesseRoot);
}
- public void close() throws IOException {
- if (currentWriter != null) {
- currentWriter.write("</body></html>");
- currentWriter.close();
- }
- }
-
public void open(String testName) throws IOException {
File outputFile = new File(outputPath, testName + ".html");
currentWriter = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8");
@@ -60,27 +53,35 @@ public void open(String testName) throws IOException {
currentWriter.write("<html><head><title>");
currentWriter.write(testName);
currentWriter
- .write("</title><meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>"
- + "<link rel='stylesheet' type='text/css' href='fitnesse.css'/>"
- + "<script src='fitnesse.js' type='text/javascript'></script>" + "</head><body><h2>");
+ .write("</title><meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>"
+ + "<link rel='stylesheet' type='text/css' href='css/fitnesse.css'/>"
+ + "<script src='javascript/jquery-1.7.2.min.js' type='text/javascript'></script>"
+ + "<script src='javascript/fitnesse.js' type='text/javascript'></script>" + "</head><body><header><h2>");
currentWriter.write(testName);
- currentWriter.write("</h2>");
+ currentWriter.write("</h2></header><article>");
}
+ public void close() throws IOException {
+ if (currentWriter != null) {
+ currentWriter.write("</article></body></html>");
+ currentWriter.close();
+ }
+ }
+
public void write(String content) throws IOException {
currentWriter.write(content.replace("src=\"/files/images/", "src=\"images/"));
}
- public void addFile(String r, String relativeFilePath) throws IOException {
+ public void addFile(String resource, String relativeFilePath) throws IOException {
File dst = new File(outputPath, relativeFilePath);
dst.getParentFile().mkdirs();
- copy(r, dst);
+ copy(resource, dst);
}
- private void copy(String src, File dst) throws IOException {
- InputStream in = getClass().getResourceAsStream(src);
- OutputStream out = new FileOutputStream(dst);
+ private void copy(String source, File destination) throws IOException {
+ InputStream in = getClass().getResourceAsStream(source);
+ OutputStream out = new FileOutputStream(destination);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
@@ -94,9 +95,10 @@ private void copy(String src, File dst) throws IOException {
private void initFolder(String fitnesseRoot) throws IOException {
String base = "/fitnesse/resources/";
String cssDir = base + "css/";
- addFile(cssDir + "fitnesse_wiki.css", "fitnesse.css");
+ addFile(cssDir + "fitnesse_wiki.css", "css/fitnesse.css");
String javascriptDir = base + "javascript/";
- addFile(javascriptDir + "fitnesse.js", "fitnesse.js");
+ addFile(javascriptDir + "jquery-1.7.2.min.js", "javascript/jquery-1.7.2.min.js");
+ addFile(javascriptDir + "fitnesse.js", "javascript/fitnesse.js");
String imagesDir = base + "images/";
addFile(imagesDir + "collapsibleOpen.png", "images/collapsibleOpen.png");
addFile(imagesDir + "collapsibleClosed.png", "images/collapsibleClosed.png");
@@ -162,7 +164,9 @@ public void setResultsRepository(ResultsRepository mockResultsRepository) {
}
- /** package-private to prevent instantiation apart from getInstance and tests */
+ /**
+ * package-private to prevent instantiation apart from getInstance and tests
+ */
JavaFormatter(String suiteName) {
this.mainPageName = suiteName;
}
@@ -198,11 +202,11 @@ public void writeSummary(String suiteName) throws IOException {
}
public String summaryRow(String testName, TestSummary testSummary) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("<tr class=\"").append(getCssClass(testSummary)).append("\"><td>").append(
- "<a href=\"").append(testName).append(".html\">").append(testName).append("</a>").append(
- "</td><td>").append(testSummary.right).append("</td><td>").append(testSummary.wrong)
- .append("</td><td>").append(testSummary.exceptions).append("</td></tr>");
+ "<a href=\"").append(testName).append(".html\">").append(testName).append("</a>").append(
+ "</td><td>").append(testSummary.right).append("</td><td>").append(testSummary.wrong)
+ .append("</td><td>").append(testSummary.exceptions).append("</td></tr>");
return sb.toString();
}
@@ -228,4 +232,4 @@ public static void dropInstance(String testName) {
allocatedInstances.remove(testName);
}
-}
+}
View
2  src/fitnesse/responders/run/JavaFormatterFolderResultsRepositoryTest.java
@@ -41,7 +41,7 @@ public void usesTestNameAsHeadingWithinValidHtmlStructure() throws Exception {
repository.open(TEST_NAME);
repository.close();
- String heading = evaluateXPathAgainstOutputHtml("/html/body/h2/text()");
+ String heading = evaluateXPathAgainstOutputHtml("/html/body/header/h2/text()");
assertEquals(TEST_NAME, heading);
}
Something went wrong with that request. Please try again.