Using the system property JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR does not work and creates faulty documents with the value of the property instead of the value of the LineSeparator enum.
Calling System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM"); before anything else should make the system line separator the default line separator when serializing. Instead, the default line separator is initialized to the String value "SYSTEM".
Here is a test that currently fails with version 2.0.4 of JDom (Java 6 or Java 7):
package org.flexo.model;
import junit.framework.Assert;
import org.jdom2.JDOMConstants;
import org.jdom2.output.LineSeparator;
import org.junit.Test;
public class TestJDomLineSeparator {
@Test
public void testLineSeparatorFromSystemProperty() {
System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM");
Assert.assertEquals(System.getProperty("line.separator"), LineSeparator.DEFAULT.value());
}
}
It seems that calling final LineSeparator sep = Enum.valueOf(LineSeparator.class, prop); throws an IllegalArgumentException when called during the initialization of the enum. The exception is silently caught and the system property is immediately returned (this last part does not make sense).
Using the system property
JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATORdoes not work and creates faulty documents with the value of the property instead of the value of theLineSeparatorenum.Calling
System.setProperty(JDOMConstants.JDOM2_PROPERTY_LINE_SEPARATOR, "SYSTEM");before anything else should make the system line separator the default line separator when serializing. Instead, the default line separator is initialized to theStringvalue"SYSTEM".Here is a test that currently fails with version 2.0.4 of JDom (Java 6 or Java 7):
It seems that calling
final LineSeparator sep = Enum.valueOf(LineSeparator.class, prop);throws anIllegalArgumentExceptionwhen called during the initialization of the enum. The exception is silently caught and the system property is immediately returned (this last part does not make sense).