Author: manik.surtani(a)jboss.com
Date: 2009-03-01 07:10:33 -0500 (Sun, 01 Mar 2009)
New Revision: 7811
Modified:
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java
Log:
Updated tests to use unclosable streams
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-01
12:05:53 UTC (rev 7810)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-01
12:10:33 UTC (rev 7811)
@@ -2,6 +2,8 @@
import org.easymock.EasyMock;
import org.horizon.Cache;
+import org.horizon.io.UnclosableObjectInputStream;
+import org.horizon.io.UnclosableObjectOutputStream;
import org.horizon.loader.modifications.Clear;
import org.horizon.loader.modifications.Modification;
import org.horizon.loader.modifications.Remove;
@@ -250,13 +252,13 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
- cs.toStream(oos);
+ cs.toStream(new UnclosableObjectOutputStream(oos));
oos.flush();
oos.close();
out.close();
cs.clear();
ObjectInputStream ois = new ObjectInputStream(new
ByteArrayInputStream(out.toByteArray()));
- cs.fromStream(ois);
+ cs.fromStream(new UnclosableObjectInputStream(ois));
Set<StoredEntry> set = cs.loadAll();
@@ -279,7 +281,7 @@
byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};
out.write(dummyStartBytes);
ObjectOutputStream oos = new ObjectOutputStream(out);
- cs.toStream(oos);
+ cs.toStream(new UnclosableObjectOutputStream(oos));
oos.flush();
oos.close();
out.write(dummyEndBytes);
@@ -292,7 +294,7 @@
int bytesRead = in.read(dummy, 0, 8);
assert bytesRead == 8;
for (int i = 1; i < 9; i++) assert dummy[i - 1] == i : "Start byte stream
corrupted!";
- cs.fromStream(new ObjectInputStream(in));
+ cs.fromStream(new UnclosableObjectInputStream(new ObjectInputStream(in)));
bytesRead = in.read(dummy, 0, 8);
assert bytesRead == 8;
for (int i = 8; i > 0; i--) assert dummy[8 - i] == i : "Start byte stream
corrupted!";
Modified:
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-03-01
12:05:53 UTC (rev 7810)
+++
core/branches/flat/src/test/java/org/horizon/loader/decorators/ChainingCacheLoaderTest.java 2009-03-01
12:10:33 UTC (rev 7811)
@@ -1,6 +1,8 @@
package org.horizon.loader.decorators;
import org.easymock.EasyMock;
+import org.horizon.io.UnclosableObjectInputStream;
+import org.horizon.io.UnclosableObjectOutputStream;
import org.horizon.loader.BaseCacheStoreTest;
import org.horizon.loader.CacheLoaderConfig;
import org.horizon.loader.CacheLoaderException;
@@ -237,7 +239,7 @@
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(byteStream);
- cs.toStream(oos);
+ cs.toStream(new UnclosableObjectOutputStream(oos));
oos.close();
byteStream.close();
cs.clear();
@@ -249,7 +251,7 @@
assert !s.containsKey("k2");
}
- cs.fromStream(new ObjectInputStream(new
ByteArrayInputStream(byteStream.toByteArray())));
+ cs.fromStream(new UnclosableObjectInputStream(new ObjectInputStream(new
ByteArrayInputStream(byteStream.toByteArray()))));
assert cs.containsKey("k1");
assert cs.containsKey("k2");
Modified:
core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java 2009-03-01
12:05:53 UTC (rev 7810)
+++
core/branches/flat/src/test/java/org/horizon/loader/file/FileCacheStoreTest.java 2009-03-01
12:10:33 UTC (rev 7811)
@@ -1,5 +1,6 @@
package org.horizon.loader.file;
+import org.horizon.io.UnclosableObjectOutputStream;
import org.horizon.loader.BaseCacheStoreTest;
import org.horizon.loader.CacheLoaderException;
import org.horizon.loader.CacheStore;
@@ -91,7 +92,7 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
- cs.toStream(oos);
+ cs.toStream(new UnclosableObjectOutputStream(oos));
oos.flush();
oos.close();
out.close();
Show replies by date