Class TestHelper
java.lang.Object
de.xima.fc.testhelper.TestHelper
Helper with static utility functions for writing tests.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic javax.mail.internet.InternetAddress[]Parses the given strings intoInternetAddressinstances.static <T> T[]array(T... items) Shortcut for creating an array of items.static <T extends Comparable<T>>
voidassertAfter(T expected, T actual) Asserts that the given value is after the expected value (i.e. greater than the expected value).static <T extends Comparable<T>>
voidassertBefore(T expected, T actual) Asserts that the given value is before the expected value (i.e. less than the expected value).static <T extends Comparable<T>>
voidassertBetween(T expectedFrom, T expecterAfter, T actual) Asserts that the given value is between the expected from and expected after values (i.e. greater than the expected from value and less than the expected after value).static voidassertBlank(String actual) Asserts that the given string is blank.static voidassertContains(Iterable<?> expected, Iterable<?> actual) Asserts actual items contain the expected items.static voidassertContains(String expectedContent, String value) Asserts that the given string contains the expected content.static voidassertContainsEntries(Map<Object, Object> expected, Object actual) Asserts the given value is a map entry and that the expected map contains a key-value pair with the same key and value.static voidassertContainsValuesAtKeys(Set<?> expectedKeys, Set<?> expectedValues, Object actual) Asserts that the given value is aMapand that it contains the expected keys and values.static voidassertEmpty(Iterable<?> actual) Asserts that the given iterable is empty.static voidassertEmpty(String actual) Asserts that the given string is empty.static voidassertEndsWith(String expectedSuffix, String actual) Asserts that the given string ends with the expected suffix.static voidassertEqualsAsJson(Object expected, Object actual) Serializes both objects to JSON, then structurally compares those JSON values.static voidassertEqualsAsJson(Object expected, Object actual, String message) Serializes both objects to JSON, then structurally compares those JSON values.static voidassertEqualsIgnoreCase(String expected, String actual) Asserts that the actual value is equal to the expected value, ignoring the case.static voidAsserts the given HTML is W3C conform, without any errors, warnings or fatal errors.static voidassertFullyConformingHtml(String html, de.xima.nu_validator.wrapper.bridge.api.INuValidator validator) Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.static voidassertFullyConformingHtml(String html, de.xima.nu_validator.wrapper.bridge.api.INuValidator validator, Consumer<de.xima.nu_validator.wrapper.common.api.INuValidatorOptionsBuilder> configurator) Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.static voidassertFullyConformingHtml(String html, Consumer<de.xima.nu_validator.wrapper.common.api.INuValidatorOptionsBuilder> configurator) Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.static voidassertHasLength(int expectedLength, CharSequence value) Asserts the given string has the expected length.static <T> TassertHasOneItem(Iterable<T> actual) Asserts that the given iterable has exactly one item, and returns that item.static voidassertHasSize(int expectedSize, Collection<?> actualCollection) Asserts the given collection has the expected size.static voidassertInRange(com.google.common.collect.Range<Double> expected, double actual) Asserts that the actual numerical value is within the expected range.static voidassertInRange(com.google.common.collect.Range<Float> expected, float actual) Asserts that the actual numerical value is within the expected range.static voidassertInRange(com.google.common.collect.Range<Integer> expected, int actual) Asserts that the actual numerical value is within the expected range.static voidassertInRange(com.google.common.collect.Range<Long> expected, long actual) Asserts that the actual numerical value is within the expected range.static <T> Class<? extends T> assertIsAssignableFrom(Class<T> expectedType, Class<?> actualType) Asserts that the actual type is assignable to the expected type.static <T> TassertIsInstance(Class<T> clazz, Object item) Deprecated.static <T extends Throwable>
TassertIsOrHasCause(Class<T> expectedType, Throwable actual) Asserts that the given throwable is of the given type or has a throwable of that type somewhere in its chain of causes.static <T extends Throwable>
TassertIsOrHasCause(Throwable actual, Class<T> expectedType) Deprecated.static voidassertLengthGreaterThan(int expectedMinLength, CharSequence value) Asserts that the given string's length is greater than the expected minimum length.static voidassertLinesEqual(String expected, String actual) Splits both strings into lines, trims them, and compares them line by line.static StringassertMessageContains(String expectedContent, Throwable throwable) Asserts that the given throwable's message contains the expected content, and returns the message.static voidassertNoneEquals(Iterable<?> unexpected, Object actual) Asserts that the actual item is not equal to any of the unexpected items.static voidassertNotBlank(String actual) Asserts that the given string is blank.static voidassertNotContains(Iterable<?> unexpected, Iterable<?> actual) Asserts that the actual items do not contain the unexpected items.static voidassertNotEmpty(byte[] value) Asserts that the given byte array is not null and not empty.static voidassertNotEmpty(byte[] value, String message) Asserts that the given byte array is not null and not empty.static voidassertSameItems(Object expected, Object actual) Asserts that both given values are collections with the same items, regardless of the order.static voidassertSetEquals(Iterable<?> expected, Iterable<?> actual) Asserts that both iterables contain the same items, regardless of the order.static voidassertStartsWith(String expectedPrefix, String actual) Asserts that the given string starts with the expected prefix.static voidassertStreamEquals(byte[] expected, InputStream actual) Asserts that the data from the given input stream equals the expected data.static voidassertStreamEquals(InputStream expected, byte[] actual) Asserts that the data from the given input stream equals the expected data.static voidassertStreamEquals(InputStream expected, InputStream actual) Asserts that the data from the given input stream equals the expected data.static voidassertStreamEquals(Reader expected, Reader actual) Asserts that the data from the given reader equals the expected data.static <T extends Throwable>
TassertThrows(Class<T> expectedType, org.junit.jupiter.api.function.Executable executable) Asserts that the given executable throws a throwable of the expected type.static ThrowableassertThrows(org.junit.jupiter.api.function.Executable executable) Asserts that the given executable throws any throwable.static voidassertZipContent(String expectedContent, Map<String, byte[]> zip, String path) Asserts that the given zip content contains a file with the given path and that the content of that file equals the expected content.static byte[]classpathResourceBinary(String resourcePath) Reads a resource from the class path as binary data.static StringclasspathResourcePlainText(String resourcePath) Reads a resource from the class path as a plain text string, using UTF-8 encoding.static FileCreates a temporary directory.static FilecreateTmpFile(byte[] content, String fileName, String extension) Creates a file in the temp folder with the specified contentstatic FilecreateTmpFile(String content, String fileName, String extension) Creates a file in the temp folder with the specified contentstatic FilecreateTmpTextFile(String content) Creates a file in the temp folder with the specified contentstatic com.alibaba.fastjson.JSONObjectgetZipContentAsJson(Map<String, byte[]> exportContent, String path) static StringgetZipContentAsText(Map<String, byte[]> exportContent, String path) static <T> List<T> list(T... items) Shortcut for creating a list of items.static <T> List<T[]> listOfArrays(T[]... items) Creates a list of arrays from the given arrays.static List<de.xima.mailserver.api.IMailMessage> mailsSorted(de.xima.mailserver.api.IMailInbox mailbox) Gets all mails from the given inbox, sorted by recipient.static <K,V> Map <K, V> Shortcut for creating a map with arbitrary key-value pairs.static IUserDeprecated.static <K,V> Map <K, V> orderedMap(Object... items) Same asmap(Object...), but uses aLinkedHashMapimplementation that preserves the order of the key-value pairs.static intFinds a random port that is not in use by the current operating system.static BufferedImagereadBufferedImage(byte[] data, String formatName) Reads a buffered image from the given byte array using the given format name.static <T> Set<T> set(T... items) Shortcut for creating a set of items.static Stringstr(byte[] bytes) Decodes the given byte array to a string using UTF-8 encoding.static <K,V> Map <K, V> Creates a map with the data from the given map, but limited to the given keys.static <K,V> Map <K, V> Creates a map with the data from the given map, but limited to the given keys.unzipInMemory(byte[] zipFile) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(byte[] zipFile, String password) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(File zipFile) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(File zipFile, String password) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(InputStream zipFile) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(InputStream zipFile, String password) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(Path zipFile) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.unzipInMemory(Path zipFile, String password) Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.
-
Constructor Details
-
TestHelper
public TestHelper()
-
-
Method Details
-
addr
Parses the given strings intoInternetAddressinstances. The strings may contain multiple addresses separated by commas. The addresses are sorted by their string representation.- Parameters:
addresses- Addresses to parse.- Returns:
- An array of
InternetAddressinstances.
-
array
Shortcut for creating an array of items.- Type Parameters:
T- Type of the items.- Parameters:
items- Items to be added to the array.- Returns:
- An array with the items.
-
assertAfter
Asserts that the given value is after the expected value (i.e. greater than the expected value).- Parameters:
expected- The expected value that should be before the actual value.actual- The actual value that should be after the expected value.
-
assertBefore
Asserts that the given value is before the expected value (i.e. less than the expected value).- Parameters:
expected- The expected value that should be after the actual value.actual- The actual value that should be before the expected value.
-
assertBetween
public static <T extends Comparable<T>> void assertBetween(T expectedFrom, T expecterAfter, T actual) Asserts that the given value is between the expected from and expected after values (i.e. greater than the expected from value and less than the expected after value).- Parameters:
expectedFrom- The expected value that should be before the actual value.expecterAfter- The expected value that should be after the actual value.actual- The actual value that should be between the expected from and expected after values.
-
assertBlank
Asserts that the given string is blank.- Parameters:
actual- The string to check.
-
assertContains
Asserts actual items contain the expected items. It may contain other items as well.- Parameters:
expected- Expected items that should be contained in the actual items.actual- Actual items that should contain the expected items.
-
assertContains
-
assertContainsEntries
-
assertContainsValuesAtKeys
-
assertEmpty
Asserts that the given iterable is empty.- Parameters:
actual- The actual value.
-
assertEmpty
Asserts that the given string is empty.- Parameters:
actual- The actual value.
-
assertEndsWith
-
assertEqualsAsJson
Serializes both objects to JSON, then structurally compares those JSON values. Useful when you have e.g. different map or list implementation with a bad equals implementation; or anything containing arrays (arrays do not implement equals in a way that compares their contents).The values can be either (a) a serialized JSON value as a
String, (b) a byte[] containing a serialized JSON value, or (c) any other object that can be serialized to JSON.- Parameters:
expected- Expected value.actual- Actual value.
-
assertEqualsAsJson
Serializes both objects to JSON, then structurally compares those JSON values. Useful when you have e.g. different map or list implementation with a bad equals implementation; or anything containing arrays (arrays do not implement equals in a way that compares their contents).The values can be either (a) a serialized JSON value as a
String, (b) a byte[] containing a serialized JSON value, or (c) any other object that can be serialized to JSON.- Parameters:
expected- Expected value.actual- Actual value.message- Message to show when the assertion fails.
-
assertEqualsIgnoreCase
-
assertFullyConformingHtml
public static void assertFullyConformingHtml(String html) throws de.xima.nu_validator.wrapper.bridge.api.NuValidatorException Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.- Parameters:
html- The HTML to validate.- Throws:
de.xima.nu_validator.wrapper.bridge.api.NuValidatorException- When the HTML could not be validated.
-
assertFullyConformingHtml
public static void assertFullyConformingHtml(String html, Consumer<de.xima.nu_validator.wrapper.common.api.INuValidatorOptionsBuilder> configurator) throws de.xima.nu_validator.wrapper.bridge.api.NuValidatorException Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.- Parameters:
html- The HTML to validate.configurator- Configurator for the options to use for validation.- Throws:
de.xima.nu_validator.wrapper.bridge.api.NuValidatorException- When the HTML could not be validated.
-
assertFullyConformingHtml
public static void assertFullyConformingHtml(String html, de.xima.nu_validator.wrapper.bridge.api.INuValidator validator) throws de.xima.nu_validator.wrapper.bridge.api.NuValidatorException Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.- Parameters:
html- The HTML to validate.validator- Validator to use for validation.- Throws:
de.xima.nu_validator.wrapper.bridge.api.NuValidatorException- When the HTML could not be validated.
-
assertFullyConformingHtml
public static void assertFullyConformingHtml(String html, de.xima.nu_validator.wrapper.bridge.api.INuValidator validator, Consumer<de.xima.nu_validator.wrapper.common.api.INuValidatorOptionsBuilder> configurator) throws de.xima.nu_validator.wrapper.bridge.api.NuValidatorException Asserts the given HTML is W3C conform, without any errors, warnings or fatal errors.- Parameters:
html- The HTML to validate.validator- Validator to use for validation.configurator- Configurator for the options to use for validation.- Throws:
de.xima.nu_validator.wrapper.bridge.api.NuValidatorException- When the HTML could not be validated.
-
assertHasLength
Asserts the given string has the expected length.- Parameters:
expectedLength- Expected length.value- String to check.
-
assertHasOneItem
Asserts that the given iterable has exactly one item, and returns that item.- Type Parameters:
T- Type of the item.- Parameters:
actual- The actual iterable.- Returns:
- The single item in the iterable.
-
assertHasSize
Asserts the given collection has the expected size.- Parameters:
expectedSize- Expected size.actualCollection- Actual collection.
-
assertInRange
Asserts that the actual numerical value is within the expected range.- Parameters:
expected- The expected range.actual- The actual value.
-
assertInRange
Asserts that the actual numerical value is within the expected range.- Parameters:
expected- The expected range.actual- The actual value.
-
assertInRange
Asserts that the actual numerical value is within the expected range.- Parameters:
expected- The expected range.actual- The actual value.
-
assertInRange
Asserts that the actual numerical value is within the expected range.- Parameters:
expected- The expected range.actual- The actual value.
-
assertIsAssignableFrom
public static <T> Class<? extends T> assertIsAssignableFrom(Class<T> expectedType, Class<?> actualType) Asserts that the actual type is assignable to the expected type.- Type Parameters:
T- Expected type.- Parameters:
expectedType- Expected type.actualType- Actual type.- Returns:
- The actual type cast to the expected type.
-
assertIsInstance
Deprecated.UseAssertions.assertInstanceOf(Class, Object).Checks that the given value is an instance of the expected class.- Type Parameters:
T- Expected type.- Parameters:
clazz- Expected class.item- Instance to check.- Returns:
- The instance cast to the expected class.
-
assertIsOrHasCause
@Deprecated public static <T extends Throwable> T assertIsOrHasCause(Throwable actual, Class<T> expectedType) Deprecated.Asserts that the given throwable is of the given type or has a throwable of that type somewhere in its chain of causes.- Type Parameters:
T- Expected type.- Parameters:
actual- The actual throwable.expectedType- The expected type.- Returns:
- The throwable of the expected type.
-
assertIsOrHasCause
Asserts that the given throwable is of the given type or has a throwable of that type somewhere in its chain of causes.- Type Parameters:
T- Expected type.- Parameters:
expectedType- The expected type.actual- The actual throwable.- Returns:
- The throwable of the expected type.
-
assertLengthGreaterThan
Asserts that the given string's length is greater than the expected minimum length.- Parameters:
expectedMinLength- The expected minimum length.value- The string to check.
-
assertLinesEqual
Splits both strings into lines, trims them, and compares them line by line. Useful when you have e.g. different line endings or leading/trailing whitespace. Line terminators are line feed (LF), carriage return (CR), or carriage return followed by line feed (CRLF).- Parameters:
expected- Expected lines.actual- Actual lines.
-
assertMessageContains
Asserts that the given throwable's message contains the expected content, and returns the message.- Parameters:
expectedContent- The expected content.throwable- The throwable to check.- Returns:
- The message of the throwable.
-
assertNoneEquals
Asserts that the actual item is not equal to any of the unexpected items.- Parameters:
unexpected- Unexpected items of which none should be equal to the actual item.actual- Actual item that should not be equal to any of the unexpected items.
-
assertNotBlank
Asserts that the given string is blank.- Parameters:
actual- The string to check.
-
assertNotContains
-
assertNotEmpty
public static void assertNotEmpty(byte[] value) Asserts that the given byte array is not null and not empty.- Parameters:
value- The byte array to check.
-
assertNotEmpty
Asserts that the given byte array is not null and not empty.- Parameters:
value- The byte array to check.
-
assertSameItems
-
assertSetEquals
-
assertStartsWith
-
assertStreamEquals
Asserts that the data from the given input stream equals the expected data.- Parameters:
expected- Expected data.actual- Input stream to check.
-
assertStreamEquals
Asserts that the data from the given input stream equals the expected data.- Parameters:
expected- Expected data.actual- Data to check.
-
assertStreamEquals
Asserts that the data from the given input stream equals the expected data.- Parameters:
expected- Input stream with the expected data.actual- Input stream to check.
-
assertStreamEquals
-
assertThrows
Asserts that the given executable throws any throwable.- Parameters:
executable- The executable that should throw a throwable.- Returns:
- The thrown throwable.
-
assertThrows
public static <T extends Throwable> T assertThrows(Class<T> expectedType, org.junit.jupiter.api.function.Executable executable) Asserts that the given executable throws a throwable of the expected type.- Type Parameters:
T- The type of the expected throwable.- Parameters:
expectedType- The expected type of the thrown throwable.executable- The executable that should throw a throwable of the expected type.- Returns:
- The thrown throwable of the expected type.
-
assertZipContent
Asserts that the given zip content contains a file with the given path and that the content of that file equals the expected content.- Parameters:
expectedContent- The expected content of the file in the zip.zip- The zip content as a map of file paths to their content as byte arrays.path- The path of the file in the zip to check.
-
classpathResourceBinary
Reads a resource from the class path as binary data.- Parameters:
resourcePath- Path to the resource, with or without a leading slash.- Returns:
- The content of the resource as binary data.
-
classpathResourcePlainText
-
createTmpDir
Creates a temporary directory. Make sure to delete it once you're done with it!- Returns:
- The temporary directory.
- Throws:
IOException- When the directory could not be created.
-
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 contentfileName- Name of the tmp fileextension- Extension of the tmp file.- Returns:
- the
Fileinstance - 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 contentfileName- Name of the tmp fileextension- Extension of the tmp file.- Returns:
- the
Fileinstance - Throws:
IOException- When the text file could not be created.
-
createTmpTextFile
Creates a file in the temp folder with the specified content- Parameters:
content- the file content- Returns:
- the
Fileinstance - Throws:
IOException- When the text file could not be created.
-
getZipContentAsJson
-
getZipContentAsText
-
list
Shortcut for creating a list of items.- Type Parameters:
T- Type of the items.- Parameters:
items- Items to be added to the list.- Returns:
- A list of the items.
-
listOfArrays
Creates a list of arrays from the given arrays. You could also uselist(Object...)but when that method is used with a single array, it will create a list of the array elements instead of a list of arrays.- Type Parameters:
T- Type of the array elements.- Parameters:
items- Arrays to be added to the list.- Returns:
- A list of arrays.
-
mailsSorted
public static List<de.xima.mailserver.api.IMailMessage> mailsSorted(de.xima.mailserver.api.IMailInbox mailbox) throws de.xima.mailserver.api.MailServerException Gets all mails from the given inbox, sorted by recipient.- Parameters:
mailbox- Mailbox to get the mails from.- Returns:
- A list of all mails in the mailbox, sorted by recipient.
- Throws:
de.xima.mailserver.api.MailServerException- When the mails could not be retrieved.
-
map
Shortcut for creating a map with arbitrary key-value pairs. The number of arguments must be even. In comparison withMap.of(), this method allows for more than 10 key-value pairs, but at the cost of giving up type safety. This usually isn't a problem in tests, but if you need type safety, you should useMap.of()instead.- Type Parameters:
K- Type of the keys.V- Type of the values.- Parameters:
items- Key-value pairs to be added to the map.- Returns:
- A map with the key-value pairs.
-
mockUser
Deprecated.- Parameters:
name- Name of the user, unused.- Returns:
- An anonymous virtual user.
-
orderedMap
Same asmap(Object...), but uses aLinkedHashMapimplementation that preserves the order of the key-value pairs. Creates a map with arbitrary key-value pairs. The number of arguments must be even.- Type Parameters:
K- Type of the keys.V- Type of the values.- Parameters:
items- Key-value pairs to be added to the map.- Returns:
- A map with the key-value pairs.
-
randomFreePort
public static int randomFreePort()Finds a random port that is not in use by the current operating system. Note that there is no guarantee that the port will still be free after this method returns, when some application binds to it in the meantime.- Returns:
- A random free port.
-
readBufferedImage
Reads a buffered image from the given byte array using the given format name.- Parameters:
data- Byte array with the image data.formatName- Format name of the image, e.g. "png" or "jpeg".- Returns:
- The buffered image.
- Throws:
IOException- When the image could not be read.
-
set
Shortcut for creating a set of items.- Type Parameters:
T- Type of the items.- Parameters:
items- Items to be added to the set.- Returns:
- A set with the items.
-
str
Decodes the given byte array to a string using UTF-8 encoding.- Parameters:
bytes- Byte array to decode.- Returns:
- The decoded string.
-
submap
Creates a map with the data from the given map, but limited to the given keys.- Type Parameters:
K- Type of the keys.V- Type of the values.- Parameters:
map- Map to get the data from.keys- Keys to include in the new map.- Returns:
- A map with the data from the given map, but limited to the given keys.
-
submap
Creates a map with the data from the given map, but limited to the given keys.- Type Parameters:
K- Type of the keys.V- Type of the values.- Parameters:
map- Map to get the data from.keys- Keys to include in the new map.- Returns:
- A map with the data from the given map, but limited to the given keys.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The zip file to unzip.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The zip file to unzip.password- The password to use for unzipping the zip file, if it is password protected.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The zip file as a byte array to unzip.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The zip file as a byte array to unzip.password- The password to use for unzipping the zip file, if it is password protected.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The path to the zip file to unzip.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The path to the zip file to unzip.password- The password to use for unzipping the zip file, if it is password protected.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The input stream of the zip file to unzip.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
unzipInMemory
public static Map<String,byte[]> unzipInMemory(InputStream zipFile, String password) throws IOException Unzips the given zip file into memory and returns a map of file paths to their content as byte arrays.- Parameters:
zipFile- The input stream of the zip file to unzip.password- The password to use for unzipping the zip file, if it is password protected.- Returns:
- A map of file paths to their content as byte arrays.
- Throws:
IOException- When the zip file could not be read.
-
Assertions.assertInstanceOf(Class, Object).