summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-07-17 02:22:32 (GMT)
committerNick Hudson <nick.hudson@isode.com>2015-07-28 13:14:20 (GMT)
commit673655830b0325d964e67fa835ea83f485e9beeb (patch)
tree27e4f8bd20dd9011207641a83212ced393fbada2 /test/com/isode/stroke/compress
parent6f84f6a65b8b80e2f599dff76da0cd13fbead611 (diff)
downloadstroke-673655830b0325d964e67fa835ea83f485e9beeb.zip
stroke-673655830b0325d964e67fa835ea83f485e9beeb.tar.bz2
Complete StreamStack and add tests.
TLSLayer could not be updated because it requires TLS to be ported first. Updates other classes, only for having compatibility with SafeByteArray because of updates in Stream Stack. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for StreamStack and XMPPLayer, which passes. Change-Id: I8707fc1f16d622d2a90f6f39f671b7e7c46aa170
Diffstat (limited to 'test/com/isode/stroke/compress')
-rw-r--r--test/com/isode/stroke/compress/ZLibCompressorTest.java12
-rw-r--r--test/com/isode/stroke/compress/ZLibDecompressorTest.java28
2 files changed, 20 insertions, 20 deletions
diff --git a/test/com/isode/stroke/compress/ZLibCompressorTest.java b/test/com/isode/stroke/compress/ZLibCompressorTest.java
index 5767415..c9d1f69 100644
--- a/test/com/isode/stroke/compress/ZLibCompressorTest.java
+++ b/test/com/isode/stroke/compress/ZLibCompressorTest.java
@@ -9,7 +9,7 @@
*/
package com.isode.stroke.compress;
-import com.isode.stroke.base.ByteArray;
+import com.isode.stroke.base.SafeByteArray;
import com.isode.stroke.stringcodecs.Hexify;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
@@ -27,7 +27,7 @@ public class ZLibCompressorTest {
@Test
public void testProcess() throws Exception {
ZLibCompressor testling = new ZLibCompressor();
- ByteArray result = testling.process(new ByteArray("foo"));
+ SafeByteArray result = testling.process(new SafeByteArray("foo"));
assertEquals("78da4acbcf07000000ffff", Hexify.hexify(result));
}
@@ -35,14 +35,14 @@ public class ZLibCompressorTest {
@Test
public void testProcess_Twice() throws ZLibException {
ZLibCompressor testling = new ZLibCompressor();
- testling.process(new ByteArray("foo"));
- ByteArray result = testling.process(new ByteArray("bar"));
+ testling.process(new SafeByteArray("foo"));
+ SafeByteArray result = testling.process(new SafeByteArray("bar"));
assertEquals("4a4a2c02000000ffff", Hexify.hexify(result));
}
- public static ByteArray unhex(String string) {
+ public static SafeByteArray unhex(String string) {
HexBinaryAdapter adaptor = new HexBinaryAdapter();
- return new ByteArray(adaptor.unmarshal(string));
+ return new SafeByteArray(adaptor.unmarshal(string));
}
}
diff --git a/test/com/isode/stroke/compress/ZLibDecompressorTest.java b/test/com/isode/stroke/compress/ZLibDecompressorTest.java
index f4f5e06..d691363 100644
--- a/test/com/isode/stroke/compress/ZLibDecompressorTest.java
+++ b/test/com/isode/stroke/compress/ZLibDecompressorTest.java
@@ -9,7 +9,7 @@
*/
package com.isode.stroke.compress;
-import com.isode.stroke.base.ByteArray;
+import com.isode.stroke.base.SafeByteArray;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -24,48 +24,48 @@ public class ZLibDecompressorTest {
@Test
public void testProcess() throws ZLibException {
ZLibDecompressor testling = new ZLibDecompressor();
- ByteArray result = testling.process(ZLibCompressorTest.unhex("78da4acbcf07000000ffff"));
+ SafeByteArray result = testling.process(ZLibCompressorTest.unhex("78da4acbcf07000000ffff"));
- assertEquals(new ByteArray("foo"), result);
+ assertEquals(new SafeByteArray("foo"), result);
}
@Test
public void testProcess_Twice() throws ZLibException {
ZLibDecompressor testling = new ZLibDecompressor();
testling.process(ZLibCompressorTest.unhex("78da4acbcf07000000ffff"));
- ByteArray result = testling.process(ZLibCompressorTest.unhex("4a4a2c02000000ffff"));
+ SafeByteArray result = testling.process(ZLibCompressorTest.unhex("4a4a2c02000000ffff"));
- assertEquals(new ByteArray("bar"), result);
+ assertEquals(new SafeByteArray("bar"), result);
}
@Test(expected = ZLibException.class)
public void testProcess_Invalid() throws ZLibException {
ZLibDecompressor testling = new ZLibDecompressor();
- testling.process(new ByteArray("invalid"));
+ testling.process(new SafeByteArray("invalid"));
}
@Test
public void testProcess_Huge() throws ZLibException {
- ByteArray data = new ByteArray();
+ SafeByteArray data = new SafeByteArray();
for (int i = 0; i < 2048; ++i) {
data.append((byte) i);
}
- ByteArray original = new ByteArray(data);
- ByteArray compressed = new ZLibCompressor().process(original);
- ByteArray decompressed = new ZLibDecompressor().process(compressed);
+ SafeByteArray original = new SafeByteArray(data);
+ SafeByteArray compressed = new ZLibCompressor().process(original);
+ SafeByteArray decompressed = new ZLibDecompressor().process(compressed);
assertEquals(original, decompressed);
}
@Test
public void testProcess_ChunkSize() throws ZLibException {
- ByteArray data = new ByteArray();
+ SafeByteArray data = new SafeByteArray();
for (int i = 0; i < 1024; ++i) {
data.append((byte) i);
}
- ByteArray original = new ByteArray(data);
- ByteArray compressed = new ZLibCompressor().process(original);
- ByteArray decompressed = new ZLibDecompressor().process(compressed);
+ SafeByteArray original = new SafeByteArray(data);
+ SafeByteArray compressed = new ZLibCompressor().process(original);
+ SafeByteArray decompressed = new ZLibDecompressor().process(compressed);
assertEquals(original, decompressed);
}