gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/lava gzz/storm/impl/TransientPool.java test...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava gzz/storm/impl/TransientPool.java test...
Date: Sat, 18 Jan 2003 19:24:36 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      03/01/18 19:24:36

Modified files:
        lava/gzz/storm/impl: TransientPool.java 
        lava/test/gzz/storm: StormPoolTest.java 

Log message:
        Have it: Calling .close() on a BlockOutputStream twice wasn't tested

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/TransientPool.java.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/StormPoolTest.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/storm/impl/TransientPool.java
diff -u gzz/lava/gzz/storm/impl/TransientPool.java:1.24 
gzz/lava/gzz/storm/impl/TransientPool.java:1.25
--- gzz/lava/gzz/storm/impl/TransientPool.java:1.24     Tue Jan 14 10:43:06 2003
+++ gzz/lava/gzz/storm/impl/TransientPool.java  Sat Jan 18 19:24:36 2003
@@ -41,18 +41,14 @@
      */
     protected Map dbs;
 
-    protected class TransientBlockOutputStream extends 
AbstractBlockOutputStream
-
-{
-        protected ByteArrayOutputStream baos;
-
+    protected class TransientBlockOutputStream extends 
AbstractBlockOutputStream {
        protected TransientBlockOutputStream(Header822 header)
                                                      throws IOException {
             super(new ByteArrayOutputStream(), header);
-           baos = (ByteArrayOutputStream)out;
         }
 
        public void close() throws IOException {
+           ByteArrayOutputStream baos = (ByteArrayOutputStream)out;
            block = new TransientBlock(makeIdFromDigest(),
                                       baos.toByteArray(), header);
            blocks.put(block.getId(), block);
@@ -69,6 +65,8 @@
                                 Header822 header) throws IOException {
            super(id, header);
             this.bytes = bytes;
+
+           id.check(bytes);
        }
 
        public InputStream getRawInputStream() throws IOException {
Index: gzz/lava/test/gzz/storm/StormPoolTest.java
diff -u gzz/lava/test/gzz/storm/StormPoolTest.java:1.15 
gzz/lava/test/gzz/storm/StormPoolTest.java:1.16
--- gzz/lava/test/gzz/storm/StormPoolTest.java:1.15     Sat Jan 18 18:56:36 2003
+++ gzz/lava/test/gzz/storm/StormPoolTest.java  Sat Jan 18 19:24:36 2003
@@ -79,6 +79,23 @@
        pool.add(bos.getBlock());
     }
 
+    /** Test closing the same BlockOutputStream twice.
+     */
+    public void testCloseTwice(StormPool pool) throws IOException {
+       BlockOutputStream bos = pool.getBlockOutputStream("text/plain");
+       bos.write(0x01);
+       bos.close();
+       bos.close();
+
+
+       Block block = bos.getBlock();
+       block.getId().check(CopyUtil.readBytes(block.getRawInputStream()));
+       InputStream in = block.getInputStream();
+       if(in.read() != 0x01) throw new Error();
+       if(in.read() >= 0) throw new Error();
+       in.close();
+    }
+
     /** Test creating a block with our own header.
      */
     public void testOwnHeader(StormPool pool) throws IOException {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]