activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r1302904 - in /activemq/trunk/activemq-core/src/test: java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java resources/org/apache/activemq/store/leveldb/ resources/org/apache/activemq/store/leveldb/leveldb.xml
Date Tue, 20 Mar 2012 14:06:38 GMT
Author: rajdavies
Date: Tue Mar 20 14:06:37 2012
New Revision: 1302904

URL: http://svn.apache.org/viewvc?rev=1302904&view=rev
Log:
Added config test for LevelDB - for https://issues.apache.org/jira/browse/AMQ-3772

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java
      - copied, changed from r1302885, activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/leveldb.xml
      - copied, changed from r1302885, activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml

Copied: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java
(from r1302885, activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java?p2=activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java&p1=activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java&r1=1302885&r2=1302904&rev=1302904&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/leveldb/LevelDBConfigTest.java
Tue Mar 20 14:06:37 2012
@@ -14,199 +14,32 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.config;
+package org.apache.activemq.store.leveldb;
 
 import java.io.File;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.util.List;
-
-import javax.sql.DataSource;
 
 import junit.framework.TestCase;
-
 import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.broker.region.policy.FixedSizedSubscriptionRecoveryPolicy;
-import org.apache.activemq.broker.region.policy.LastImageSubscriptionRecoveryPolicy;
-import org.apache.activemq.broker.region.policy.NoSubscriptionRecoveryPolicy;
-import org.apache.activemq.broker.region.policy.RoundRobinDispatchPolicy;
-import org.apache.activemq.broker.region.policy.SimpleDispatchPolicy;
-import org.apache.activemq.broker.region.policy.StrictOrderDispatchPolicy;
-import org.apache.activemq.broker.region.policy.SubscriptionRecoveryPolicy;
-import org.apache.activemq.broker.region.policy.TimedSubscriptionRecoveryPolicy;
 import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.jdbc.DefaultDatabaseLocker;
-import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
-import org.apache.activemq.store.jdbc.adapter.TransactDatabaseLocker;
-import org.apache.activemq.store.journal.JournalPersistenceAdapter;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.apache.activemq.transport.tcp.TcpTransportServer;
 import org.apache.activemq.usage.SystemUsage;
-import org.apache.activemq.wireformat.ObjectStreamWireFormat;
 import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.derby.jdbc.EmbeddedDataSource;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
 import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.FileSystemResource;
 import org.springframework.core.io.Resource;
 
 /**
  * 
  */
-public class ConfigTest extends TestCase {
+public class LevelDBConfigTest extends TestCase {
 
-    protected static final String JOURNAL_ROOT = "target/test-data/";
-    protected static final String DERBY_ROOT = "target/test-data/";
-    protected static final String CONF_ROOT = "src/test/resources/org/apache/activemq/config/sample-conf/";
-    private static final Logger LOG = LoggerFactory.getLogger(ConfigTest.class);
-
-    static {
-        System.setProperty("javax.net.ssl.trustStore", "src/test/resources/client.keystore");
-        System.setProperty("javax.net.ssl.trustStorePassword", "password");
-        System.setProperty("javax.net.ssl.trustStoreType", "jks");
-        System.setProperty("javax.net.ssl.keyStore", "src/test/resources/server.keystore");
-        System.setProperty("javax.net.ssl.keyStorePassword", "password");
-        System.setProperty("javax.net.ssl.keyStoreType", "jks");
-    }
 
-    /*
-     * IMPORTANT NOTE: Assertions checking for the existence of the derby
-     * directory will fail if the first derby directory is not created under
-     * target/test-data/. The test in unable to change the derby root directory
-     * for succeeding creation. It uses the first created directory as the root.
-     */
+    protected static final String CONF_ROOT = "src/test/resources/org/apache/activemq/store/leveldb/";
+    private static final Logger LOG = LoggerFactory.getLogger(LevelDBConfigTest.class);
 
-    /*
-     * This tests creating a journal persistence adapter using the persistence
-     * adapter factory bean
-     */
-    public void testJournaledJDBCConfig() throws Exception {
-        // System.out.print("Checking journaled JDBC persistence adapter
-        // configuration... ");
-
-        File journalFile = new File(JOURNAL_ROOT + "testJournaledJDBCConfig/journal");
-        recursiveDelete(journalFile);
-
-        File derbyFile = new File(DERBY_ROOT + "testJournaledJDBCConfig/derbydb"); // Default
-                                                                                    // derby
-                                                                                    // name
-        recursiveDelete(derbyFile);
 
-        BrokerService broker;
-        broker = createBroker(new FileSystemResource(CONF_ROOT + "journaledjdbc-example.xml"));
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerJournaledJDBCConfigTest",
broker.getBrokerName());
-
-            PersistenceAdapter adapter = broker.getPersistenceAdapter();
 
-            assertTrue("Should have created a journal persistence adapter", adapter instanceof
JournalPersistenceAdapter);
-            assertTrue("Should have created a derby directory at " + derbyFile.getAbsolutePath(),
derbyFile.exists());
-            assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(),
journalFile.exists());
-
-            // Check persistence factory configurations
-            // System.out.print("Checking persistence adapter factory
-            // settings... ");
-            broker.getPersistenceAdapter();
-            
-            assertTrue(broker.getSystemUsage().getStoreUsage().getStore() instanceof JournalPersistenceAdapter);
-
-            LOG.info("Success");
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
-    }
-
-    /*
-     * This tests creating a jdbc persistence adapter using xbeans-spring
-     */
-    public void testJdbcConfig() throws Exception {
-        // System.out.print("Checking jdbc persistence adapter configuration...
-        // ");     
-        File journalFile = new File(JOURNAL_ROOT + "testJDBCConfig/journal");
-        recursiveDelete(journalFile);
-        
-        File derbyFile = new File(DERBY_ROOT + "testJDBCConfig/derbydb"); // Default
-                                                                            // derby
-                                                                            // name
-        recursiveDelete(derbyFile);
-
-        BrokerService broker;
-        broker = createBroker(new FileSystemResource(CONF_ROOT + "jdbc-example.xml"));
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerJdbcConfigTest", broker.getBrokerName());
-
-            PersistenceAdapter adapter = broker.getPersistenceAdapter();
-
-            assertTrue("Should have created a jdbc persistence adapter", adapter instanceof
JDBCPersistenceAdapter);
-            assertEquals("JDBC Adapter Config Error (cleanupPeriod)", 60000, ((JDBCPersistenceAdapter)adapter).getCleanupPeriod());
-            assertTrue("Should have created an EmbeddedDataSource", ((JDBCPersistenceAdapter)adapter).getDataSource()
instanceof EmbeddedDataSource);
-            assertTrue("Should have created a DefaultWireFormat", ((JDBCPersistenceAdapter)adapter).getWireFormat()
instanceof ObjectStreamWireFormat);
-
-            LOG.info("Success");
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
-    }
-
-    public void testJdbcLockConfigOverride() throws Exception {
-      
-        JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
-        Mockery context = new Mockery();
-        final DataSource dataSource = context.mock(DataSource.class);
-        final Connection connection = context.mock(Connection.class);
-        final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
-        final ResultSet result = context.mock(ResultSet.class);
-        adapter.setDataSource(dataSource);
-        adapter.setCreateTablesOnStartup(false);
-        
-        context.checking(new Expectations() {{
-            allowing (dataSource).getConnection(); will (returnValue(connection));
-            allowing (connection).getMetaData(); will (returnValue(metadata));
-            allowing (connection);
-            allowing (metadata).getDriverName(); will (returnValue("Microsoft_SQL_Server_2005_jdbc_driver"));
-            allowing (result).next(); will (returnValue(true));
-        }});
-        
-        adapter.start();
-        assertTrue("has the locker override", adapter.getDatabaseLocker() instanceof TransactDatabaseLocker);
-        adapter.stop();
-    }
-
-    
-
-    public void testJdbcLockConfigDefault() throws Exception {
-      
-        JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
-        Mockery context = new Mockery();
-        final DataSource dataSource = context.mock(DataSource.class);
-        final Connection connection = context.mock(Connection.class);
-        final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
-        final ResultSet result = context.mock(ResultSet.class);
-        adapter.setDataSource(dataSource);
-        adapter.setCreateTablesOnStartup(false);
-        
-        context.checking(new Expectations() {{
-            allowing (dataSource).getConnection(); will (returnValue(connection));
-            allowing (connection).getMetaData(); will (returnValue(metadata));
-            allowing (connection);
-            allowing (metadata).getDriverName(); will (returnValue("Some_Unknown_driver"));
-            allowing (result).next(); will (returnValue(true));
-        }});
-        
-        adapter.start();
-        assertEquals("has the default locker", adapter.getDatabaseLocker().getClass(), DefaultDatabaseLocker.class);
-        adapter.stop();
-    }
 
     /*
      * This tests configuring the different broker properties using
@@ -216,12 +49,10 @@ public class ConfigTest extends TestCase
         ActiveMQTopic dest;
         BrokerService broker;
 
-        File journalFile = new File(JOURNAL_ROOT);
-        recursiveDelete(journalFile);
 
         // Create broker from resource
         // System.out.print("Creating broker... ");
-        broker = createBroker("org/apache/activemq/config/example.xml");
+        broker = createBroker("org/apache/activemq/store/leveldb/leveldb.xml");
         LOG.info("Success");
 
         try {
@@ -241,59 +72,6 @@ public class ConfigTest extends TestCase
             assertEquals("Should have a specific VM Connector", "vm://javacoola", broker.getVmConnectorURI().toString());
             LOG.info("Success");
 
-            // Check transport connectors list
-            // System.out.print("Checking transport connectors... ");
-            List connectors = broker.getTransportConnectors();
-            assertTrue("Should have created at least 3 connectors", connectors.size() >=
3);
-            assertTrue("1st connector should be TcpTransportServer", ((TransportConnector)connectors.get(0)).getServer()
instanceof TcpTransportServer);
-            assertTrue("2nd connector should be TcpTransportServer", ((TransportConnector)connectors.get(1)).getServer()
instanceof TcpTransportServer);
-            assertTrue("3rd connector should be TcpTransportServer", ((TransportConnector)connectors.get(2)).getServer()
instanceof TcpTransportServer);
-
-            // Check network connectors
-            // System.out.print("Checking network connectors... ");
-            List networkConnectors = broker.getNetworkConnectors();
-            assertEquals("Should have a single network connector", 1, networkConnectors.size());
-            LOG.info("Success");
-
-            // Check dispatch policy configuration
-            // System.out.print("Checking dispatch policies... ");
-
-            dest = new ActiveMQTopic("Topic.SimpleDispatch");
-            assertTrue("Should have a simple dispatch policy for " + dest.getTopicName(),
-                       broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy()
instanceof SimpleDispatchPolicy);
-
-            dest = new ActiveMQTopic("Topic.RoundRobinDispatch");
-            assertTrue("Should have a round robin dispatch policy for " + dest.getTopicName(),
-                       broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy()
instanceof RoundRobinDispatchPolicy);
-
-            dest = new ActiveMQTopic("Topic.StrictOrderDispatch");
-            assertTrue("Should have a strict order dispatch policy for " + dest.getTopicName(),
-                       broker.getDestinationPolicy().getEntryFor(dest).getDispatchPolicy()
instanceof StrictOrderDispatchPolicy);
-            LOG.info("Success");
-
-            // Check subscription policy configuration
-            // System.out.print("Checking subscription recovery policies... ");
-            SubscriptionRecoveryPolicy subsPolicy;
-
-            dest = new ActiveMQTopic("Topic.FixedSizedSubs");
-            subsPolicy = broker.getDestinationPolicy().getEntryFor(dest).getSubscriptionRecoveryPolicy();
-            assertTrue("Should have a fixed sized subscription recovery policy for " + dest.getTopicName(),
subsPolicy instanceof FixedSizedSubscriptionRecoveryPolicy);
-            assertEquals("FixedSizedSubsPolicy Config Error (maximumSize)", 2000000, ((FixedSizedSubscriptionRecoveryPolicy)subsPolicy).getMaximumSize());
-            assertEquals("FixedSizedSubsPolicy Config Error (useSharedBuffer)", false, ((FixedSizedSubscriptionRecoveryPolicy)subsPolicy).isUseSharedBuffer());
-
-            dest = new ActiveMQTopic("Topic.LastImageSubs");
-            subsPolicy = broker.getDestinationPolicy().getEntryFor(dest).getSubscriptionRecoveryPolicy();
-            assertTrue("Should have a last image subscription recovery policy for " + dest.getTopicName(),
subsPolicy instanceof LastImageSubscriptionRecoveryPolicy);
-
-            dest = new ActiveMQTopic("Topic.NoSubs");
-            subsPolicy = broker.getDestinationPolicy().getEntryFor(dest).getSubscriptionRecoveryPolicy();
-            assertTrue("Should have no subscription recovery policy for " + dest.getTopicName(),
subsPolicy instanceof NoSubscriptionRecoveryPolicy);
-
-            dest = new ActiveMQTopic("Topic.TimedSubs");
-            subsPolicy = broker.getDestinationPolicy().getEntryFor(dest).getSubscriptionRecoveryPolicy();
-            assertTrue("Should have a timed subscription recovery policy for " + dest.getTopicName(),
subsPolicy instanceof TimedSubscriptionRecoveryPolicy);
-            assertEquals("TimedSubsPolicy Config Error (recoverDuration)", 25000, ((TimedSubscriptionRecoveryPolicy)subsPolicy).getRecoverDuration());
-            LOG.info("Success");
 
             // Check usage manager
             // System.out.print("Checking memory manager configurations... ");
@@ -304,9 +82,9 @@ public class ConfigTest extends TestCase
             assertEquals("SystemUsage Config Error (TempUsage.limit)", 1024 * 1024 * 100,
systemUsage.getTempUsage().getLimit());
             assertEquals("SystemUsage Config Error (StoreUsage.limit)", 1024 * 1024 * 1024,
systemUsage.getStoreUsage().getLimit());
             assertEquals("SystemUsage Config Error (StoreUsage.name)", "foo", systemUsage.getStoreUsage().getName());
-            
+
             assertNotNull(systemUsage.getStoreUsage().getStore());
-            assertTrue(systemUsage.getStoreUsage().getStore() instanceof MemoryPersistenceAdapter);
+            assertTrue(systemUsage.getStoreUsage().getStore() instanceof LevelDBPersistenceAdapter);
                         
             LOG.info("Success");
 
@@ -317,89 +95,7 @@ public class ConfigTest extends TestCase
         }
     }
 
-    /*
-     * This tests creating a journal persistence adapter using xbeans-spring
-     */
-    public void testJournalConfig() throws Exception {
-        // System.out.print("Checking journal persistence adapter
-        // configuration... ");
-
-        File journalFile = new File(JOURNAL_ROOT + "testJournalConfig/journal");
-        recursiveDelete(journalFile);
-
-        BrokerService broker;
-        broker = createBroker(new FileSystemResource(CONF_ROOT + "journal-example.xml"));
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerJournalConfigTest", broker.getBrokerName());
-
-            PersistenceAdapter adapter = broker.getPersistenceAdapter();
-
-            assertTrue("Should have created a journal persistence adapter", adapter instanceof
JournalPersistenceAdapter);
-            assertTrue("Should have created a journal directory at " + journalFile.getAbsolutePath(),
journalFile.exists());
-
-            LOG.info("Success");
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
-    }
-
-    /*
-     * This tests creating a memory persistence adapter using xbeans-spring
-     */
-    public void testMemoryConfig() throws Exception {
-        // System.out.print("Checking memory persistence adapter
-        // configuration... ");
-
-        File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig");
-        recursiveDelete(journalFile);
-
-        File derbyFile = new File(DERBY_ROOT + "testMemoryConfig");
-        recursiveDelete(derbyFile);
-
-        BrokerService broker;
-        broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml"));
-
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName());
-
-            PersistenceAdapter adapter = broker.getPersistenceAdapter();
-
-            assertTrue("Should have created a memory persistence adapter", adapter instanceof
MemoryPersistenceAdapter);
-            assertTrue("Should have not created a derby directory at " + derbyFile.getAbsolutePath(),
!derbyFile.exists());
-            assertTrue("Should have not created a journal directory at " + journalFile.getAbsolutePath(),
!journalFile.exists());
-
-            LOG.info("Success");
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
-
-    }
-
-    public void testXmlConfigHelper() throws Exception {
-        BrokerService broker;
-
-        broker = createBroker(new FileSystemResource(CONF_ROOT + "memory-example.xml"));
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerMemoryConfigTest", broker.getBrokerName());
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
 
-        broker = createBroker("org/apache/activemq/config/config.xml");
-        try {
-            assertEquals("Broker Config Error (brokerName)", "brokerXmlConfigHelper", broker.getBrokerName());
-        } finally {
-            if (broker != null) {
-                broker.stop();
-            }
-        }
-    }
 
     /*
      * TODO: Create additional tests for forwarding bridges

Copied: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/leveldb.xml
(from r1302885, activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/leveldb.xml?p2=activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/leveldb.xml&p1=activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml&r1=1302885&r2=1302904&rev=1302904&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml
(original)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/store/leveldb/leveldb.xml
Tue Mar 20 14:06:37 2012
@@ -28,54 +28,10 @@
         persistent="false" vmConnectorURI="vm://javacoola"
         useShutdownHook="false" deleteAllMessagesOnStartup="true">
 
-        <!--
-        || NOTE this config file is used for unit testing the configuration mechanism
-        || it is not necessarily a good example of a config file! :)
-        -->
-        <amq:destinationPolicy>
-            <amq:policyMap>
-                <amq:policyEntries>
-
-                    <amq:policyEntry topic="Topic.SimpleDispatch">
-                        <amq:dispatchPolicy><amq:simpleDispatchPolicy /></amq:dispatchPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.RoundRobinDispatch">
-                        <amq:dispatchPolicy><amq:roundRobinDispatchPolicy /></amq:dispatchPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.StrictOrderDispatch">
-                        <amq:dispatchPolicy><amq:strictOrderDispatchPolicy /></amq:dispatchPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.FixedSizedSubs">
-                        <amq:subscriptionRecoveryPolicy>
-                            <amq:fixedSizedSubscriptionRecoveryPolicy maximumSize="2000000"
useSharedBuffer="false"/>
-                        </amq:subscriptionRecoveryPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.LastImageSubs">
-                        <amq:subscriptionRecoveryPolicy><amq:lastImageSubscriptionRecoveryPolicy/></amq:subscriptionRecoveryPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.NoSubs">
-                        <amq:subscriptionRecoveryPolicy><amq:noSubscriptionRecoveryPolicy/></amq:subscriptionRecoveryPolicy>
-                    </amq:policyEntry>
-
-                    <amq:policyEntry topic="Topic.TimedSubs">
-                        <amq:subscriptionRecoveryPolicy><amq:timedSubscriptionRecoveryPolicy
recoverDuration="25000"/></amq:subscriptionRecoveryPolicy>
-                    </amq:policyEntry>
-
-                </amq:policyEntries>
-            </amq:policyMap>
-        </amq:destinationPolicy>
-
-        <amq:networkConnectors>
-            <amq:networkConnector uri="static://(tcp://localhost:61616)"/>
-        </amq:networkConnectors>
+
 
         <amq:persistenceAdapter>
-            <amq:memoryPersistenceAdapter createTransactionStore="true"/>
+            <amq:levelDB directory = "target/activemq-data"/>
         </amq:persistenceAdapter>
 
         <amq:systemUsage>
@@ -94,8 +50,6 @@
 
         <amq:transportConnectors>
             <amq:transportConnector uri="tcp://localhost:61635"/>
-            <amq:transportConnector uri="tcp://localhost:61636"/>
-            <amq:transportConnector uri="tcp://localhost:61637"/>
         </amq:transportConnectors>
 
 



Mime
View raw message