Skip to content

Commit

Permalink
not clear where the strange formatting is coming from
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenartur committed May 20, 2020
1 parent 2e1782c commit 707ca35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions xstream/src/java/com/thoughtworks/xstream/XStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
Expand Down Expand Up @@ -1932,6 +1933,7 @@ public ObjectOutputStream createObjectOutputStream(final OutputStream out, Chars
final PipedInputStream pipedinput= new PipedInputStream(pipedoutput);
TransformerFactory instance= TransformerFactory.newInstance();
Transformer transformer= instance.newTransformer(stylesheet);
transformer.setOutputProperty(OutputKeys.INDENT, "no");
Thread thread= new Thread(() -> {
try {
transformer.transform(new StreamSource(pipedinput), new StreamResult(out));
Expand Down
16 changes: 5 additions & 11 deletions xstream/src/test/com/thoughtworks/xstream/XStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,35 +409,29 @@ public void testObjectOutputStreamXSLSimpleSmokeTest() throws IOException, Trans
oout.flush();
oout.close();
Assert.assertEquals(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +System.lineSeparator()+
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+
"<rootname>" +System.lineSeparator()+
" <int>1</int>" +System.lineSeparator()+
"</rootname>" +System.lineSeparator()+
"", out.toString("UTF-8"));
"</rootname>", out.toString("UTF-8"));
}

public void testObjectOutputStreamXSLSimpleSmokeTest2() throws IOException, TransformerConfigurationException, InterruptedException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
StringReader strs=new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +System.lineSeparator()+
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">" +System.lineSeparator()+
"<xsl:output method=\"xml\" indent=\"yes\" standalone=\"yes\" />" +System.lineSeparator()+
"<xsl:template match=\"@*|node()\">" +System.lineSeparator()+
" <xsl:copy>" +System.lineSeparator()+
" <xsl:apply-templates select=\"@*|node()\"/>" +System.lineSeparator()+
" </xsl:copy>" +System.lineSeparator()+
"</xsl:template>" +System.lineSeparator()+
"<xsl:template match=\"@*|node()\"><xsl:copy><xsl:apply-templates select=\"@*|node()\"/></xsl:copy></xsl:template>" +System.lineSeparator()+
"</xsl:stylesheet>");
DataHolder newDataHolder = xstream.newDataHolder();
final ObjectOutputStream oout = xstream.createObjectOutputStream(out,StandardCharsets.UTF_8,"rootname",new StreamSource(strs),newDataHolder);
oout.writeObject(new Integer(1));
oout.flush();
oout.close();
Assert.assertEquals(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +System.lineSeparator()+
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
"<rootname>" +System.lineSeparator()+
" <int>1</int>" +System.lineSeparator()+
"</rootname>" +System.lineSeparator()+
"", out.toString("UTF-8"));
"</rootname>", out.toString("UTF-8"));
}

public void testObjectOutputStreamXSLGenerateINI() throws IOException, TransformerConfigurationException, InterruptedException {
Expand Down

0 comments on commit 707ca35

Please sign in to comment.