git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0747c3c
)
Test: add Stream CryptUtils
author
Niki Roo
<niki@nikiroo.be>
Tue, 23 Apr 2019 12:36:13 +0000
(14:36 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Tue, 23 Apr 2019 12:36:13 +0000
(14:36 +0200)
src/be/nikiroo/utils/test_code/CryptUtilsTest.java
patch
|
blob
|
blame
|
history
diff --git
a/src/be/nikiroo/utils/test_code/CryptUtilsTest.java
b/src/be/nikiroo/utils/test_code/CryptUtilsTest.java
index 597650466ef1d1c024d9860b77c52a17317f5e1e..61e18fbb49198ec36240d361a9d16d13a44af7c3 100644
(file)
--- a/
src/be/nikiroo/utils/test_code/CryptUtilsTest.java
+++ b/
src/be/nikiroo/utils/test_code/CryptUtilsTest.java
@@
-1,6
+1,11
@@
package be.nikiroo.utils.test_code;
package be.nikiroo.utils.test_code;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
import be.nikiroo.utils.CryptUtils;
import be.nikiroo.utils.CryptUtils;
+import be.nikiroo.utils.IOUtils;
import be.nikiroo.utils.test.TestCase;
import be.nikiroo.utils.test.TestLauncher;
import be.nikiroo.utils.test.TestCase;
import be.nikiroo.utils.test.TestLauncher;
@@
-127,9
+132,21
@@
class CryptUtilsTest extends TestLauncher {
super(title, args);
this.key = key;
super(title, args);
this.key = key;
- addTest(new TestCase("
TODO: Make some tests with the Streams
") {
+ addTest(new TestCase("
Simple test
") {
@Override
public void test() throws Exception {
@Override
public void test() throws Exception {
+ InputStream in = new ByteArrayInputStream(new byte[] {42, 127, 12});
+ crypt.encryptInputStream(in);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ IOUtils.write(in, out);
+ byte[] result = out.toByteArray();
+
+ assertEquals("We wrote 3 bytes, we expected 3 bytes back but got: "
+ + result.length, result.length, result.length);
+
+ assertEquals(42, result[0]);
+ assertEquals(127, result[1]);
+ assertEquals(12, result[2]);
}
});
}
}
});
}