-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IOUtils.toByteArray with generator
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.kloudtek.util.io; | ||
|
||
import com.kloudtek.util.StringUtils; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class IOUtilsTest { | ||
public static final byte[] TESTDATA = StringUtils.utf8("foo"); | ||
|
||
@Test | ||
public void toByteArrayWithGenerator() throws IOException { | ||
byte[] data = IOUtils.toByteArray(new IOUtils.DataGenerator() { | ||
@Override | ||
public void generateData(OutputStream os) throws IOException { | ||
os.write(TESTDATA); | ||
} | ||
}); | ||
assertArrayEquals(TESTDATA,data); | ||
} | ||
} |