Source code: org/activemq/usecases/JournalDurableSubscriptionTest.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.activemq.usecases;
19
20 import java.io.File;
21 import java.io.IOException;
22
23 import org.apache.derby.jdbc.EmbeddedDataSource;
24 import org.activemq.io.impl.DefaultWireFormat;
25 import org.activemq.store.PersistenceAdapter;
26 import org.activemq.store.jdbc.JDBCPersistenceAdapter;
27 import org.activemq.store.journal.JournalPersistenceAdapter;
28
29 /**
30 * @version $Revision: 1.1.1.1 $
31 */
32 public class JournalDurableSubscriptionTest extends DurableSubscriptionTestSupport {
33
34 boolean init;
35
36 protected PersistenceAdapter createPersistenceAdapter() throws IOException {
37
38 System.setProperty("derby.system.home", "target");
39 System.setProperty("derby.storage.fileSyncTransactionLog", "true");
40
41 EmbeddedDataSource ds = new EmbeddedDataSource();
42 ds.setDatabaseName("testdb");
43 if( !init )
44 ds.setCreateDatabase("create");
45 JDBCPersistenceAdapter jdbcAdapter = new JDBCPersistenceAdapter(ds, new DefaultWireFormat());
46 if( !init )
47 jdbcAdapter.setDropTablesOnStartup(true);
48
49 File directory = new File("target/journal");
50 if( !init )
51 recursiveDelete(directory);
52
53 JournalPersistenceAdapter journalAdapter = new JournalPersistenceAdapter(directory, jdbcAdapter);
54 journalAdapter.setJournalType(JournalPersistenceAdapter.DEFAULT_JOURNAL_TYPE);
55
56 init=true;
57 return journalAdapter;
58 }
59
60 }