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 and Description
    --- | ---
    `static String` | `controlFileSource` The default relative path to write control-files to when `writeXml` is `true` (default: `src/test/resources/`).
    `static boolean` | `logXml` Set to `true` to log the actual XML document (parsed from an JAXB object or a `String`) when validating (default `false`).
    `static boolean` | `writeXml` Set to `true` to (over)write the control-files on (default `false`) (see also `controlFileSource`).

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WritingXmlValidator()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `validateXml(BaseObject object, String controlFile)` Validates that the document represented by `object` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(BaseObject object, String controlFile, org.custommonkey.xmlunit.DifferenceListener differenceListener)` Validates that the document represented by `object` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, File controlFile, boolean trimComment, org.custommonkey.xmlunit.DifferenceListener differenceListener)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, File controlFile, org.custommonkey.xmlunit.DifferenceListener differenceListener)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, String controlFile)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, String controlFile, boolean trimComment)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, String controlFile, boolean trimComment, org.custommonkey.xmlunit.DifferenceListener differenceListener)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static void` | `validateXml(String result, String controlFile, org.custommonkey.xmlunit.DifferenceListener differenceListener)` Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
    `static File` | `writeToDisk(Object data, String name)` Writes the document represented by `data` to a `File`.
    `static File` | `writeToDiskPlain(String data, String name)` Writes the document represented by `data` to a `File`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### writeXml

          public static boolean writeXml

      Set to `true` to (over)write the control-files on (default `false`) (see also `controlFileSource`).

    - #### logXml

          public static boolean logXml

      Set to `true` to log the actual XML document (parsed from an JAXB object or a `String`) when validating (default `false`).

    - #### controlFileSource

          public static String controlFileSource

      The default relative path to write control-files to when `writeXml` is `true` (default: `src/test/resources/`).

  - ### Constructor Detail

    - #### WritingXmlValidator

          public WritingXmlValidator()

  - ### Method Detail

    - #### writeToDisk

          public static File writeToDisk(Object data,
                                         String name)
                                  throws IOException

      Writes the document represented by `data` to a `File`.
      Parameters:
        `data` - a JAXB object from package `org.appng.xml.platform`
        `name` - the path to the file (relative to `controlFileSource` )
      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 by `data` to a `File`.
      Parameters:
        `data` - a XML string
        `name` - the path to the file (relative to `controlFileSource` )
      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 by `object` is equal to the document parsed from the `controlFile`.
      Parameters:
        `object` - a JAXB object from package `org.appng.xml.platform`
        `controlFile` - the path to the control file (relative to the classpath)
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(BaseObject object,
                                         String controlFile,
                                         org.custommonkey.xmlunit.DifferenceListener differenceListener)
                                  throws IOException

      Validates that the document represented by `object` is equal to the document parsed from the `controlFile`.
      Parameters:
        `object` - a JAXB object from package `org.appng.xml.platform`
        `controlFile` - the path to the control file (relative to the classpath)
        `differenceListener` - an optional `DifferenceListener` that is applied when building the `Diff` between the documents
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         String controlFile)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the path to the control file (relative to the classpath)
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         String controlFile,
                                         org.custommonkey.xmlunit.DifferenceListener differenceListener)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the path to the control file (relative to the classpath)
        `differenceListener` - an optional `DifferenceListener` that is applied when building the `Diff` between the documents
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         File controlFile,
                                         org.custommonkey.xmlunit.DifferenceListener differenceListener)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the control file
        `differenceListener` - an optional `DifferenceListener` that is applied when building the `Diff` between the documents
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         String controlFile,
                                         boolean trimComment)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the path to the control file (relative to the classpath)
        `trimComment` - set to `true` to un-comment previously commented elements
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         String controlFile,
                                         boolean trimComment,
                                         org.custommonkey.xmlunit.DifferenceListener differenceListener)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the path to the control file (relative to the classpath)
        `trimComment` - set to `true` to un-comment previously commented elements
        `differenceListener` - an optional `DifferenceListener` that is applied when building the `Diff` between the documents
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

    - #### validateXml

          public static void validateXml(String result,
                                         File controlFile,
                                         boolean trimComment,
                                         org.custommonkey.xmlunit.DifferenceListener differenceListener)
                                  throws IOException

      Validates that the document represented by `result` is equal to the document parsed from the `controlFile`.
      Parameters:
        `result` - a XML string
        `controlFile` - the control file
        `trimComment` - set to `true` to un-comment previously commented elements
        `differenceListener` - an optional `DifferenceListener` that is applied when building the `Diff` between the documents
      Throws:
        `IOException` - if an I/O error occurs while validating
        `AssertionError` - if the validation fails

Copyright © 2011–2023 aiticon GmbH. All rights reserved.