sk.baka.ambient.commons
Class TestUtils

java.lang.Object
  extended by sk.baka.ambient.commons.TestUtils

public final class TestUtils
extends java.lang.Object

Test utilities.

Author:
Martin Vysny

Method Summary
static
<T> void
compareLists(java.util.Collection<? extends T> expected, java.util.Collection<? extends T> got)
          Compares given collection as lists, item by item.
static
<T> void
compareSets(java.util.Collection<? extends T> expected, java.util.Collection<? extends T> got)
          Compares given collection as sets.
static java.io.InputStream stringToInputStream(java.lang.String str, java.lang.String encoding)
          Converts given string to a byte array and returns an input stream.
static byte[] toAscii(java.lang.String str)
          Converts given string char-by-char to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toAscii

public static byte[] toAscii(java.lang.String str)
Converts given string char-by-char to a byte array. Each char is converted to a single byte. Only characters 0-127 are accepted.

Parameters:
str - the string to convert.
Returns:
the byte array.

stringToInputStream

public static java.io.InputStream stringToInputStream(java.lang.String str,
                                                      java.lang.String encoding)
                                               throws java.io.UnsupportedEncodingException
Converts given string to a byte array and returns an input stream.

Parameters:
str - the string to convert.
encoding - the encoding
Returns:
the byte array.
Throws:
java.io.UnsupportedEncodingException

compareLists

public static <T> void compareLists(java.util.Collection<? extends T> expected,
                                    java.util.Collection<? extends T> got)
Compares given collection as lists, item by item. Ordering does matter.

Type Parameters:
T - the item type
Parameters:
expected - expected list
got - actual list.

compareSets

public static <T> void compareSets(java.util.Collection<? extends T> expected,
                                   java.util.Collection<? extends T> got)
Compares given collection as sets. Ordering does not matter.

Type Parameters:
T - the item type
Parameters:
expected - expected list
got - actual list.


Copyright © 2007-2009. All Rights Reserved.