org.apache.struts2.junit.util

## Class TestUtils

- java.lang.Object
- - org.apache.struts2.junit.util.TestUtils

-     public class TestUtils
      extends Object

  Utility methods for test classes

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TestUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `assertEquals(URL source, String text)`
    `static boolean` | `compare(URL url, String text)` Attempt to verify the contents of text against the contents of the URL specified.
    `static String` | `normalize(String json, boolean removeSpaces)` normalizes a string so that strings generated on different platforms can be compared.
    `static String` | `normalize(URL url)`
    `static String` | `readContent(URL url)`
    `static String` | `readContent(URL url, Charset encoding)`

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

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

- - ### Constructor Detail

    - #### TestUtils

          public TestUtils()

  - ### Method Detail

    - #### normalize

          public static String normalize(String json,
                                         boolean removeSpaces)

      normalizes a string so that strings generated on different platforms can be compared. any group of one or more space, tab, \r, and \n characters are converted to a single space character
      Parameters:
        `json` - the JSON to be normalized. normalize will trim before starting
        `removeSpaces` - removes white spaces from the JSON or not
      Returns:
        the normalized string

    - #### normalize

          public static String normalize(URL url)
                                  throws Exception

      Throws:
        `Exception`

    - #### compare

          public static boolean compare(URL url,
                                        String text)
                                 throws Exception

      Attempt to verify the contents of text against the contents of the URL specified. Performs a trim on both ends
      Parameters:
        `url` - the HTML snippet that we want to validate against
      Throws:
        `Exception` - if the validation failed

    - #### assertEquals

          public static void assertEquals(URL source,
                                          String text)
                                   throws Exception

      Throws:
        `Exception`

    - #### readContent

          public static String readContent(URL url)
                                    throws Exception

      Throws:
        `Exception`

    - #### readContent

          public static String readContent(URL url,
                                           Charset encoding)
                                    throws Exception

      Throws:
        `Exception`

Copyright © 2000–2024 Apache Software Foundation. All rights reserved.