KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.PrintWriter JavaDoc;
22 import junit.framework.TestCase;
23 import org.apache.activemq.kaha.impl.KahaStore;
24 import java.util.concurrent.CountDownLatch JavaDoc;
25 /**
26  * Store test
27  *
28  * @version $Revision: 1.2 $
29  */

30 public class LoadTest extends TestCase{
31     static final int COUNT=10000;
32     static final int NUM_LOADERS=5;
33     protected String JavaDoc name="load.db";
34     protected KahaStore store;
35
36     /*
37      * Test method for 'org.apache.activemq.kaha.Store.close()'
38      */

39     public void testLoad() throws Exception JavaDoc{
40         CountDownLatch JavaDoc start=new CountDownLatch JavaDoc(NUM_LOADERS);
41         CountDownLatch JavaDoc stop=new CountDownLatch JavaDoc(NUM_LOADERS);
42         for(int i=0;i<NUM_LOADERS;i++){
43             Loader loader=new Loader("loader:"+i,store,COUNT,start,stop);
44             loader.start();
45         }
46         stop.await();
47     }
48
49     protected KahaStore getStore() throws IOException JavaDoc{
50         return (KahaStore) StoreFactory.open(name,"rw");
51     }
52
53     protected void setUp() throws Exception JavaDoc{
54         super.setUp();
55         name = System.getProperty("basedir", ".")+"/target/activemq-data/load.db";
56         StoreFactory.delete(name);
57         store=getStore();
58     }
59
60     protected void tearDown() throws Exception JavaDoc{
61         super.tearDown();
62         store.clear();
63         store.close();
64         assertTrue(StoreFactory.delete(name));
65     }
66 }
67
Popular Tags