KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > store > QuickJPAStoreXARecoveryBrokerTest


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.broker.store;
19
20 import java.util.Properties JavaDoc;
21 import junit.framework.Test;
22 import org.apache.activemq.broker.BrokerService;
23 import org.apache.activemq.broker.XARecoveryBrokerTest;
24 import org.apache.activemq.store.amq.AMQPersistenceAdapter;
25 import org.apache.activemq.store.jpa.JPAReferenceStoreAdapter;
26
27 /**
28  * Used to verify that recovery works correctly against
29  *
30  * @version $Revision$
31  */

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