1 18 package org.apache.activemq.broker.store; 19 20 import java.util.Properties ; 21 import junit.framework.Test; 22 import org.apache.activemq.broker.BrokerService; 23 import org.apache.activemq.broker.RecoveryBrokerTest; 24 import org.apache.activemq.store.amq.AMQPersistenceAdapter; 25 import org.apache.activemq.store.jpa.JPAReferenceStoreAdapter; 26 27 32 public class QuickJPAStoreRecoveryBrokerTest extends RecoveryBrokerTest { 33 34 protected BrokerService createBroker() throws Exception { 35 BrokerService service = new BrokerService(); 36 service.setDeleteAllMessagesOnStartup(true); 37 AMQPersistenceAdapter pa = new AMQPersistenceAdapter(); 38 39 JPAReferenceStoreAdapter rfa = new JPAReferenceStoreAdapter(); 40 Properties props = new Properties (); 41 props.setProperty("openjpa.ConnectionDriverName", "org.apache.derby.jdbc.EmbeddedDriver"); 42 props.setProperty("openjpa.ConnectionURL", "jdbc:derby:activemq-data/derby;create=true"); 43 props.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema"); 44 props.setProperty("openjpa.Log", "DefaultLevel=WARN,SQL=TRACE"); 45 rfa.setEntityManagerProperties(props); 46 pa.setReferenceStoreAdapter(rfa); 47 48 service.setPersistenceAdapter(pa); 49 return service; 50 } 51 52 protected BrokerService createRestartedBroker() throws Exception { 53 BrokerService service = new BrokerService(); 54 AMQPersistenceAdapter pa = new AMQPersistenceAdapter(); 55 56 JPAReferenceStoreAdapter rfa = new JPAReferenceStoreAdapter(); 57 Properties props = new Properties (); 58 props.setProperty("openjpa.ConnectionDriverName", "org.apache.derby.jdbc.EmbeddedDriver"); 59 props.setProperty("openjpa.ConnectionURL", "jdbc:derby:activemq-data/derby;create=true"); 60 props.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema"); 61 props.setProperty("openjpa.Log", "DefaultLevel=WARN,SQL=TRACE"); 62 rfa.setEntityManagerProperties(props); 63 pa.setReferenceStoreAdapter(rfa); 64 65 service.setPersistenceAdapter(pa); 66 return service; 67 } 68 69 public static Test suite() { 70 return suite(QuickJPAStoreRecoveryBrokerTest.class); 71 } 72 73 public static void main(String [] args) { 74 junit.textui.TestRunner.run(suite()); 75 } 76 77 } 78 | Popular Tags |