KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > VolumeTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.kaha;
19
20 import java.io.IOException JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.LinkedList JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.ListIterator JavaDoc;
25 import junit.framework.TestCase;
26 public class VolumeTest extends TestCase{
27   
28     protected Store store;
29     protected String JavaDoc name;
30    
31    
32     protected static final int NUMBER=1;
33
34     /*
35      * dump a large number of messages into a list - then retreive them
36      */

37     public void testListVolume() throws Exception JavaDoc{
38         ListContainer container=store.getListContainer("volume");
39         container.setMarshaller(Store.BytesMarshaller);
40         byte[] data = new byte[10];
41         for (int i =0; i< NUMBER; i++){
42             container.add(data);
43             if(i%100000==0){
44                 System.err.println("persisted " + i);
45             }
46             
47         }
48         int count = 0;
49         
50         for (Iterator JavaDoc i = container.iterator(); i.hasNext();){
51             assertNotNull(i.next());
52             count++;
53             if (count%100000==0){
54                 System.err.println("retrived " + count);
55             }
56         }
57         assertEquals("Different retrieved to stored",NUMBER,count);
58     }
59     
60     
61     
62
63     protected Store getStore() throws IOException JavaDoc{
64         return StoreFactory.open(name,"rw");
65     }
66
67     protected void setUp() throws Exception JavaDoc{
68         super.setUp();
69         name = System.getProperty("basedir", ".")+"/target/activemq-data/volume-container.db";
70         StoreFactory.delete(name);
71         store=StoreFactory.open(name,"rw");
72        
73     }
74
75     protected void tearDown() throws Exception JavaDoc{
76         super.tearDown();
77         if(store!=null){
78             store.close();
79         }
80         assertTrue(StoreFactory.delete(name));
81     }
82 }
83
Popular Tags