-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jay Bazuzi <[email protected]> Co-authored-by: Llewellyn Falco <[email protected]>
- Loading branch information
1 parent
aa8d2c3
commit 69d5e6c
Showing
5 changed files
with
50 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
approvaltests/src/main/java/org/approvaltests/XmlApprovals.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
approvaltests/src/main/java/org/approvaltests/XmlXomApprovals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.approvaltests; | ||
|
||
import nu.xom.Builder; | ||
import nu.xom.Document; | ||
import nu.xom.Serializer; | ||
import org.approvaltests.core.Options; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.StringReader; | ||
|
||
public class XmlXomApprovals | ||
{ | ||
public static void verifyXml(String xml) | ||
{ | ||
verifyXml(xml, new Options()); | ||
} | ||
public static void verifyXml(String xml, Options options) | ||
{ | ||
Approvals.verifyXml(xml, x -> prettyPrintXml(x, 2), options); | ||
} | ||
public static String prettyPrintXml(String minimizedXml, int indent) | ||
{ | ||
try | ||
{ | ||
Builder builder = new Builder(); | ||
Document doc = builder.build(new StringReader(minimizedXml)); | ||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | ||
Serializer serializer = new Serializer(byteArrayOutputStream, "UTF-8"); | ||
serializer.setIndent(indent); | ||
serializer.setLineSeparator("\n"); | ||
serializer.setMaxLength(0); | ||
serializer.write(doc); | ||
return byteArrayOutputStream.toString("UTF-8"); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
return minimizedXml + "\n\nXML Parsing Error:\n" + e.getMessage(); | ||
} | ||
} | ||
} |