Skip to content

Commit

Permalink
Do not adjust system property "line.separator" as it otherwise diverges
Browse files Browse the repository at this point in the history
from System.lineSeparator()

Fix all test cases to use platform specific line separators
  • Loading branch information
kwin committed Feb 8, 2024
1 parent d050b2d commit fd86451
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 65 deletions.
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
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 @@ -259,7 +259,7 @@ protected String getDivisionBlock(String text) {

/** {@inheritDoc} */
protected String getVerbatimSourceBlock(String text) {
return "<div class=\"verbatim source\">\n<pre>" + text + "</pre></div>";
return "<div class=\"verbatim source\">" + EOL + "<pre>" + text + "</pre></div>";
}

/** {@inheritDoc} */
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

0 comments on commit fd86451

Please sign in to comment.