aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-colorizer
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-01-18 10:28:23 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-01-18 10:28:23 +0100
commita88512126dc63e77c19c62a495b984379a01f020 (patch)
treef7607c05af473bca3f5247b9dd4cff4cc0865a94 /sonar-colorizer
parentf5a8b2e863f3d45308cdc4f148228ec5aa669016 (diff)
downloadsonarqube-a88512126dc63e77c19c62a495b984379a01f020.tar.gz
sonarqube-a88512126dc63e77c19c62a495b984379a01f020.zip
SONAR-2115 add an unit test to reproduce the bug (Files with Windows end of lines are badly parsed by syntax highlighter)
Diffstat (limited to 'sonar-colorizer')
-rw-r--r--sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
index 0c5cd743f53..67f7ee7cc28 100644
--- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
+++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
@@ -26,10 +26,7 @@ import static org.hamcrest.number.OrderingComparisons.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
+import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -39,6 +36,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.junit.Ignore;
import org.junit.Test;
public class CodeColorizerTest {
@@ -54,6 +53,21 @@ public class CodeColorizerTest {
}
@Test
+ @Ignore("see http://jira.codehaus.org/browse/SONAR-2115")
+ public void shouldSupportWindowsEndOfLines() throws IOException {
+ StringBuilder windowsFile = new StringBuilder();
+ List<String> lines = FileUtils.readLines(FileUtils.toFile(getClass().getResource("/org/sonar/colorizer/samples/Sample.java")));
+ for (String line : lines) {
+ windowsFile.append(line).append(IOUtils.LINE_SEPARATOR_WINDOWS);
+ }
+
+ String html = CodeColorizer.javaToHtml(new StringReader(windowsFile.toString()), HtmlOptions.DEFAULT);
+
+ assertHtml(html);
+ assertContains(html, "<pre><span class=\"k\">public</span> <span class=\"k\">class</span> Sample {</pre>");
+ }
+
+ @Test
public void useHtmlOptions() throws IOException {
Reader java = readFile("/org/sonar/colorizer/samples/Sample.java");