Package com.amazonaws.test.util
Class SdkAsserts
java.lang.Object
com.amazonaws.test.util.SdkAsserts
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertFileEqualsFile
(File expected, File actual) Asserts that the contents of the two files are same.static void
assertFileEqualsStream
(File expected, InputStream actual) Asserts that the contents in the specified file are exactly equal to the contents read from the specified input stream.static void
assertFileEqualsStream
(String errmsg, File expected, InputStream actual) Asserts that the contents in the specified file are exactly equal to the contents read from the specified input stream.static void
assertNotEmpty
(String str) Deprecated.Use Hamcrest Matchers insteadstatic void
assertStreamEqualsStream
(InputStream expected, InputStream actual) Asserts that the contents in the specified input streams are same.static void
assertStreamEqualsStream
(String errmsg, InputStream expectedInputStream, InputStream inputStream) Asserts that the contents in the specified input streams are same.static void
assertStringEqualsStream
(String expected, InputStream actual) Asserts that the contents in the specified string are exactly equal to the contents read from the specified input stream.static void
Asserts that the specified AmazonServiceException is valid, meaning it has a non-empty, non-null value for its message, requestId, etc.static boolean
doesFileEqualStream
(File expectedFile, InputStream inputStream) Returns true if, and only if, the contents in the specified file are exactly equal to the contents read from the specified input stream.static boolean
doesStreamEqualStream
(InputStream expected, InputStream actual) Returns true if, and only if, the contents read from the specified input streams are exactly equal.
-
Constructor Details
-
SdkAsserts
public SdkAsserts()
-
-
Method Details
-
assertNotEmpty
Deprecated.Use Hamcrest Matchers insteadAsserts that the specified String is not null and not empty.- Parameters:
str
- The String to test.
-
assertFileEqualsStream
Asserts that the contents in the specified file are exactly equal to the contents read from the specified input stream. The input stream will be closed at the end of this method. If any problems are encountered, or the stream's contents don't match up exactly with the file's contents, then this method will fail the current test.- Parameters:
expected
- The file containing the expected contents.actual
- The stream that will be read, compared to the expected file contents, and finally closed.
-
assertFileEqualsStream
Asserts that the contents in the specified file are exactly equal to the contents read from the specified input stream. The input stream will be closed at the end of this method. If any problems are encountered, or the stream's contents don't match up exactly with the file's contents, then this method will fail the current test.- Parameters:
errmsg
- error message to be thrown when the assertion fails.expected
- The file containing the expected contents.actual
- The stream that will be read, compared to the expected file contents, and finally closed.
-
assertStreamEqualsStream
Asserts that the contents in the specified input streams are same. The input streams will be closed at the end of this method. If any problems are encountered, or the stream's contents don't match up exactly with the file's contents, then this method will fail the current test.- Parameters:
expected
- expected input stream. The stream will be closed at the end.actual
- The stream that will be read, compared to the expected file contents, and finally closed.
-
assertStreamEqualsStream
public static void assertStreamEqualsStream(String errmsg, InputStream expectedInputStream, InputStream inputStream) Asserts that the contents in the specified input streams are same. The input streams will be closed at the end of this method. If any problems are encountered, or the stream's contents don't match up exactly with the file's contents, then this method will fail the current test.- Parameters:
errmsg
- error message to be thrown when the assertion fails.expected
- expected input stream. The stream will be closed at the end.actual
- The stream that will be read, compared to the expected file contents, and finally closed.
-
assertFileEqualsFile
Asserts that the contents of the two files are same.- Parameters:
expected
- expected file.actual
- actual file.
-
assertStringEqualsStream
Asserts that the contents in the specified string are exactly equal to the contents read from the specified input stream. The input stream will be closed at the end of this method. If any problems are encountered, or the stream's contents don't match up exactly with the string's contents, then this method will fail the current test.- Parameters:
expected
- The string containing the expected data.actual
- The stream that will be read, compared to the expected string data, and finally closed.
-
doesStreamEqualStream
public static boolean doesStreamEqualStream(InputStream expected, InputStream actual) throws IOException Returns true if, and only if, the contents read from the specified input streams are exactly equal. Both input streams will be closed at the end of this method.- Parameters:
expected
- The input stream containing the expected contents.inputStream
- The stream that will be read, compared to the expected file contents, and finally closed.- Returns:
- True if the two input streams contain the same data.
- Throws:
IOException
- If any problems are encountered comparing the file and stream.
-
doesFileEqualStream
public static boolean doesFileEqualStream(File expectedFile, InputStream inputStream) throws IOException Returns true if, and only if, the contents in the specified file are exactly equal to the contents read from the specified input stream. The input stream will be closed at the end of this method.- Parameters:
expectedFile
- The file containing the expected contents.inputStream
- The stream that will be read, compared to the expected file contents, and finally closed.- Throws:
IOException
- If any problems are encountered comparing the file and stream.
-
assertValidException
Asserts that the specified AmazonServiceException is valid, meaning it has a non-empty, non-null value for its message, requestId, etc.- Parameters:
e
- The exception to validate.
-