Skip to content
Merged
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 @@ -30,7 +30,7 @@
*/
public class PrettyPrintXMLWriter implements XMLWriter {
/** Line separator ("\n" on UNIX) */
protected static final String LS = System.getProperty("line.separator");
protected static final String LS = System.lineSeparator();

private PrintWriter writer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static String unifyLineSeparators(String s, String ls) {
}

if (ls == null) {
ls = System.getProperty("line.separator");
ls = System.lineSeparator();
}

if (!("\n".equals(ls) || "\r".equals(ls) || "\r\n".equals(ls))) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/codehaus/plexus/util/xml/XmlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class XmlUtil {
public static final int DEFAULT_INDENTATION_SIZE = 2;

/** The default line separator ("\n" on UNIX) */
public static final String DEFAULT_LINE_SEPARATOR = System.getProperty("line.separator");
public static final String DEFAULT_LINE_SEPARATOR = System.lineSeparator();

/**
* Determines if a given File shall be handled as XML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class XmlWriterUtil {
/** The vm line separator */
public static final String LS = System.getProperty("line.separator");
public static final String LS = System.lineSeparator();

/** The default line indenter size i.e. 2. */
public static final int DEFAULT_INDENTATION_SIZE = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.File;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.NoSuchElementException;

Expand Down Expand Up @@ -181,7 +180,7 @@ void issue51DetectJava7ConcatenationBug() throws Exception {

int iterations = 20000;

try (Writer osw = Files.newBufferedWriter(xmlFile.toPath(), StandardCharsets.UTF_8)) {
try (Writer osw = Files.newBufferedWriter(xmlFile.toPath())) {
writer = new PrettyPrintXMLWriter(osw);
for (int i = 0; i < iterations; ++i) {
writer.startElement(Tag.DIV.toString() + i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ void escapingInAttributes() throws Exception {
@Test
void inputLocationTracking() throws Exception {
Xpp3DomBuilder.InputLocationBuilder ilb = new Xpp3DomBuilder.InputLocationBuilder() {
@Override
public Object toInputLocation(XmlPullParser parser) {
return parser.getLineNumber(); // store only line number as a simple Integer
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ public FixedInputLocationBuilder(Object location) {
this.location = location;
}

@Override
public Object toInputLocation(XmlPullParser parser) {
return location;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @since 3.4.0
*/
class Xpp3DomWriterTest {
private static final String LS = System.getProperty("line.separator");
private static final String LS = System.lineSeparator();

/**
* <p>testWriter.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -636,9 +635,9 @@ void testibm_not_wf_P02_ibm02n29xml() throws Exception {
*/
@Test
@Disabled("test file is malformed in the original suite")
public void testibm_not_wf_P02_ibm02n30xml() throws IOException {
public void testibm_not_wf_P02_ibm02n30xml() throws Exception {
try (BufferedReader reader = Files.newBufferedReader(
Paths.get(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"),
Path.of(testResourcesDir.getCanonicalPath(), "not-wf/P02/ibm02n30.xml"),
Charset.forName("ISO-8859-15"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand All @@ -661,7 +660,7 @@ public void testibm_not_wf_P02_ibm02n30xml() throws IOException {
*/
@Test
@Disabled("test file is malformed in the original suite")
public void testibm_not_wf_P02_ibm02n31xml() throws IOException {
public void testibm_not_wf_P02_ibm02n31xml() throws Exception {
try (FileInputStream is = new FileInputStream(new File(testResourcesDir, "not-wf/P02/ibm02n31.xml"));
InputStreamReader reader = new InputStreamReader(is, "ISO-8859-15")) {
parser.setInput(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -213,7 +212,7 @@ void testibm_not_wf_P32_ibm32n08xml() throws Exception {
*/
@Test
@Disabled("MXParser does not support parsing inside DOCTYPEDECL")
public void testibm_not_wf_P32_ibm32n09xml() throws IOException {
public void testibm_not_wf_P32_ibm32n09xml() throws Exception {
try (Reader reader = new FileReader(new File(testResourcesDir, "not-wf/P32/ibm32n09.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;

import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -880,7 +880,7 @@ void xmlDeclVersionEncodingStandaloneNoSpace() throws Exception {
*/
@Test
void encodingISO88591NewXmlReader() throws Exception {
try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
try (Reader reader = new XmlStreamReader(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand All @@ -899,7 +899,7 @@ void encodingISO88591NewXmlReader() throws Exception {
@Test
void encodingISO88591InputStream() throws Exception {
try (InputStream input =
Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
Files.newInputStream(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
parser.setInput(input, null);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand All @@ -920,7 +920,7 @@ void encodingISO88591InputStream() throws Exception {
@Test
void encodingISO88591StringReader() throws Exception {
String xmlFileContents;
try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
try (Reader reader = new XmlStreamReader(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
xmlFileContents = readAllFrom(reader);
}

Expand Down Expand Up @@ -948,7 +948,7 @@ void encodingISO88591NewReader() throws Exception {
// because the decoder created by new InputStreamReader() is lenient while the one created by
// Files.newBufferedReader() is not.
try (Reader reader = new InputStreamReader(
Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml")),
Files.newInputStream(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml")),
StandardCharsets.UTF_8)) {
MXParser parser = new MXParser();
parser.setInput(reader);
Expand All @@ -970,7 +970,7 @@ void encodingISO88591NewReader() throws Exception {
@Test
void encodingISO88591InputStreamEncoded() throws Exception {
try (InputStream input =
Files.newInputStream(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
Files.newInputStream(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
parser.setInput(input, StandardCharsets.UTF_8.name());
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand All @@ -988,7 +988,7 @@ void encodingISO88591InputStreamEncoded() throws Exception {
*/
@Test
void encodingUTF8NewXmlReader() throws Exception {
try (Reader reader = new XmlStreamReader(Paths.get("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
try (Reader reader = new XmlStreamReader(Path.of("src/test/resources/xml", "test-encoding-ISO-8859-1.xml"))) {
MXParser parser = new MXParser();
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand Down Expand Up @@ -1215,7 +1215,7 @@ void docdeclTextWithEntitiesInAttributesDOS() throws Exception {
}

private void testDocdeclTextWithEntitiesInAttributes(String filename) throws IOException {
try (InputStream input = Files.newInputStream(Paths.get("src/test/resources/xml", filename))) {
try (InputStream input = Files.newInputStream(Path.of("src/test/resources/xml", filename))) {
MXParser parser = new MXParser();
parser.setInput(input, null);
parser.defineEntityReplacementText("nbsp", "&#160;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

Expand Down Expand Up @@ -131,7 +130,7 @@ void testhst_bh_004() throws Exception {
*/
@Test
@Disabled("MXParser does not support DOCDECL parsing")
public void testhst_bh_005() throws IOException {
public void testhst_bh_005() throws Exception {
try (Reader reader = new FileReader(new File(testResourcesDir, "005.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand All @@ -153,7 +152,7 @@ public void testhst_bh_005() throws IOException {
*/
@Test
@Disabled("MXParser does not support DOCDECL parsing")
public void testhst_bh_006() throws IOException {
public void testhst_bh_006() throws Exception {
try (Reader reader = new FileReader(new File(testResourcesDir, "006.xml"))) {
parser.setInput(reader);
while (parser.nextToken() != XmlPullParser.END_DOCUMENT) {}
Expand Down
Loading