Package org.appng.testsupport.validation
Class WritingXmlValidator
- java.lang.Object
-
- org.appng.testsupport.validation.WritingXmlValidator
-
public class WritingXmlValidator extends Object
Utility class that supports testing if two XML documents have the same content.- Author:
- Matthias Müller
-
-
Field Summary
Fields Modifier and Type Field Description static String
controlFileSource
The default relative path to write control-files to whenwriteXml
istrue
(default:src/test/resources/
).static boolean
logXml
Set totrue
to log the actual XML document (parsed from an JAXB object or aString
) when validating (defaultfalse
).static boolean
writeXml
-
Constructor Summary
Constructors Constructor Description WritingXmlValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
validateXml(String result, File controlFile, boolean trimComment, DifferenceListener differenceListener)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(String result, File controlFile, DifferenceListener differenceListener)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(String result, String controlFile)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(String result, String controlFile, boolean trimComment)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(String result, String controlFile, boolean trimComment, DifferenceListener differenceListener)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(String result, String controlFile, DifferenceListener differenceListener)
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.static void
validateXml(BaseObject object, String controlFile)
Validates that the document represented byobject
is equal to the document parsed from thecontrolFile
.static void
validateXml(BaseObject object, String controlFile, DifferenceListener differenceListener)
Validates that the document represented byobject
is equal to the document parsed from thecontrolFile
.static File
writeToDisk(Object data, String name)
Writes the document represented bydata
to aFile
.static File
writeToDiskPlain(String data, String name)
Writes the document represented bydata
to aFile
.
-
-
-
Field Detail
-
writeXml
public static boolean writeXml
-
logXml
public static boolean logXml
Set totrue
to log the actual XML document (parsed from an JAXB object or aString
) when validating (defaultfalse
).
-
-
Method Detail
-
writeToDisk
public static File writeToDisk(Object data, String name) throws IOException
Writes the document represented bydata
to aFile
.- Parameters:
data
- a JAXB object from packageorg.appng.xml.platform
name
- the path to the file (relative tocontrolFileSource
)- Returns:
- the generated
File
- Throws:
IOException
- if an I/O error occurs while writing the file
-
writeToDiskPlain
public static File writeToDiskPlain(String data, String name) throws IOException
Writes the document represented bydata
to aFile
.- Parameters:
data
- a XML stringname
- the path to the file (relative tocontrolFileSource
)- Returns:
- the generated
File
- Throws:
IOException
- if an I/O error occurs while writing the file
-
validateXml
public static void validateXml(BaseObject object, String controlFile) throws IOException
Validates that the document represented byobject
is equal to the document parsed from thecontrolFile
.- Parameters:
object
- a JAXB object from packageorg.appng.xml.platform
controlFile
- the path to the control file (relative to the classpath)- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(BaseObject object, String controlFile, DifferenceListener differenceListener) throws IOException
Validates that the document represented byobject
is equal to the document parsed from thecontrolFile
.- Parameters:
object
- a JAXB object from packageorg.appng.xml.platform
controlFile
- the path to the control file (relative to the classpath)differenceListener
- an optionalDifferenceListener
that is applied when building theDiff
between the documents- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, String controlFile) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the path to the control file (relative to the classpath)- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, String controlFile, DifferenceListener differenceListener) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the path to the control file (relative to the classpath)differenceListener
- an optionalDifferenceListener
that is applied when building theDiff
between the documents- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, File controlFile, DifferenceListener differenceListener) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the control filedifferenceListener
- an optionalDifferenceListener
that is applied when building theDiff
between the documents- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, String controlFile, boolean trimComment) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the path to the control file (relative to the classpath)trimComment
- set totrue
to un-comment previously commented elements- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, String controlFile, boolean trimComment, DifferenceListener differenceListener) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the path to the control file (relative to the classpath)trimComment
- set totrue
to un-comment previously commented elementsdifferenceListener
- an optionalDifferenceListener
that is applied when building theDiff
between the documents- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
validateXml
public static void validateXml(String result, File controlFile, boolean trimComment, DifferenceListener differenceListener) throws IOException
Validates that the document represented byresult
is equal to the document parsed from thecontrolFile
.- Parameters:
result
- a XML stringcontrolFile
- the control filetrimComment
- set totrue
to un-comment previously commented elementsdifferenceListener
- an optionalDifferenceListener
that is applied when building theDiff
between the documents- Throws:
IOException
- if an I/O error occurs while validatingAssertionError
- if the validation fails
-
-