KickJava   Java API By Example, From Geeks To Geeks.

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


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.RecoveryBrokerTest;
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 QuickJPAStoreRecoveryBrokerTest extends RecoveryBrokerTest {
33
34     protected BrokerService createBroker() throws Exception JavaDoc {
35         BrokerService service = new BrokerService();
36         service.setDeleteAllMessagesOnStartup(true);
37         AMQPersistenceAdapter pa = new AMQPersistenceAdapter();
38         
39         JPAReferenceStoreAdapter rfa = new JPAReferenceStoreAdapter();
40         Properties JavaDoc props = new Properties JavaDoc();
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 JavaDoc {
53         BrokerService service = new BrokerService();
54         AMQPersistenceAdapter pa = new AMQPersistenceAdapter();
55
56         JPAReferenceStoreAdapter rfa = new JPAReferenceStoreAdapter();
57         Properties JavaDoc props = new Properties JavaDoc();
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 JavaDoc[] args) {
74         junit.textui.TestRunner.run(suite());
75     }
76
77 }
78
Popular Tags