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/DirPool.java gzz/storm/...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/lava gzz/storm/impl/DirPool.java gzz/storm/...
Date: Thu, 14 Nov 2002 16:25:07 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      02/11/14 16:25:06

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

Log message:
        Deleting Storm blocks

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/TransientPool.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/StormPoolTest.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/DirPool.test.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/TransientPool.test.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.5 
gzz/lava/gzz/storm/impl/DirPool.java:1.6
--- gzz/lava/gzz/storm/impl/DirPool.java:1.5    Thu Nov 14 15:43:05 2002
+++ gzz/lava/gzz/storm/impl/DirPool.java        Thu Nov 14 16:25:06 2002
@@ -120,7 +120,9 @@
        os.write(bytes);
        os.close();
     }
-    public void delete(Block b) {}
+    public void delete(Block b) throws IOException {
+       getFile(b.getId()).delete();
+    }
     public Set getIds() {
        HashSet ids = new HashSet();
        String[] list = dir.list();
Index: gzz/lava/gzz/storm/impl/TransientPool.java
diff -u gzz/lava/gzz/storm/impl/TransientPool.java:1.12 
gzz/lava/gzz/storm/impl/TransientPool.java:1.13
--- gzz/lava/gzz/storm/impl/TransientPool.java:1.12     Thu Nov 14 15:43:05 2002
+++ gzz/lava/gzz/storm/impl/TransientPool.java  Thu Nov 14 16:25:06 2002
@@ -111,7 +111,9 @@
 
        blocks.put(block.getId(), block);
     }
-    public void delete(Block b) {}
+    public void delete(Block b) {
+       blocks.keySet().remove(b.getId());
+    }
     public Set getIds() { return blocks.keySet(); }
     public BlockOutputStream getBlockOutputStream(String contentType) 
                                                           throws IOException {
Index: gzz/lava/test/gzz/storm/StormPoolTest.java
diff -u gzz/lava/test/gzz/storm/StormPoolTest.java:1.9 
gzz/lava/test/gzz/storm/StormPoolTest.java:1.10
--- gzz/lava/test/gzz/storm/StormPoolTest.java:1.9      Thu Nov 14 15:43:05 2002
+++ gzz/lava/test/gzz/storm/StormPoolTest.java  Thu Nov 14 16:25:06 2002
@@ -141,13 +141,14 @@
     }
 
     /** Create a new block, check that the ID appears
-     *  in the pool's getIds() set.
+     *  in the pool's getIds() set. Then, delete the block
+     *  and check that the block disappears.
      *  NOTE: getIds() is NOT REQUIRED to return all ids in the pool;
      *  this is implementation-dependent. Obviously, this method
      *  should only be called for pools that guarantee the id to be
      *  in getIds().
      */
-    public void testAddId(StormPool pool) throws IOException {
+    public void testAddRemoveId(StormPool pool) throws IOException {
        Set oldIds = new HashSet(pool.getIds());
 
        BlockOutputStream bos = pool.getBlockOutputStream("text/plain");
@@ -160,6 +161,27 @@
 
        if(!newIds.contains(bos.getBlockId()))
            throw new Error("Id was not added");
+
+       pool.delete(bos.getBlock());
+
+       if(pool.getIds().contains(bos.getBlockId()))
+           throw new Error("Id was not removed");
+    }
+
+    /** Remove a block from the pool.
+     */
+    public void testDelete(StormPool pool) throws IOException {
+       BlockOutputStream bos = pool.getBlockOutputStream("text/plain");
+       bos.close();
+
+       pool.get(bos.getBlockId());
+
+       pool.delete(bos.getBlock());
+
+       try {
+           pool.get(bos.getBlockId());
+           throw new Error();
+       } catch(FileNotFoundException _) {}
     }
 
     /** Add a block and check its id.
Index: gzz/lava/test/gzz/storm/impl/DirPool.test
diff -u gzz/lava/test/gzz/storm/impl/DirPool.test:1.3 
gzz/lava/test/gzz/storm/impl/DirPool.test:1.4
--- gzz/lava/test/gzz/storm/impl/DirPool.test:1.3       Thu Nov 14 15:43:05 2002
+++ gzz/lava/test/gzz/storm/impl/DirPool.test   Thu Nov 14 16:25:06 2002
@@ -27,7 +27,8 @@
 def testNewBlock(): s.testNewBlock(p)
 def testOwnHeader(): s.testOwnHeader(p)
 def testIdsNotNull(): s.testIdsNotNull(p)
-def testAddId(): s.testAddId(p)
+def testAddRemoveId(): s.testAddRemoveId(p)
+def testDelete(): s.testDelete(p)
 def testBlockId(): s.testBlockId(p)
 def testAddBlock(): s.testAddBlock(p)
 def testGetNonexistent(): s.testGetNonexistent(p)
Index: gzz/lava/test/gzz/storm/impl/TransientPool.test
diff -u gzz/lava/test/gzz/storm/impl/TransientPool.test:1.5 
gzz/lava/test/gzz/storm/impl/TransientPool.test:1.6
--- gzz/lava/test/gzz/storm/impl/TransientPool.test:1.5 Thu Nov 14 15:43:05 2002
+++ gzz/lava/test/gzz/storm/impl/TransientPool.test     Thu Nov 14 16:25:06 2002
@@ -19,15 +19,13 @@
 import java, gzz
 
 s = gzz.storm.StormPoolTest()
+p = gzz.storm.impl.TransientPool()
 
-def p():
-    return gzz.storm.impl.TransientPool()
-
-def testNewBlock(): s.testNewBlock(p())
-def testOwnHeader(): s.testOwnHeader(p())
-def testIdsNotNull(): s.testIdsNotNull(p())
-def testAddId(): s.testAddId(p())
-def testBlockId(): s.testBlockId(p())
-def testAddBlock(): s.testAddBlock(p())
-def testGetNonexistent(): s.testGetNonexistent(p())
-
+def testNewBlock(): s.testNewBlock(p)
+def testOwnHeader(): s.testOwnHeader(p)
+def testIdsNotNull(): s.testIdsNotNull(p)
+def testAddRemoveId(): s.testAddRemoveId(p)
+def testDelete(): s.testDelete(p)
+def testBlockId(): s.testBlockId(p)
+def testAddBlock(): s.testAddBlock(p)
+def testGetNonexistent(): s.testGetNonexistent(p)




reply via email to

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