1 18 package org.apache.activemq.kaha; 19 20 import java.io.IOException ; 21 import java.io.PrintWriter ; 22 import junit.framework.TestCase; 23 import org.apache.activemq.kaha.impl.KahaStore; 24 import java.util.concurrent.CountDownLatch ; 25 30 public class LoadTest extends TestCase{ 31 static final int COUNT=10000; 32 static final int NUM_LOADERS=5; 33 protected String name="load.db"; 34 protected KahaStore store; 35 36 39 public void testLoad() throws Exception { 40 CountDownLatch start=new CountDownLatch (NUM_LOADERS); 41 CountDownLatch stop=new CountDownLatch (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 { 50 return (KahaStore) StoreFactory.open(name,"rw"); 51 } 52 53 protected void setUp() throws Exception { 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 { 61 super.tearDown(); 62 store.clear(); 63 store.close(); 64 assertTrue(StoreFactory.delete(name)); 65 } 66 } 67 | Popular Tags |