Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not adjust system property "line.separator" as it otherwise diverges #200

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/
@SuppressWarnings("checkstyle:interfaceistype")
public interface Markup {
/** The vm line separator */
String EOL = System.getProperty("line.separator");
/** The OS dependent line separator */
String EOL = System.lineSeparator();

// ----------------------------------------------------------------------
// Generic separator characters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@
@PlexusTest
public abstract class AbstractModuleTest implements Markup {

/*
* Set the system properties:
* <ul>
* <li><code>line.separator</code> to <code>\n</code> (Unix) to prevent
* failure on windows.</li>
* </ul>
*/
static {
// Safety
System.setProperty("line.separator", "\n");
}

// ----------------------------------------------------------------------
// Methods for creating test reader and writer
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -95,14 +83,6 @@ protected Writer getXmlTestWriter(String baseName) throws IOException {
return getXmlTestWriter(baseName, outputExtension());
}

protected static String normalizeLineEnds(String s) {
if (s != null) {
return s.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
} else {
return null;
}
}

/**
* Returns an XML FileWriter to write to a file with the given name
* in the test target output directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public void testHead() {
sink.flush();
sink.close();

String actual = normalizeLineEnds(testWriter.toString());
String expected = normalizeLineEnds(getHeadBlock());
String actual = testWriter.toString();
String expected = getHeadBlock();

assertEquals(expected, actual, "Wrong head!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ public static void generateNumberedList(Sink sink) {
* @param sink The sink to receive the events.
*/
public static void generateDefinitionList(Sink sink) {
String eol = System.getProperty("line.separator");

sink.definitionList();

Expand All @@ -262,7 +261,7 @@ public static void generateDefinitionList(Sink sink) {
sink.text("of definition list.");
sink.verbatim();
sink.inline(SinkEventAttributeSet.Semantics.CODE);
sink.text("Verbatim source text" + eol + " in a box ");
sink.text("Verbatim source text" + System.lineSeparator() + " in a box ");
sink.inline_();
sink.verbatim_();
sink.definition_();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ protected String getTableBlock(String cell, String caption) {

@Override
protected String getTableWithHeaderBlock(String... rowPrefixes) {
return "\n"
+ "*----+--:--*\n"
+ "|" + rowPrefixes[0] + "0||" + rowPrefixes[0] + "1||" + rowPrefixes[0] + "2|\n"
+ "*----+--:--*\n"
+ rowPrefixes[1] + "0|" + rowPrefixes[1] + "1|" + rowPrefixes[1] + "2|\n"
+ "*----+--:--*\n"
+ rowPrefixes[2] + "0|" + rowPrefixes[2] + "1|" + rowPrefixes[2] + "2|\n"
+ "*----+--:--*\n";
return EOL
+ "*----+--:--*" + EOL
+ "|" + rowPrefixes[0] + "0||" + rowPrefixes[0] + "1||" + rowPrefixes[0] + "2|" + EOL
+ "*----+--:--*" + EOL
+ rowPrefixes[1] + "0|" + rowPrefixes[1] + "1|" + rowPrefixes[1] + "2|" + EOL
+ "*----+--:--*" + EOL
+ rowPrefixes[2] + "0|" + rowPrefixes[2] + "1|" + rowPrefixes[2] + "2|" + EOL
+ "*----+--:--*" + EOL;
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ public void testEntities() throws Exception {
@Test
public void testStyleWithCData() throws Exception {
// DOXIA-449
final String text = "<style type=\"text/css\">\n" + "<![CDATA[\n"
+ "h2 {\n"
+ "font-size: 50px;\n"
+ "}\n"
+ "]]>\n"
final String text = "<style type=\"text/css\">" + EOL + "<![CDATA[" + EOL
+ "h2 {" + EOL
+ "font-size: 50px;" + EOL
+ "}" + EOL
+ "]]>" + EOL
+ "</style>";

SinkEventTestingSink sink = new SinkEventTestingSink();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ protected String getFooterBlock() {

/** {@inheritDoc} */
protected String getListBlock(String item) {
return "<ul>\n<li>" + item + "</li></ul>";
return "<ul>" + EOL + "<li>" + item + "</li></ul>";
}

/** {@inheritDoc} */
protected String getNumberedListBlock(String item) {
return "<ol style=\"list-style-type: lower-roman;\">\n<li>" + item + "</li></ol>";
return "<ol style=\"list-style-type: lower-roman;\">" + EOL + "<li>" + item + "</li></ol>";
}

/** {@inheritDoc} */
protected String getDefinitionListBlock(String definum, String definition) {
return "<dl>\n<dt>" + definum + "</dt>\n<dd>" + definition + "</dd></dl>";
return "<dl>" + EOL + "<dt>" + definum + "</dt>" + EOL + "<dd>" + definition + "</dd></dl>";
}

/** {@inheritDoc} */
Expand All @@ -209,20 +209,21 @@ protected String getFigureBlock(String source, String caption) {

/** {@inheritDoc} */
protected String getTableBlock(String cell, String caption) {
return "<table border=\"0\"><caption>" + caption + "</caption>\n<tr>\n<td style=\"text-align: center;\">" + cell
+ "</td></tr></table>";
return "<table border=\"0\"><caption>" + caption + "</caption>" + EOL + "<tr>" + EOL
+ "<td style=\"text-align: center;\">" + cell + "</td></tr></table>";
}

@Override
protected String getTableWithHeaderBlock(String... rowPrefixes) {
return "<table border=\"0\">\n<tr>\n<th>" + rowPrefixes[0] + "0</th>\n<th>" + rowPrefixes[0] + "1</th>\n<th>"
+ rowPrefixes[0] + "2</th></tr>\n"
+ "<tr>\n<td style=\"text-align: left;\">" + rowPrefixes[1]
+ "0</td>\n<td style=\"text-align: right;\">" + rowPrefixes[1]
+ "1</td>\n<td style=\"text-align: center;\">" + rowPrefixes[1] + "2</td></tr>\n"
+ "<tr>\n<td style=\"text-align: left;\">" + rowPrefixes[2]
+ "0</td>\n<td style=\"text-align: right;\">" + rowPrefixes[2]
+ "1</td>\n<td style=\"text-align: center;\">" + rowPrefixes[2] + "2</td></tr>"
return "<table border=\"0\">" + EOL + "<tr>" + EOL + "<th>" + rowPrefixes[0] + "0</th>" + EOL + "<th>"
+ rowPrefixes[0] + "1</th>" + EOL + "<th>"
+ rowPrefixes[0] + "2</th></tr>" + EOL
+ "<tr>" + EOL + "<td style=\"text-align: left;\">" + rowPrefixes[1]
+ "0</td>" + EOL + "<td style=\"text-align: right;\">" + rowPrefixes[1]
+ "1</td>" + EOL + "<td style=\"text-align: center;\">" + rowPrefixes[1] + "2</td></tr>" + EOL
+ "<tr>" + EOL + "<td style=\"text-align: left;\">" + rowPrefixes[2]
+ "0</td>" + EOL + "<td style=\"text-align: right;\">" + rowPrefixes[2]
+ "1</td>" + EOL + "<td style=\"text-align: center;\">" + rowPrefixes[2] + "2</td></tr>"
+ "</table>";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ protected String getDateBlock(String date) {

/** {@inheritDoc} */
protected String getHeadBlock() {
return "<!DOCTYPE html\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title></title>\n<meta charset=\"UTF-8\"/></head>";
return "<!DOCTYPE html\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + EOL + "<head>" + EOL
+ "<title></title>" + EOL + "<meta charset=\"UTF-8\"/></head>";
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -126,32 +126,32 @@ protected String getSectionTitleBlock(String title) {

/** {@inheritDoc} */
protected String getSection1Block(String title) {
return "<section><header>\n<h1>" + title + "</h1></header></section>";
return "<section><header>" + EOL + "<h1>" + title + "</h1></header></section>";
}

/** {@inheritDoc} */
protected String getSection2Block(String title) {
return "<section><header>\n<h2>" + title + "</h2></header></section>";
return "<section><header>" + EOL + "<h2>" + title + "</h2></header></section>";
}

/** {@inheritDoc} */
protected String getSection3Block(String title) {
return "<section><header>\n<h3>" + title + "</h3></header></section>";
return "<section><header>" + EOL + "<h3>" + title + "</h3></header></section>";
}

/** {@inheritDoc} */
protected String getSection4Block(String title) {
return "<section><header>\n<h4>" + title + "</h4></header></section>";
return "<section><header>" + EOL + "<h4>" + title + "</h4></header></section>";
}

/** {@inheritDoc} */
protected String getSection5Block(String title) {
return "<section><header>\n<h5>" + title + "</h5></header></section>";
return "<section><header>" + EOL + "<h5>" + title + "</h5></header></section>";
}

/** {@inheritDoc} */
protected String getSection6Block(String title) {
return "<section><header>\n<h6>" + title + "</h6></header></section>";
return "<section><header>" + EOL + "<h6>" + title + "</h6></header></section>";
}

/** {@inheritDoc} */
Expand All @@ -171,17 +171,17 @@ protected String getFooterBlock() {

/** {@inheritDoc} */
protected String getListBlock(String item) {
return "<ul>\n<li>" + item + "</li></ul>";
return "<ul>" + EOL + "<li>" + item + "</li></ul>";
}

/** {@inheritDoc} */
protected String getNumberedListBlock(String item) {
return "<ol style=\"list-style-type: lower-roman;\">\n<li>" + item + "</li></ol>";
return "<ol style=\"list-style-type: lower-roman;\">" + EOL + "<li>" + item + "</li></ol>";
}

/** {@inheritDoc} */
protected String getDefinitionListBlock(String definum, String definition) {
return "<dl>\n<dt>" + definum + "</dt>\n<dd>" + definition + "</dd></dl>";
return "<dl>" + EOL + "<dt>" + definum + "</dt>" + EOL + "<dd>" + definition + "</dd></dl>";
}

/** {@inheritDoc} */
Expand All @@ -197,24 +197,24 @@ protected String getFigureBlock(String source, String caption) {
/** {@inheritDoc} */
protected String getTableBlock(String cell, String caption) {
return "<table class=\"bodyTable\">"
+ "<caption>Table caption</caption><tr class=\"a\">\n<td>cell</td></tr>"
+ "<caption>Table caption</caption><tr class=\"a\">" + EOL + "<td>cell</td></tr>"
+ "</table>";
}

@Override
protected String getTableWithHeaderBlock(String... rowPrefixes) {
return "<table class=\"bodyTable\">\n"
+ "<tr class=\"a\">\n"
+ "<th>" + rowPrefixes[0] + "0</th>\n"
+ "<th>" + rowPrefixes[0] + "1</th>\n"
+ "<th>" + rowPrefixes[0] + "2</th></tr>\n"
+ "<tr class=\"b\">\n"
+ "<td style=\"text-align: left;\">" + rowPrefixes[1] + "0</td>\n"
+ "<td style=\"text-align: right;\">" + rowPrefixes[1] + "1</td>\n"
+ "<td style=\"text-align: center;\">" + rowPrefixes[1] + "2</td></tr>\n"
+ "<tr class=\"a\">\n"
+ "<td style=\"text-align: left;\">" + rowPrefixes[2] + "0</td>\n"
+ "<td style=\"text-align: right;\">" + rowPrefixes[2] + "1</td>\n"
return "<table class=\"bodyTable\">" + EOL
+ "<tr class=\"a\">" + EOL
+ "<th>" + rowPrefixes[0] + "0</th>" + EOL
+ "<th>" + rowPrefixes[0] + "1</th>" + EOL
+ "<th>" + rowPrefixes[0] + "2</th></tr>" + EOL
+ "<tr class=\"b\">" + EOL
+ "<td style=\"text-align: left;\">" + rowPrefixes[1] + "0</td>" + EOL
+ "<td style=\"text-align: right;\">" + rowPrefixes[1] + "1</td>" + EOL
+ "<td style=\"text-align: center;\">" + rowPrefixes[1] + "2</td></tr>" + EOL
+ "<tr class=\"a\">" + EOL
+ "<td style=\"text-align: left;\">" + rowPrefixes[2] + "0</td>" + EOL
+ "<td style=\"text-align: right;\">" + rowPrefixes[2] + "1</td>" + EOL
+ "<td style=\"text-align: center;\">" + rowPrefixes[2] + "2</td></tr>"
+ "</table>";
}
Expand Down Expand Up @@ -367,7 +367,9 @@ public void testEntities() {
sink.close();
}

assertEquals("<section><header>\n<h1>&amp;</h1></header>\n<p>&amp;</p></section>", writer.toString());
assertEquals(
"<section><header>" + EOL + "<h1>&amp;</h1></header>" + EOL + "<p>&amp;</p></section>",
writer.toString());
}

/**
Expand Down Expand Up @@ -398,7 +400,7 @@ public void testHead() {
}

String expected =
"<head>\n<title>Title</title><!--A comment--><meta name=\"author\" content=\"&#x123;&amp;\" />"
"<head>" + EOL + "<title>Title</title><!--A comment--><meta name=\"author\" content=\"&#x123;&amp;\" />"
+ "<base href=\"http://maven.apache.org/\" /></head>";
String actual = writer.toString();
assertTrue(actual.contains(expected), actual);
Expand Down
Loading