Class TestHelper


  • public final class TestHelper
    extends Object
    • Constructor Detail

      • TestHelper

        public TestHelper()
    • Method Detail

      • addr

        public static javax.mail.internet.InternetAddress[] addr​(String... addresses)
      • assertBlank

        public static void assertBlank​(String actual)
      • assertNotBlank

        public static void assertNotBlank​(String actual)
      • assertContains

        public static void assertContains​(Iterable<?> expected,
                                          Object actual)
      • assertContains

        public static void assertContains​(String expectedContent,
                                          String value)
      • assertLengthGreaterThan

        public static void assertLengthGreaterThan​(int expectedMinLength,
                                                   CharSequence value)
      • assertContainsEntries

        public static void assertContainsEntries​(Map<Object,​Object> expected,
                                                 Object actual)
      • assertContainsValuesAtKeys

        public static void assertContainsValuesAtKeys​(Set<?> expectedKeys,
                                                      Set<?> expectedValues,
                                                      Object actual)
      • assertHasOneItem

        public static <T> T assertHasOneItem​(Iterable<T> actual)
      • assertSetEquals

        public static void assertSetEquals​(Iterable<?> expected,
                                           Iterable<?> actual)
      • assertEmpty

        public static void assertEmpty​(List<?> actual)
      • assertEmpty

        public static void assertEmpty​(String actual)
      • assertEndsWith

        public static void assertEndsWith​(String expectedSuffix,
                                          String actual)
      • assertIsInstance

        public static <T> T assertIsInstance​(Class<T> clazz,
                                             Object item)
      • assertIsAssignableFrom

        public static <T> Class<? extends T> assertIsAssignableFrom​(Class<T> expectedType,
                                                                    Class<?> actualType)
      • assertIsOrHasCause

        public static <T extends Throwable> T assertIsOrHasCause​(Throwable actual,
                                                                 Class<T> expectedType)
      • assertLinesEqual

        public static void assertLinesEqual​(String expected,
                                            String actual)
      • assertInRange

        public static void assertInRange​(com.google.common.collect.Range<Double> expected,
                                         double actual)
      • assertInRange

        public static void assertInRange​(com.google.common.collect.Range<Float> expected,
                                         float actual)
      • assertInRange

        public static void assertInRange​(com.google.common.collect.Range<Integer> expected,
                                         int actual)
      • assertInRange

        public static void assertInRange​(com.google.common.collect.Range<Long> expected,
                                         long actual)
      • assertSameItems

        public static void assertSameItems​(Object expected,
                                           Object actual)
      • assertHasSize

        public static void assertHasSize​(int expectedSize,
                                         Collection<?> actualCollection)
      • assertStartsWith

        public static void assertStartsWith​(String expectedPrefix,
                                            String actual)
      • assertStreamEquals

        public static void assertStreamEquals​(byte[] expected,
                                              InputStream actual)
      • assertStreamEquals

        public static void assertStreamEquals​(Reader expected,
                                              Reader actual)
      • createTmpFile

        public static File createTmpFile​(byte[] content,
                                         String fileName,
                                         String extension)
                                  throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        fileName - Name of the tmp file
        extension - Extension of the tmp file.
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • createTmpFile

        public static File createTmpFile​(String content,
                                         String fileName,
                                         String extension)
                                  throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        fileName - Name of the tmp file
        extension - Extension of the tmp file.
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • createTmpTextFile

        public static File createTmpTextFile​(String content)
                                      throws IOException
        Creates a file in the temp folder with the specified content
        Parameters:
        content - the file content
        Returns:
        the File instance
        Throws:
        IOException - When the text file could not be created.
      • mailsSorted

        public static List<de.xima.mailserver.api.IMailMessage> mailsSorted​(de.xima.mailserver.api.IMailInbox mailbox)
                                                                     throws de.xima.mailserver.api.MailServerException
        Throws:
        de.xima.mailserver.api.MailServerException
      • map

        public static <K,​V> Map<K,​V> map​(Object... items)
      • orderedMap

        public static <K,​V> Map<K,​V> orderedMap​(Object... items)
      • randomFreePort

        public static int randomFreePort()
      • str

        public static String str​(byte[] bytes)
      • submap

        public static <K,​V> Map<K,​V> submap​(Map<K,​V> map,
                                                        Iterable<?> keys)
      • submap

        @SafeVarargs
        public static <K,​V> Map<K,​V> submap​(Map<K,​V> map,
                                                        K... keys)