activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r911055 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/kahadb/plist/PList.java test/java/org/apache/activemq/broker/region/QueuePurgeTest.java test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
Date Wed, 17 Feb 2010 16:29:17 GMT
Author: gtully
Date: Wed Feb 17 16:29:16 2010
New Revision: 911055

URL: http://svn.apache.org/viewvc?rev=911055&view=rev
Log:
fix plist destroy, intermittent failure of src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java?rev=911055&r1=911054&r2=911055&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
Wed Feb 17 16:29:16 2010
@@ -117,10 +117,10 @@
 
     void destroy(Transaction tx) throws IOException {
         // start from the first
-        EntryLocation entry = loadEntry(tx, getRoot(tx).getNext());
+        EntryLocation entry = getFirst(tx);
         while (entry != null) {
             EntryLocation toRemove = entry.copy();
-            entry = loadEntry(tx, entry.getNext());
+            entry = getNext(tx, entry.getNext());
             doRemove(tx, toRemove);
         }
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java?rev=911055&r1=911054&r2=911055&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/region/QueuePurgeTest.java
Wed Feb 17 16:29:16 2010
@@ -137,6 +137,7 @@
         LOG.info("purge done: " + (System.currentTimeMillis() - start) + "ms");
         assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0,
                 proxy.getQueueSize());
+        assertEquals("usage goes to duck", 0, proxy.getMemoryPercentUsage());
     }
 
     private QueueViewMBean getProxyToQueueViewMBean()

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java?rev=911055&r1=911054&r2=911055&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/plist/PListTest.java
Wed Feb 17 16:29:16 2010
@@ -17,11 +17,13 @@
 package org.apache.activemq.store.kahadb.plist;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNull;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
+
 import org.apache.activemq.util.IOHelper;
 import org.apache.kahadb.util.ByteSequence;
 import org.junit.After;
@@ -32,8 +34,6 @@
 
     private PListStore store;
     private PList plist;
-    
-
    
 
     @Test
@@ -82,7 +82,10 @@
 
     @Test
     public void testRemove() throws IOException {
-        final int COUNT = 2000;
+        doTestRemove(2000);
+    }
+    
+    protected void doTestRemove(final int COUNT) throws IOException {            
         Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
         for (int i = 0; i < COUNT; i++) {
             String test = new String("test" + i);
@@ -100,9 +103,26 @@
 
     }
 
-    //@Test
-    public void testDestroy() {
-        fail("Not yet implemented");
+    @Test
+    public void testDestroy() throws Exception {
+        doTestRemove(1);
+        plist.destroy();
+        assertEquals(0,plist.size());
+    }
+    
+    @Test
+    public void testDestroyNonEmpty() throws Exception {
+        final int COUNT = 1000;
+        Map<String, ByteSequence> map = new LinkedHashMap<String, ByteSequence>();
+        for (int i = 0; i < COUNT; i++) {
+            String test = new String("test" + i);
+            ByteSequence bs = new ByteSequence(test.getBytes());
+            map.put(test, bs);
+            plist.addLast(test, bs);
+        }
+        plist.destroy();
+        assertEquals(0,plist.size());
+        assertNull("no first entry", plist.getFirst());
     }
 
     @Before



Mime
View raw message