You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2006/03/21 18:22:06 UTC

svn commit: r387586 [3/3] - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/kaha/ main/java/org/apache/activemq/kaha/impl/ main/java/org/apache/activemq/store/kahadaptor/ test/java/org/apache/activemq/kaha/

Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java (added)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,92 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.activemq.store.kahadaptor;
+
+import java.io.IOException;
+import java.util.Iterator;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.Message;
+import org.apache.activemq.command.MessageAck;
+import org.apache.activemq.command.MessageId;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.store.MessageRecoveryListener;
+import org.apache.activemq.store.MessageStore;
+/**
+ * An implementation of {@link org.apache.activemq.store.MessageStore} which uses a JPS Container
+ * 
+ * @version $Revision: 1.7 $
+ */
+public class KahaMessageStore implements MessageStore{
+    protected final ActiveMQDestination destination;
+    protected final MapContainer messageContainer;
+
+    public KahaMessageStore(MapContainer container,ActiveMQDestination destination) throws IOException{
+        this.messageContainer=container;
+        this.destination=destination;
+    }
+
+    public void addMessage(ConnectionContext context,Message message) throws IOException{
+        messageContainer.put(message.getMessageId().toString(),message);
+    }
+
+    public void addMessageReference(ConnectionContext context,MessageId messageId,long expirationTime,String messageRef)
+                    throws IOException{
+        messageContainer.put(messageId.toString(),messageRef);
+    }
+
+    public Message getMessage(MessageId identity) throws IOException{
+        return (Message) messageContainer.get(identity.toString());
+    }
+
+    public String getMessageReference(MessageId identity) throws IOException{
+        return (String) messageContainer.get(identity.toString());
+    }
+
+    public void removeMessage(ConnectionContext context,MessageAck ack) throws IOException{
+        messageContainer.remove(ack.getLastMessageId().toString());
+    }
+
+    public void removeMessage(MessageId msgId) throws IOException{
+        messageContainer.remove(msgId.toString());
+    }
+
+    public void recover(MessageRecoveryListener listener) throws Exception{
+        for(Iterator iter=messageContainer.values().iterator();iter.hasNext();){
+            Object msg=(Object) iter.next();
+            if(msg.getClass()==String.class){
+                listener.recoverMessageReference((String) msg);
+            }else{
+                listener.recoverMessage((Message) msg);
+            }
+        }
+        listener.finished();
+    }
+
+    public void start() throws IOException{}
+
+    public void stop(long timeout) throws IOException{}
+
+    public void removeAllMessages(ConnectionContext context) throws IOException{
+        messageContainer.clear();
+    }
+
+    public ActiveMQDestination getDestination(){
+        return destination;
+    }
+
+    public void delete(){
+        messageContainer.clear();
+    }
+}

Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaMessageStore.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java (added)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,151 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.activemq.store.kahadaptor;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import org.activeio.command.WireFormat;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StoreFactory;
+import org.apache.activemq.kaha.StringMarshaller;
+import org.apache.activemq.openwire.OpenWireFormat;
+import org.apache.activemq.store.MessageStore;
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.TopicMessageStore;
+import org.apache.activemq.store.TransactionStore;
+import org.apache.activemq.store.memory.MemoryTransactionStore;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+/**
+ * @org.apache.xbean.XBean
+ * 
+ * @version $Revision: 1.4 $
+ */
+public class KahaPersistentAdaptor implements PersistenceAdapter{
+    MemoryTransactionStore transactionStore;
+    ConcurrentHashMap topics=new ConcurrentHashMap();
+    ConcurrentHashMap queues=new ConcurrentHashMap();
+    private boolean useExternalMessageReferences;
+    private WireFormat wireFormat = new OpenWireFormat();
+    Store store;
+
+    public KahaPersistentAdaptor(File dir) throws IOException{
+        if (!dir.exists()){
+            dir.mkdirs();
+        }
+        String name = dir.getAbsolutePath() + File.separator + "kaha.db";
+        store=StoreFactory.open(name,"rw");
+        
+    }
+
+    public Set getDestinations(){
+        Set rc=new HashSet();
+        for(Iterator i=store.getMapContainerIds().iterator();i.hasNext();){
+            Object obj=i.next();
+            if(obj instanceof ActiveMQDestination){
+                rc.add(obj);
+            }
+        }
+        return rc;
+    }
+
+    public synchronized MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException{
+        MessageStore rc=(MessageStore) queues.get(destination);
+        if(rc==null){
+            rc=new KahaMessageStore(getMapContainer(destination),destination);
+            if(transactionStore!=null){
+                rc=transactionStore.proxy(rc);
+            }
+            queues.put(destination,rc);
+        }
+        return rc;
+    }
+
+    public synchronized TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException{
+        TopicMessageStore rc=(TopicMessageStore) topics.get(destination);
+        if(rc==null){
+            MapContainer messageContainer=getMapContainer(destination);
+            MapContainer subsContainer=getMapContainer(destination.toString()+"-Subscriptions");
+            MapContainer ackContainer=store.getMapContainer(destination.toString()+"-Acks");
+            ackContainer.setKeyMarshaller(new StringMarshaller());
+            ackContainer.setValueMarshaller(new AtomicIntegerMarshaller());
+            ackContainer.load();
+            rc=new KahaTopicMessageStore(store,messageContainer,ackContainer,subsContainer,destination);
+            if(transactionStore!=null){
+                rc=transactionStore.proxy(rc);
+            }
+            topics.put(destination,rc);
+        }
+        return rc;
+    }
+
+    public TransactionStore createTransactionStore() throws IOException{
+        if(transactionStore==null){
+            transactionStore=new MemoryTransactionStore();
+        }
+        return transactionStore;
+    }
+
+    public void beginTransaction(ConnectionContext context){}
+
+    public void commitTransaction(ConnectionContext context) throws IOException{
+        store.force();
+    }
+
+    public void rollbackTransaction(ConnectionContext context){}
+
+    public void start() throws Exception{}
+
+    public void stop() throws Exception{}
+
+    public long getLastMessageBrokerSequenceId() throws IOException{
+        return 0;
+    }
+
+    public void deleteAllMessages() throws IOException{
+        if(store!=null){
+            store.clear();
+        }
+        if(transactionStore!=null){
+            transactionStore.delete();
+        }
+    }
+
+    public boolean isUseExternalMessageReferences(){
+        return useExternalMessageReferences;
+    }
+
+    public void setUseExternalMessageReferences(boolean useExternalMessageReferences){
+        this.useExternalMessageReferences=useExternalMessageReferences;
+    }
+
+    protected MapContainer getMapContainer(Object id) throws IOException{
+        MapContainer container=store.getMapContainer(id);
+        container.setKeyMarshaller(new StringMarshaller());
+        if(useExternalMessageReferences){
+            container.setValueMarshaller(new StringMarshaller());
+        }else{
+            container.setValueMarshaller(new CommandMarshaller(wireFormat));
+        }
+        container.load();
+        return container;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaPersistentAdaptor.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java (added)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,162 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.activemq.store.kahadaptor;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.Message;
+import org.apache.activemq.command.MessageId;
+import org.apache.activemq.command.SubscriptionInfo;
+import org.apache.activemq.kaha.ListContainer;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StringMarshaller;
+import org.apache.activemq.store.MessageRecoveryListener;
+import org.apache.activemq.store.TopicMessageStore;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
+/**
+ * @version $Revision: 1.5 $
+ */
+public class KahaTopicMessageStore extends KahaMessageStore implements TopicMessageStore{
+    private Map ackContainer;
+    private Map subscriberContainer;
+    private Store store;
+    private Map subscriberAcks=new ConcurrentHashMap();
+
+    public KahaTopicMessageStore(Store store,MapContainer messageContainer,MapContainer ackContainer,
+                    MapContainer subsContainer,ActiveMQDestination destination) throws IOException{
+        super(messageContainer,destination);
+        this.store=store;
+        this.ackContainer=ackContainer;
+        subscriberContainer=subsContainer;
+        // load all the Ack containers
+        for(Iterator i=subscriberContainer.keySet().iterator();i.hasNext();){
+            Object key=i.next();
+            addSubscriberAckContainer(key);
+        }
+    }
+
+    public synchronized void addMessage(ConnectionContext context,Message message) throws IOException{
+        int subscriberCount=subscriberAcks.size();
+        if(subscriberCount>0){
+            super.addMessage(context,message);
+            String id=message.getMessageId().toString();
+            ackContainer.put(id,new AtomicInteger(subscriberCount));
+            for(Iterator i=subscriberAcks.keySet().iterator();i.hasNext();){
+                Object key=i.next();
+                ListContainer container=store.getListContainer(key);
+                container.add(id);
+            }
+        }
+    }
+
+    public synchronized void acknowledge(ConnectionContext context,String clientId,String subscriptionName,
+                    MessageId messageId) throws IOException{
+        String subcriberId=getSubscriptionKey(clientId,subscriptionName);
+        String id=messageId.toString();
+        ListContainer container=(ListContainer) subscriberAcks.get(subcriberId);
+        if(container!=null){
+            container.remove(id);
+            AtomicInteger count=(AtomicInteger) ackContainer.remove(id);
+            if(count!=null){
+                if(count.decrementAndGet()>0){
+                    ackContainer.put(id,count);
+                }else{
+                    // no more references to message messageContainer so remove it
+                    container.remove(id);
+                }
+            }
+        }
+    }
+
+    public SubscriptionInfo lookupSubscription(String clientId,String subscriptionName) throws IOException{
+        return (SubscriptionInfo) subscriberContainer.get(getSubscriptionKey(clientId,subscriptionName));
+    }
+
+    public synchronized void addSubsciption(String clientId,String subscriptionName,String selector,boolean retroactive)
+                    throws IOException{
+        SubscriptionInfo info=new SubscriptionInfo();
+        info.setDestination(destination);
+        info.setClientId(clientId);
+        info.setSelector(selector);
+        info.setSubcriptionName(subscriptionName);
+        String key=getSubscriptionKey(clientId,subscriptionName);
+        subscriberContainer.put(key,info);
+        addSubscriberAckContainer(key);
+    }
+
+    public synchronized void deleteSubscription(String clientId,String subscriptionName){
+        String key=getSubscriptionKey(clientId,subscriptionName);
+        subscriberContainer.remove(key);
+        ListContainer list=(ListContainer) subscriberAcks.get(key);
+        for(Iterator i=list.iterator();i.hasNext();){
+            String id=i.next().toString();
+            AtomicInteger count=(AtomicInteger) ackContainer.remove(id);
+            if(count!=null){
+                if(count.decrementAndGet()>0){
+                    ackContainer.put(id,count);
+                }else{
+                    // no more references to message messageContainer so remove it
+                    messageContainer.remove(id);
+                }
+            }
+        }
+    }
+
+    public void recoverSubscription(String clientId,String subscriptionName,MessageRecoveryListener listener)
+                    throws Exception{
+        String key=getSubscriptionKey(clientId,subscriptionName);
+        ListContainer list=(ListContainer) subscriberAcks.get(key);
+        for(Iterator i=list.iterator();i.hasNext();){
+            Object msg=messageContainer.get(i.next());
+            if(msg!=null){
+                if(msg.getClass()==String.class){
+                    listener.recoverMessageReference((String) msg);
+                }else{
+                    listener.recoverMessage((Message) msg);
+                }
+            }
+            listener.finished();
+        }
+    }
+
+    public void delete(){
+        super.delete();
+        ackContainer.clear();
+        subscriberContainer.clear();
+    }
+
+    public SubscriptionInfo[] getAllSubscriptions() throws IOException{
+        return (SubscriptionInfo[]) subscriberContainer.values().toArray(
+                        new SubscriptionInfo[subscriberContainer.size()]);
+    }
+
+    protected String getSubscriptionKey(String clientId,String subscriberName){
+        String result=clientId+":";
+        result+=subscriberName!=null?subscriberName:"NOT_SET";
+        return result;
+    }
+
+    protected void addSubscriberAckContainer(Object key) throws IOException{
+        ListContainer container=store.getListContainer(key);
+        container.setMarshaller(new StringMarshaller());
+        container.load();
+        subscriberAcks.put(key,container);
+    }
+}

Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/KahaTopicMessageStore.java
------------------------------------------------------------------------------
    svn:executable = *

Copied: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/package.html (from r387583, incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/package.html)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/package.html?p2=incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/package.html&p1=incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/package.html&r1=387583&r2=387586&rev=387586&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/package.html (original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadaptor/package.html Tue Mar 21 09:21:33 2006
@@ -4,7 +4,7 @@
 <body>
 
 <p>
-	VM based implementation of message persistence
+	kaha implementation of message persistence for the broker
 </p>
 
 </body>

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/ListContainerTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/ListContainerTest.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/ListContainerTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/ListContainerTest.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,315 @@
+package org.apache.activemq.kaha;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import org.apache.activemq.kaha.ListContainer;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StoreFactory;
+import junit.framework.TestCase;
+
+public class ListContainerTest extends TestCase{
+   
+    protected String name = "test";
+    protected Store store;
+    protected ListContainer container;
+    protected LinkedList testList;
+    protected static final int COUNT = 10;
+    /*
+     * Test method for 'org.apache.activemq.kaha.ListContainer.size()'
+     */
+    public void testSize()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.ListContainer.addFirst(Object)'
+     */
+    public void testAddFirst()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+        String first = "first";
+        container.addFirst(first);
+        assertEquals(first,container.get(0));
+        assertEquals(container.size(),testList.size()+1);
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.ListContainer.addLast(Object)'
+     */
+    public void testAddLast()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+        String last = "last";
+        container.addLast(last);
+        assertEquals(last,container.get(testList.size()));
+        assertEquals(container.size(),testList.size()+1);
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.ListContainer.removeFirst()'
+     */
+    public void testRemoveFirst()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+        assertEquals(testList.get(0),container.removeFirst());
+        assertEquals(container.size(),testList.size()-1);
+        for (int i =1; i < testList.size(); i++){
+            assertEquals(testList.get(i),container.get(i-1));
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.ListContainer.removeLast()'
+     */
+    public void testRemoveLast()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+        assertEquals(testList.get(testList.size()-1),container.removeLast());
+        assertEquals(container.size(),testList.size()-1);
+        for (int i =0; i < testList.size()-1; i++){
+            assertEquals(testList.get(i),container.get(i));
+        }
+    }
+
+    
+    /*
+     * Test method for 'java.util.List.iterator()'
+     */
+    public void testIterator()throws Exception {
+        container.addAll(testList);
+        for (Iterator i = testList.iterator(), j = container.iterator(); i.hasNext();){
+            assertEquals(i.next(),j.next());
+        }
+        for (Iterator i = container.iterator(); i.hasNext();){
+            i.next();
+            i.remove();
+        }
+        assert(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'java.util.List.isEmpty()'
+     */
+    public void testIsEmpty()throws Exception {
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'java.util.List.contains(Object)'
+     */
+    public void testContains()throws Exception {
+        container.addAll(testList);
+        for (Iterator i = testList.iterator(), j = container.iterator(); i.hasNext();){
+            assertTrue(container.contains(i.next()));
+        }
+    }
+
+    /*
+     * Test method for 'java.util.List.toArray()'
+     */
+    public void testToArray()throws Exception {
+        container.addAll(testList);
+        Object[] a = testList.toArray();
+        Object[] b = container.toArray();
+        assertEquals(a.length,b.length);
+        for (int i = 0 ; i < a.length; i++){
+            assertEquals(a[i],b[i]);
+        }
+    }
+
+   
+    /*
+     * Test method for 'java.util.List.remove(Object)'
+     */
+    public void testRemoveObject()throws Exception {
+        container.addAll(testList);
+        assertEquals(container.size(),testList.size());
+        for (int i =0; i < testList.size(); i++){
+            container.remove(testList.get(i));
+        }
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'java.util.List.containsAll(Collection<?>)'
+     */
+    public void testContainsAll()throws Exception {
+        container.addAll(testList);
+        assertTrue(container.containsAll(testList));
+    }
+
+   
+    /*
+     * Test method for 'java.util.List.removeAll(Collection<?>)'
+     */
+    public void testRemoveAll()throws Exception {
+        container.addAll(testList);
+        assertEquals(testList.size(),container.size());
+        container.removeAll(testList);
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'java.util.List.retainAll(Collection<?>)'
+     */
+    public void testRetainAll()throws Exception {
+        container.addAll(testList);
+        assertEquals(testList.size(),container.size());
+        testList.remove(0);
+        container.retainAll(testList);
+        assertEquals(testList.size(),container.size());
+    }
+
+    /*
+     * Test method for 'java.util.List.clear()'
+     */
+    public void testClear()throws Exception {
+        container.addAll(testList);
+        assertEquals(testList.size(),container.size());
+        container.clear();
+        assertTrue(container.isEmpty());
+    }
+
+   
+    /*
+     * Test method for 'java.util.List.get(int)'
+     */
+    public void testGet()throws Exception {
+        container.addAll(testList);
+        for (int i =0; i < testList.size();i++){
+            assertEquals(container.get(i),testList.get(i));
+        }
+    }
+
+    /*
+     * Test method for 'java.util.List.set(int, E)'
+     */
+    public void testSet()throws Exception {
+        container.addAll(testList);
+        
+    }
+
+    /*
+     * Test method for 'java.util.List.add(int, E)'
+     */
+    public void testAddIntE()throws Exception {
+        container.addAll(testList);
+        assertTrue(container.equals(testList));
+        Object testObj = "testObj";
+        int index = 0;
+        testList.set(index, testObj);
+        container.set(index, testObj);
+        assertTrue(container.equals(testList));
+        index = testList.size()-1;
+        testList.set(index, testObj);
+        container.set(index, testObj);
+        assertTrue(container.equals(testList));
+    }
+
+    /*
+     * Test method for 'java.util.List.remove(int)'
+     */
+    public void testRemoveInt()throws Exception {
+        container.addAll(testList);
+        assertTrue(container.equals(testList));
+        testList.remove(0);
+        container.remove(0);
+        assertTrue(container.equals(testList));
+        int pos = testList.size()-1;
+        testList.remove(pos);
+        container.remove(pos);
+        assertTrue(container.equals(testList));
+    }
+
+    /*
+     * Test method for 'java.util.List.indexOf(Object)'
+     */
+    public void testIndexOf()throws Exception {
+        container.addAll(testList);
+        assertTrue(container.equals(testList));
+        for (int i =0; i < testList.size(); i++){
+           Object o = testList.get(i);
+           assertEquals(i,container.indexOf(o));
+        }
+    }
+
+   
+    /*
+     * Test method for 'java.util.List.listIterator()'
+     */
+    public void testListIterator()throws Exception {
+        container.addAll(testList);
+        ListIterator containerIter = container.listIterator();
+        ListIterator testIter = testList.listIterator();
+        assertTrue(testIter.hasNext());
+        assertTrue(containerIter.hasNext());
+        while (testIter.hasNext()){
+            Object o1 = testIter.next();
+            Object o2 = containerIter.next();
+            assertEquals(o1,o2);
+            testIter.remove();
+            containerIter.remove();
+        }
+        assertTrue(testList.isEmpty());
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'java.util.List.listIterator(int)'
+     */
+    public void testListIteratorInt()throws Exception {
+        container.addAll(testList);
+        int start = testList.size()/2;
+        ListIterator containerIter = container.listIterator(start);
+        ListIterator testIter = testList.listIterator(start);
+        assertTrue(testIter.hasNext());
+        assertTrue(containerIter.hasNext());
+        while (testIter.hasNext()){
+            Object o1 = testIter.next();
+            Object o2 = containerIter.next();
+            assertEquals(o1,o2);
+        }
+    }
+
+    /*
+     * Test method for 'java.util.List.subList(int, int)'
+     */
+    public void testSubList()throws Exception {
+        container.addAll(testList);
+        int start = testList.size()/2;
+        List l1 = testList.subList(start, testList.size());
+        List l2 = container.subList(start, testList.size());
+        assertEquals(l1.size(),l2.size());
+        assertEquals(l1,l2);
+    }
+    
+    protected Store getStore() throws IOException{
+        return StoreFactory.open(name, "rw");
+    }
+    
+    protected void setUp() throws Exception{
+        super.setUp();
+        StoreFactory.delete(name);
+        store = getStore();
+        store.deleteListContainer(name);
+        container = store.getListContainer(name);
+        container.load();
+        testList = new LinkedList();
+        for (int i =0; i < COUNT; i++){
+            String value = "value:"+i;
+            testList.add(value);
+        }
+        
+    }
+
+    protected void tearDown() throws Exception{
+        super.tearDown();
+        assertTrue(StoreFactory.delete(name));
+    }
+}

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/LoadTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/LoadTest.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/LoadTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/LoadTest.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,62 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.activemq.kaha;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import junit.framework.TestCase;
+import org.apache.activemq.kaha.impl.StoreImpl;
+import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+/**
+ * Store test
+ * 
+ * @version $Revision: 1.2 $
+ */
+public class LoadTest extends TestCase{
+    static final int COUNT=10000;
+    static final int NUM_LOADERS=2;
+    protected String name="load.db";
+    protected StoreImpl store;
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.close()'
+     */
+    public void testLoad() throws Exception{
+        CountDownLatch start=new CountDownLatch(NUM_LOADERS);
+        CountDownLatch stop=new CountDownLatch(NUM_LOADERS);
+        for(int i=0;i<NUM_LOADERS;i++){
+            Loader loader=new Loader("loader:"+i,store,COUNT,start,stop);
+            loader.start();
+        }
+        stop.await();
+        store.dumpFreeSpace(new PrintWriter(System.out));
+    }
+
+    protected StoreImpl getStore() throws IOException{
+        return (StoreImpl) StoreFactory.open(name,"rw");
+    }
+
+    protected void setUp() throws Exception{
+        super.setUp();
+        StoreFactory.delete(name);
+        store=getStore();
+    }
+
+    protected void tearDown() throws Exception{
+        super.tearDown();
+        store.clear();
+        store.close();
+        assertTrue(StoreFactory.delete(name));
+    }
+}

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/Loader.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/Loader.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/Loader.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/Loader.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,113 @@
+/**
+ * 
+ * Copyright 2005-2006 The Apache Software Foundation
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.activemq.kaha;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+import org.apache.activemq.kaha.BytesMarshaller;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Marshaller;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StringMarshaller;
+import org.apache.activemq.kaha.impl.StoreImpl;
+import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+import junit.framework.TestCase;
+/**
+ * Store test
+ * 
+ * @version $Revision: 1.2 $
+ */
+class Loader extends Thread{
+    private String name;
+    private Store store;
+    private int count;
+    private CountDownLatch start;
+    private CountDownLatch stop;
+
+    public Loader(String name,Store store,int count,CountDownLatch start,CountDownLatch stop){
+        this.name=name;
+        this.store=store;
+        this.count=count;
+        this.start = start;
+        this.stop = stop;
+    }
+
+    public void run(){
+        try{
+            start.countDown();
+            start.await();
+            Marshaller keyMarshaller=new StringMarshaller();
+            Marshaller valueMarshaller=new BytesMarshaller();
+            MapContainer container=store.getMapContainer(name);
+           
+            container.setKeyMarshaller(keyMarshaller);
+            container.setValueMarshaller(valueMarshaller);
+            container.load();
+            // set data
+            Object value=getData(1024);
+            long startTime=System.currentTimeMillis();
+            long startLoad=System.currentTimeMillis();
+            for(int i=0;i<count;i++){
+                String key="key:"+i;
+                container.put(key,value);
+            }
+            long finishLoad=System.currentTimeMillis();
+            long totalLoadTime=finishLoad-startLoad;
+            System.out.println("name "+name+" load time = "+totalLoadTime+"(ms)");
+            
+            Set keys=container.keySet();
+            long startExtract=System.currentTimeMillis();
+            
+            for(Iterator i=keys.iterator();i.hasNext();){
+                byte[] data=(byte[]) container.get(i.next());
+            }
+            long finishExtract=System.currentTimeMillis();
+            long totalExtractTime=finishExtract-startExtract;
+            System.out.println("name "+name+" extract time = "+totalExtractTime+"(ms)");
+            
+            long startRemove=System.currentTimeMillis();
+            for(Iterator i=keys.iterator();i.hasNext();){
+                container.remove(i.next());
+            }
+            long finishRemove = System.currentTimeMillis();
+            long totalRemoveTime = finishRemove-startRemove;
+            System.out.println("name "+name+" remove time = "+totalRemoveTime+"(ms)");
+            //re-insert data of longer length
+            startLoad=System.currentTimeMillis();
+            value = getData(2048);
+            for(int i=0;i<count;i++){
+                String key="key:"+i;
+                container.put(key,value);
+            }
+            finishLoad=System.currentTimeMillis();
+            totalLoadTime=finishLoad-startLoad;
+            System.out.println("name "+name+" 2nd load time = "+totalLoadTime+"(ms)");
+            
+            
+        }catch(Exception e){
+            e.printStackTrace();
+        }finally{
+            stop.countDown();
+        }
+    }
+
+    byte[] getData(int size){
+        byte[] result=new byte[size];
+        for(int i=0;i<size;i++){
+            result[i]='a';
+        }
+        return result;
+    }
+}

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/MapContainerTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/MapContainerTest.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/MapContainerTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/MapContainerTest.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,182 @@
+package org.apache.activemq.kaha;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StoreFactory;
+import junit.framework.TestCase;
+
+public class MapContainerTest extends TestCase{
+    
+    protected String name = "test";
+    protected Store store;
+    protected MapContainer container;
+    protected Map testMap;
+    protected static final int COUNT = 10;
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.size()'
+     */
+    public void testSize() throws Exception {
+        container.putAll(testMap);
+        assertTrue(container.size()==testMap.size());
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.isEmpty()'
+     */
+    public void testIsEmpty() throws Exception {
+       assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.clear()'
+     */
+    public void testClear() throws Exception {
+        container.putAll(testMap);
+        assertTrue(container.size()==testMap.size());
+        container.clear();
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.containsKey(Object)'
+     */
+    public void testContainsKeyObject() throws Exception {
+        container.putAll(testMap);
+        for (Iterator i = testMap.entrySet().iterator();i.hasNext();){
+            Map.Entry entry = (Entry) i.next();
+            assertTrue(container.containsKey(entry.getKey()));
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.get(Object)'
+     */
+    public void testGetObject() throws Exception {
+        container.putAll(testMap);
+        for (Iterator i = testMap.entrySet().iterator();i.hasNext();){
+            Map.Entry entry = (Entry) i.next();
+            Object value = container.get(entry.getKey());
+            assertNotNull(value);
+            assertTrue(value.equals(entry.getValue()));
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.containsValue(Object)'
+     */
+    public void testContainsValueObject() throws Exception {
+        container.putAll(testMap);
+        for (Iterator i = testMap.entrySet().iterator();i.hasNext();){
+            Map.Entry entry = (Entry) i.next();
+            assertTrue(container.containsValue(entry.getValue()));
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.putAll(Map)'
+     */
+    public void testPutAllMap() throws Exception {
+        container.putAll(testMap);
+        for (Iterator i = testMap.entrySet().iterator();i.hasNext();){
+            Map.Entry entry = (Entry) i.next();
+            assertTrue(container.containsValue(entry.getValue()));
+            assertTrue(container.containsKey(entry.getKey()));
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.keySet()'
+     */
+    public void testKeySet() throws Exception {
+        container.putAll(testMap);
+        Set keys = container.keySet();
+        assertTrue(keys.size()==testMap.size());
+        for (Iterator i = testMap.keySet().iterator();i.hasNext();){
+            Object key = i.next();
+            assertTrue(keys.contains(key));
+            keys.remove(key);
+        }
+        assertTrue(container.isEmpty());
+        
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.values()'
+     */
+    public void testValues() throws Exception {
+        container.putAll(testMap);
+        Collection values = container.values();
+        assertTrue(values.size()==testMap.size());
+        for (Iterator i = testMap.values().iterator();i.hasNext();){
+            Object value = i.next();
+            assertTrue(values.contains(value));
+            assertTrue(values.remove(value));
+        }
+        assertTrue(container.isEmpty());
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.entrySet()'
+     */
+    public void testEntrySet() throws Exception {
+        container.putAll(testMap);
+        Set entries = container.entrySet();
+        assertTrue(entries.size()==testMap.size());
+        for (Iterator i = entries.iterator();i.hasNext();){
+            Map.Entry entry = (Entry) i.next();
+            assertTrue(testMap.containsKey(entry.getKey()));
+            assertTrue(testMap.containsValue(entry.getValue()));
+            
+        }
+        
+    }
+
+    
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.MapContainer.remove(Object)'
+     */
+    public void testRemoveObject() throws Exception {
+        container.putAll(testMap);
+        for (Iterator i = testMap.keySet().iterator();i.hasNext();){
+            container.remove(i.next());
+        }
+        assertTrue(container.isEmpty());
+    }
+
+    protected Store getStore() throws IOException{
+        return StoreFactory.open(name, "rw");
+    }
+    
+    protected void setUp() throws Exception{
+        super.setUp();
+        store = getStore();
+        store.deleteListContainer(name);
+        container = store.getMapContainer(name);
+        container.load();
+        testMap = new HashMap();
+        for (int i =0; i < COUNT; i++){
+            String key = "key:" + i;
+            String value = "value:"+i;
+            testMap.put(key, value);
+        }
+        
+    }
+
+    protected void tearDown() throws Exception{
+        super.tearDown();
+        assertTrue(StoreFactory.delete(name));
+    }
+    
+    
+    
+    
+}

Added: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/StoreTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/StoreTest.java?rev=387586&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/StoreTest.java (added)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/kaha/StoreTest.java Tue Mar 21 09:21:33 2006
@@ -0,0 +1,208 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.activemq.kaha;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.activemq.kaha.ListContainer;
+import org.apache.activemq.kaha.MapContainer;
+import org.apache.activemq.kaha.Store;
+import org.apache.activemq.kaha.StoreFactory;
+import junit.framework.TestCase;
+
+/**
+*Store test
+* 
+* @version $Revision: 1.2 $
+*/
+public class StoreTest extends TestCase{
+    
+    protected String name = "sdbStoreTest.db";
+    protected Store store;
+    
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.close()'
+     */
+    public void testClose() throws Exception{
+        store.close();
+        try {
+            //access should throw an exception
+            store.getListContainer("fred");
+            assertTrue("Should have got a enception",false);
+        }catch(Exception e){
+            
+        }
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.clear()'
+     */
+    public void testClear() throws Exception{
+        int count = 100;
+        ListContainer list = store.getListContainer("testClear");
+        list.load();
+        for (int i =0; i < count; i++){
+            list.add("test " + i);
+        }
+        assertEquals(count,list.size());
+        store.clear();
+        assertTrue(list.isEmpty());
+    }
+
+   
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.getMapContainer(Object)'
+     */
+    public void testGetMapContainer() throws Exception{
+        String containerId = "test";
+        MapContainer container = store.getMapContainer(containerId);
+        container.load();
+        assertNotNull(container);
+        store.close();
+        store = getStore();
+        container = store.getMapContainer(containerId);
+        assertNotNull(container);
+        
+        
+        
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.deleteMapContainer(Object)'
+     */
+    public void testDeleteMapContainer() throws Exception{
+        String containerId = "test";
+        MapContainer container = store.getMapContainer(containerId);
+        assertNotNull(container);
+        store.deleteMapContainer(containerId);
+        assertFalse(store.doesMapContainerExist(containerId));
+        store.close();
+        store = getStore();
+        assertFalse(store.doesMapContainerExist(containerId));
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.getMapContainerIds()'
+     */
+    public void testGetMapContainerIds()throws Exception {
+        String containerId = "test";
+        MapContainer container = store.getMapContainer(containerId);
+        Set set = store.getMapContainerIds();
+        assertTrue(set.contains(containerId));
+    }
+
+    
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.getListContainer(Object)'
+     */
+    public void testGetListContainer() throws Exception{
+        String containerId = "test";
+        ListContainer container = store.getListContainer(containerId);
+        assertNotNull(container);
+        store.close();
+        store = getStore();
+        container = store.getListContainer(containerId);
+        assertNotNull(container);
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.deleteListContainer(Object)'
+     */
+    public void testDeleteListContainer()throws Exception{
+        String containerId = "test";
+        ListContainer container = store.getListContainer(containerId);
+        assertNotNull(container);
+        store.deleteListContainer(containerId);
+        assertFalse(store.doesListContainerExist(containerId));
+        store.close();
+        store = getStore();
+        assertFalse(store.doesListContainerExist(containerId));
+    }
+
+    /*
+     * Test method for 'org.apache.activemq.kaha.Store.getListContainerIds()'
+     */
+    public void testGetListContainerIds()throws Exception {
+        String containerId = "test";
+        ListContainer container = store.getListContainer(containerId);
+        Set set = store.getListContainerIds();
+        assertTrue(set.contains(containerId));
+    }
+    
+    public void testBasicAllocations() throws Exception{
+        Map testMap = new HashMap();
+        for (int i =0; i<10; i++){
+            String key = "key:"+i;
+            String value = "value:"+i;
+            testMap.put(key, value);
+        }
+        List testList = new ArrayList();
+        for (int i = 0; i < 10; i++){
+            testList.add("value:"+i);
+        }
+        String listId = "testList";
+        String mapId = "testMap";
+        MapContainer mapContainer = store.getMapContainer(mapId);
+        mapContainer.load();
+        ListContainer listContainer = store.getListContainer(listId);
+        listContainer.load();
+        mapContainer.putAll(testMap);
+        listContainer.addAll(testList);
+        store.close();
+        store = getStore();
+        mapContainer = store.getMapContainer(mapId);
+        mapContainer.load();
+        listContainer = store.getListContainer(listId);
+        listContainer.load();
+        for (Iterator i = testMap.keySet().iterator(); i.hasNext();){
+            Object key = i.next();
+            Object value = testMap.get(key);
+            assertTrue(mapContainer.containsKey(key));
+            assertEquals(value,mapContainer.get(key));
+        }
+        assertEquals(testList.size(),listContainer.size());
+        for (Iterator i = testList.iterator(), j = listContainer.iterator(); i.hasNext();){
+            assertEquals(i.next(),j.next());
+        }
+    }
+    
+    
+    protected Store getStore() throws IOException{
+        return StoreFactory.open(name, "rw");
+    }
+    
+    protected void setUp() throws Exception{
+        super.setUp();
+        store = getStore();
+        
+    }
+
+    protected void tearDown() throws Exception{
+        super.tearDown();
+        assertTrue(StoreFactory.delete(name));
+    }
+}