From ef64a25b9f1f1268505b48ffded1a96ccdeb9b4a Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 2 Jan 2006 02:50:00 +0000 Subject: [PATCH] Better test setup git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@365280 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/store/DefaultStoreBrokerTest.java | 37 ++----------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java index 02c6bd0d8e..2220475fc4 100755 --- a/activemq-core/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/store/DefaultStoreBrokerTest.java @@ -16,24 +16,13 @@ */ package org.apache.activemq.broker.store; -import java.io.File; -import java.io.IOException; import java.net.URI; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; - -import javax.sql.DataSource; import junit.framework.Test; import org.apache.activemq.broker.BrokerFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerTest; -import org.apache.activemq.store.DefaultPersistenceAdapterFactory; -import org.apache.activemq.store.PersistenceAdapter; -import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter; -import org.apache.activemq.store.journal.JournalPersistenceAdapter; /** * Once the wire format is completed we can test against real persistence storage. @@ -45,29 +34,9 @@ public class DefaultStoreBrokerTest extends BrokerTest { protected BrokerService createBroker() throws Exception { return BrokerFactory.createBroker(new URI("broker://()/localhost?deleteAllMessagesOnStartup=true")); } - - protected PersistenceAdapter createPersistenceAdapter(boolean clean) throws IOException { - File dataDir = new File("test-data"); - if( clean ) { - recursiveDelete(new File(dataDir, "journal")); - } - DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); - factory.setDataDirectory(dataDir); - // Use a smaller journal so that tests are quicker. - factory.setJournalLogFileSize(1024*64); - PersistenceAdapter adapter = factory.createPersistenceAdapter(); - if( clean ) { - DataSource ds = ((JDBCPersistenceAdapter)((JournalPersistenceAdapter)adapter).getLongTermPersistence()).getDataSource(); - try { - Connection c = ds.getConnection(); - Statement s = c.createStatement(); - try { s.executeUpdate("DROP TABLE ACTIVEMQ_MSGS");} catch (SQLException e) {} - try { s.executeUpdate("DROP TABLE ACTIVEMQ_TXS");} catch (SQLException e) {} - try { s.executeUpdate("DROP TABLE ACTIVEMQ_ACKS");} catch (SQLException e) {} - } catch (SQLException e) { - } - } - return adapter; + + protected BrokerService createRestartedBroker() throws Exception { + return BrokerFactory.createBroker(new URI("broker://()/localhost")); } public static Test suite() {