You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/06/09 18:36:37 UTC
[06/52] [abbrv] [partial] activemq-artemis git commit: ARTEMIS-127
Adding activemq unit test module to Artemis
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java
new file mode 100644
index 0000000..82b5ebe
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigTest.java
@@ -0,0 +1,457 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.sql.DataSource;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+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.network.NetworkConnector;
+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.xbean.BrokerFactoryBean;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+
+public class ConfigTest {
+
+ 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.
+ */
+
+ /*
+ * This tests creating a journal persistence adapter using the persistence
+ * adapter factory bean
+ */
+ @Test
+ public void testJournaledJDBCConfig() throws Exception {
+
+ File journalFile = new File(JOURNAL_ROOT + "testJournaledJDBCConfig/journal");
+ recursiveDelete(journalFile);
+
+ File derbyFile = new File(DERBY_ROOT + "testJournaledJDBCConfig/derbydb"); // Default
+ 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
+ broker.getPersistenceAdapter();
+
+ assertTrue(broker.getSystemUsage().getStoreUsage().getStore() instanceof JournalPersistenceAdapter);
+
+ LOG.info("Success");
+ } finally {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+ }
+
+ @Test
+ 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.getLocker() 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.getLocker().getClass(), DefaultDatabaseLocker.class);
+ adapter.stop();
+ }
+
+ /*
+ * This tests configuring the different broker properties using
+ * xbeans-spring
+ */
+ @Test
+ public void testBrokerConfig() throws Exception {
+ 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");
+ LOG.info("Success");
+
+ try {
+ // Check broker configuration
+ // System.out.print("Checking broker configurations... ");
+ assertEquals("Broker Config Error (brokerName)", "brokerConfigTest", broker.getBrokerName());
+ assertEquals("Broker Config Error (populateJMSXUserID)", false, broker.isPopulateJMSXUserID());
+ assertEquals("Broker Config Error (useLoggingForShutdownErrors)", true, broker.isUseLoggingForShutdownErrors());
+ assertEquals("Broker Config Error (useJmx)", true, broker.isUseJmx());
+ assertEquals("Broker Config Error (persistent)", false, broker.isPersistent());
+ assertEquals("Broker Config Error (useShutdownHook)", false, broker.isUseShutdownHook());
+ assertEquals("Broker Config Error (deleteAllMessagesOnStartup)", true, broker.isDeleteAllMessagesOnStartup());
+ LOG.info("Success");
+
+ // Check specific vm transport
+ // System.out.print("Checking vm connector... ");
+ 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<TransportConnector> connectors = broker.getTransportConnectors();
+ assertTrue("Should have created at least 3 connectors", connectors.size() >= 3);
+ assertTrue("1st connector should be TcpTransportServer", connectors.get(0).getServer() instanceof TcpTransportServer);
+ assertTrue("2nd connector should be TcpTransportServer", connectors.get(1).getServer() instanceof TcpTransportServer);
+ assertTrue("3rd connector should be TcpTransportServer", connectors.get(2).getServer() instanceof TcpTransportServer);
+
+ // Check network connectors
+ // System.out.print("Checking network connectors... ");
+ List<NetworkConnector> 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... ");
+ SystemUsage systemUsage = broker.getSystemUsage();
+ assertTrue("Should have a SystemUsage", systemUsage != null);
+ assertEquals("SystemUsage Config Error (MemoryUsage.limit)", 1024 * 1024 * 10, systemUsage.getMemoryUsage().getLimit());
+ assertEquals("SystemUsage Config Error (MemoryUsage.percentUsageMinDelta)", 20, systemUsage.getMemoryUsage().getPercentUsageMinDelta());
+ 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);
+
+ LOG.info("Success");
+
+ } finally {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+ }
+
+ /*
+ * This tests creating a journal persistence adapter using xbeans-spring
+ */
+ @Test
+ public void testJournalConfig() throws Exception {
+ 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
+ */
+ @Test
+ public void testMemoryConfig() throws Exception {
+ 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();
+ }
+ }
+ }
+
+ @Test
+ public void testConnectorConfig() throws Exception {
+
+ File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig");
+ recursiveDelete(journalFile);
+
+ File derbyFile = new File(DERBY_ROOT + "testMemoryConfig");
+ recursiveDelete(derbyFile);
+
+ final int MAX_PRODUCERS = 5;
+ final int MAX_CONSUMERS = 10;
+
+ BrokerService broker = createBroker(new FileSystemResource(CONF_ROOT + "connector-properties.xml"));
+ broker.start();
+ try {
+
+ assertEquals(broker.getTransportConnectorByScheme("tcp").getMaximumProducersAllowedPerConnection(), MAX_PRODUCERS);
+ assertEquals(broker.getTransportConnectorByScheme("tcp").getMaximumConsumersAllowedPerConnection(), MAX_CONSUMERS);
+
+ ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61631");
+ javax.jms.Connection connection = activeMQConnectionFactory.createConnection();
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Topic topic = session.createTopic("test.foo");
+
+ for (int i = 0; i < MAX_PRODUCERS; i++) {
+ session.createProducer(topic);
+ }
+
+ try {
+ session.createProducer(topic);
+ fail("Should have got an exception on exceeding MAX_PRODUCERS");
+ } catch (JMSException expected) {
+ }
+
+ try {
+ for (int i = 0; i < (MAX_CONSUMERS + 1); i++) {
+ MessageConsumer consumer = session.createConsumer(topic);
+ assertNotNull(consumer);
+ }
+ fail("Should have caught an exception");
+ } catch (JMSException e) {
+ }
+
+ LOG.info("Success");
+ } finally {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+ }
+
+ @Test
+ 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
+ */
+
+ protected static void recursiveDelete(File file) {
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ recursiveDelete(files[i]);
+ }
+ }
+ file.delete();
+ }
+
+ protected BrokerService createBroker(String resource) throws Exception {
+ return createBroker(new ClassPathResource(resource));
+ }
+
+ protected BrokerService createBroker(Resource resource) throws Exception {
+ BrokerFactoryBean factory = new BrokerFactoryBean(resource);
+ factory.afterPropertiesSet();
+
+ BrokerService broker = factory.getBroker();
+
+ assertTrue("Should have a broker!", broker != null);
+
+ // Broker is already started by default when using the XML file
+ // broker.start();
+
+ return broker;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java
new file mode 100644
index 0000000..704e408
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.config;
+
+import javax.jms.Connection;
+import javax.jms.InvalidSelectorException;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQMessageConsumer;
+import org.apache.activemq.command.ActiveMQQueue;
+
+public class ConfigUsingDestinationOptions extends TestCase {
+ public void testValidSelectorConfig() throws JMSException {
+ ActiveMQQueue queue = new ActiveMQQueue("TEST.FOO?consumer.selector=test=1");
+
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
+ Connection conn = factory.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ ActiveMQMessageConsumer cons;
+ // JMS selector should be priority
+ cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test=2");
+ assertEquals("test=2", cons.getMessageSelector());
+
+ // Test setting using JMS destinations
+ cons = (ActiveMQMessageConsumer) sess.createConsumer(queue);
+ assertEquals("test=1", cons.getMessageSelector());
+ }
+
+ public void testInvalidSelectorConfig() throws JMSException {
+ ActiveMQQueue queue = new ActiveMQQueue("TEST.FOO?consumer.selector=test||1");
+
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
+ Connection conn = factory.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ ActiveMQMessageConsumer cons;
+ // JMS selector should be priority
+ try {
+ cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test||1");
+ fail("Selector should be invalid" + cons);
+ } catch (InvalidSelectorException e) {
+
+ }
+
+ // Test setting using JMS destinations
+ try {
+ cons = (ActiveMQMessageConsumer) sess.createConsumer(queue);
+ fail("Selector should be invalid" + cons);
+ } catch (InvalidSelectorException e) {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java
new file mode 100644
index 0000000..e13f53d
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/JDBCConfigTest.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
+import org.apache.activemq.wireformat.ObjectStreamWireFormat;
+import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.derby.jdbc.EmbeddedDataSource;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+
+public class JDBCConfigTest {
+
+ 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(JDBCConfigTest.class);
+
+ /*
+ * This tests creating a jdbc persistence adapter using xbeans-spring
+ */
+ @Test
+ public void testJdbcConfig() throws Exception {
+ File journalFile = new File(JOURNAL_ROOT + "testJDBCConfig/journal");
+ recursiveDelete(journalFile);
+
+ File derbyFile = new File(DERBY_ROOT + "testJDBCConfig/derbydb"); // Default
+ 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();
+ }
+ }
+ }
+
+ protected static void recursiveDelete(File file) {
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ recursiveDelete(files[i]);
+ }
+ }
+ file.delete();
+ }
+
+ protected BrokerService createBroker(String resource) throws Exception {
+ return createBroker(new ClassPathResource(resource));
+ }
+
+ protected BrokerService createBroker(Resource resource) throws Exception {
+ BrokerFactoryBean factory = new BrokerFactoryBean(resource);
+ factory.afterPropertiesSet();
+
+ BrokerService broker = factory.getBroker();
+
+ assertTrue("Should have a broker!", broker != null);
+
+ // Broker is already started by default when using the XML file
+ // broker.start();
+
+ return broker;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/broker.properties
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/broker.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/broker.properties
new file mode 100644
index 0000000..921671f
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/broker.properties
@@ -0,0 +1,21 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+# START SNIPPET: example
+useJmx = false
+persistent = false
+brokerName = Cheese
+# END SNIPPET: example
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/config.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/config.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/config.xml
new file mode 100644
index 0000000..9ec13ff
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/config.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <broker brokerName="brokerXmlConfigHelper" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true" xmlns="http://activemq.apache.org/schema/core">
+ <transportConnectors>
+ <transportConnector uri="tcp://localhost:61638"/>
+ </transportConnectors>
+ </broker>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/example.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/example.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/example.xml
new file mode 100644
index 0000000..0a7a686
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/example.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <!-- normal ActiveMQ XML config which is less verbose & can be validated -->
+ <amq:broker brokerName="brokerConfigTest" populateJMSXUserID="false"
+ useLoggingForShutdownErrors="true" useJmx="true"
+ 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:persistenceAdapter>
+
+ <amq:systemUsage>
+ <amq:systemUsage>
+ <amq:memoryUsage>
+ <amq:memoryUsage limit="10 mb" percentUsageMinDelta="20"/>
+ </amq:memoryUsage>
+ <amq:storeUsage>
+ <amq:storeUsage limit="1 gb" name="foo"/>
+ </amq:storeUsage>
+ <amq:tempUsage>
+ <amq:tempUsage limit="100 mb"/>
+ </amq:tempUsage>
+ </amq:systemUsage>
+ </amq:systemUsage>
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61635"/>
+ <amq:transportConnector uri="tcp://localhost:61636"/>
+ <amq:transportConnector uri="tcp://localhost:61637"/>
+ </amq:transportConnectors>
+
+
+ </amq:broker>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/connector-properties.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/connector-properties.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/connector-properties.xml
new file mode 100644
index 0000000..23f065d
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/connector-properties.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <amq:broker brokerName="brokerConnectorTest" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true">
+
+ <amq:persistenceAdapter>
+ <amq:memoryPersistenceAdapter createTransactionStore = "false"/>
+ </amq:persistenceAdapter>
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61631" maximumProducersAllowedPerConnection="5" maximumConsumersAllowedPerConnection="10"/>
+ </amq:transportConnectors>
+
+ </amq:broker>
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/jdbc-example.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/jdbc-example.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/jdbc-example.xml
new file mode 100644
index 0000000..bbd98ea
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/jdbc-example.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <amq:broker brokerName="brokerJdbcConfigTest" persistent="true" useShutdownHook="false" deleteAllMessagesOnStartup="true">
+
+ <amq:persistenceAdapter>
+ <amq:jdbcPersistenceAdapter>
+ <property name="cleanupPeriod" value="60000"/>
+ <property name="dataSource" ref="embedded-ds"/>
+ <property name="wireFormat">
+ <bean id="myWireFormat" class="org.apache.activemq.wireformat.ObjectStreamWireFormat"/>
+ </property>
+ </amq:jdbcPersistenceAdapter>
+ </amq:persistenceAdapter>
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61635"/>
+ </amq:transportConnectors>
+
+ </amq:broker>
+
+ <!-- ==================================================================== -->
+ <!-- JDBC DataSource Configurations -->
+ <!-- ==================================================================== -->
+
+ <!-- The Datasource that will be used by the Broker -->
+ <bean id="embedded-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
+ <property name="databaseName" value="testJdbcConfig"/>
+ <property name="createDatabase" value="create"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journal-example.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journal-example.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journal-example.xml
new file mode 100644
index 0000000..2a79308
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journal-example.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <amq:broker brokerName="brokerJournalConfigTest" persistent="true" useShutdownHook="false" deleteAllMessagesOnStartup="true">
+
+ <amq:persistenceAdapter>
+ <amq:journalPersistenceAdapter>
+ <amq:journal>
+ <ref bean="myJournalImpl"/>
+ </amq:journal>
+
+ <amq:persistenceAdapter>
+ <amq:memoryPersistenceAdapter createTransactionStore="true"/>
+ </amq:persistenceAdapter>
+
+ <amq:taskRunnerFactory>
+ <bean id="myTaskRunnerFactory" class="org.apache.activemq.thread.TaskRunnerFactory"/>
+ </amq:taskRunnerFactory>
+ </amq:journalPersistenceAdapter>
+ </amq:persistenceAdapter>
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61635"/>
+ </amq:transportConnectors>
+
+ </amq:broker>
+
+ <!-- The journal implementation that will be used -->
+ <bean id="myJournalImpl" class="org.apache.activeio.journal.active.JournalImpl">
+ <constructor-arg index="0">
+ <bean id="myFile" class="java.io.File">
+ <constructor-arg index="0">
+ <value>target/test-data/testJournalConfig/journal</value>
+ </constructor-arg>
+ </bean>
+ </constructor-arg>
+ </bean>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journaledjdbc-example.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journaledjdbc-example.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journaledjdbc-example.xml
new file mode 100644
index 0000000..4a6a0db
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/journaledjdbc-example.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <amq:broker brokerName="brokerJournaledJDBCConfigTest" persistent="true" useShutdownHook="false" deleteAllMessagesOnStartup="true">
+
+ <amq:persistenceFactory>
+ <amq:journalPersistenceAdapterFactory journalLogFiles="4" journalLogFileSize="32768" dataDirectory="target/test-data/testJournaledJDBCConfig" />
+ </amq:persistenceFactory>
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61635"/>
+ </amq:transportConnectors>
+
+ </amq:broker>
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/memory-example.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/memory-example.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/memory-example.xml
new file mode 100644
index 0000000..10b38a8
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/sample-conf/memory-example.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <amq:broker brokerName="brokerMemoryConfigTest" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true">
+
+ <amq:persistenceAdapter>
+ <amq:memoryPersistenceAdapter createTransactionStore = "true"/>
+ </amq:persistenceAdapter>
+
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:61635"/>
+ </amq:transportConnectors>
+
+ </amq:broker>
+</beans>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/spring-test.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/spring-test.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/spring-test.xml
new file mode 100644
index 0000000..0e2f145
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/config/spring-test.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+ <bean id="wireFormat" class="org.apache.activemq.io.impl.DefaultWireFormat"/>
+
+ <bean id="transport" factory-method="newInstance" class="org.apache.activemq.transport.TransportServerChannelProvider">
+ <constructor-arg index="0">
+ <bean class="org.apache.activemq.io.impl.DefaultWireFormat"/>
+ <!---
+ <ref bean="wireFormat"/>
+ -->
+ </constructor-arg>
+ <constructor-arg index="1">
+ <value>vm://localhost</value>
+ </constructor-arg>
+ </bean>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java
new file mode 100644
index 0000000..dadff34
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3410Test.java
@@ -0,0 +1,186 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.console.command;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.console.CommandContext;
+import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AMQ3410Test extends TestCase {
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory
+ .getLogger(PurgeCommandTest.class);
+ private static final Collection<String> DEFAULT_OPTIONS = Arrays
+ .asList(new String[] { "--amqurl", "tcp://localhost:61616", });
+
+ private static final Collection<String> DEFAULT_TOKENS = Arrays
+ .asList(new String[] { "FOO.QUEUE" });
+
+ protected AbstractApplicationContext context;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ context = createApplicationContext();
+
+ }
+
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/activemq/console/command/activemq.xml");
+ }
+
+ protected void tearDown() throws Exception {
+ BrokerService broker = (BrokerService) context.getBean("localbroker");
+ broker.stop();
+ broker = (BrokerService) context.getBean("default");
+ broker.stop();
+ super.tearDown();
+ }
+
+ public void testNoFactorySet() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.addAll(DEFAULT_TOKENS);
+
+ command.execute(tokens);
+ assertNotNull(command.getConnectionFactory());
+ assertTrue(command.getConnectionFactory() instanceof ActiveMQConnectionFactory);
+ }
+
+ public void testFactorySet() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--factory");
+ tokens.add(DummyConnectionFactory.class.getCanonicalName());
+ tokens.addAll(DEFAULT_TOKENS);
+
+ command.execute(tokens);
+
+ assertNotNull(command.getConnectionFactory());
+ assertTrue("wrong instance returned: "
+ + command.getConnectionFactory().getClass().getName(), command
+ .getConnectionFactory() instanceof DummyConnectionFactory);
+ }
+
+ public void testFactorySetWrong1() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--factory");
+ tokens
+ .add("org.apache.activemq.console.command.TestAMQ3410.DoesntExistFactory");
+ tokens.addAll(DEFAULT_TOKENS);
+
+ try {
+ command.execute(tokens);
+ } catch (Throwable cause) {
+ while (null != cause) {
+ if (cause instanceof java.lang.ClassNotFoundException)
+ return;
+ cause = cause.getCause();
+ }
+ }
+ assertFalse("No exception caught", true);
+ }
+
+ public void testFactorySetWrong2() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--factory");
+ tokens.add(InvalidConnectionFactory.class.getCanonicalName());
+ tokens.addAll(DEFAULT_TOKENS);
+
+ try {
+ command.execute(tokens);
+ } catch (Throwable e) {
+ Throwable cause = e;
+ while (null != cause) {
+ if (cause instanceof java.lang.NoSuchMethodException)
+ return;
+ cause = cause.getCause();
+ }
+ assertFalse(e.toString(), true);
+ }
+ assertFalse("No exception caught", true);
+ }
+
+ public void testFactorySetWrong3() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--factory");
+ tokens.add("java.lang.Object");
+ tokens.addAll(DEFAULT_TOKENS);
+
+ try {
+ command.execute(tokens);
+ } catch (Throwable cause) {
+ while (null != cause) {
+ if (cause instanceof java.lang.NoSuchMethodException)
+ return;
+ cause = cause.getCause();
+ }
+ }
+ assertFalse(true);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java
new file mode 100644
index 0000000..8930b2c
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/AMQ3411Test.java
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.console.command;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.console.CommandContext;
+import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AMQ3411Test extends TestCase {
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AMQ3411Test.class);
+ private static final Collection<String> DEFAULT_OPTIONS = Arrays
+ .asList(new String[] { "--amqurl", "tcp://localhost:61616", });
+
+ private static final Collection<String> DEFAULT_TOKENS = Arrays
+ .asList(new String[] { "FOO.QUEUE" });
+ protected AbstractApplicationContext context;
+ protected static final String origPassword = "ABCDEFG";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ context = createApplicationContext();
+
+ }
+
+ protected AbstractApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/activemq/console/command/activemq.xml");
+ }
+
+ protected void tearDown() throws Exception {
+ BrokerService broker = (BrokerService) context.getBean("localbroker");
+ broker.stop();
+ broker = (BrokerService) context.getBean("default");
+ broker.stop();
+ super.tearDown();
+ }
+
+ public void testNoFactorySet() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.addAll(DEFAULT_TOKENS);
+
+ command.execute(tokens);
+
+ assertNotNull(command.getPasswordFactory());
+ assertTrue(command.getPasswordFactory() instanceof DefaultPasswordFactory);
+ assertNull(command.getPassword());
+ }
+
+ public void testUsernamePasswordSet() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ String username = "user";
+ String password = "password";
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--password");
+ tokens.add(password);
+
+ tokens.add("--user");
+ tokens.add(username);
+ tokens.addAll(DEFAULT_TOKENS);
+
+ command.execute(tokens);
+
+ assertNotNull(command.getPasswordFactory());
+ assertTrue(command.getPasswordFactory() instanceof DefaultPasswordFactory);
+ assertEquals(password, command.getPassword());
+ assertEquals(username, command.getUsername());
+ }
+
+ public void testFactorySet() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--passwordFactory");
+ tokens.add(LowercasingPasswordFactory.class.getCanonicalName());
+ tokens.add("--password");
+ tokens.add(origPassword);
+ tokens.addAll(DEFAULT_TOKENS);
+
+ command.execute(tokens);
+ assertNotNull(command.getPasswordFactory());
+ assertTrue(command.getPasswordFactory() instanceof LowercasingPasswordFactory);
+
+ // validate that the factory is indeed being used for the password.
+ assertEquals(origPassword.toLowerCase(), command.getPassword());
+ }
+
+ public void testFactorySetWrong1() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--passwordFactory");
+ tokens
+ .add("org.apache.activemq.console.command.TestAMQ3411.DoesntExistFactory");
+ tokens.add("--password");
+ tokens.add(origPassword);
+
+ tokens.addAll(DEFAULT_TOKENS);
+
+ try {
+ command.execute(tokens);
+ } catch (Throwable e) {
+ Throwable cause = e;
+ while (null != cause) {
+ if (cause instanceof java.lang.ClassNotFoundException)
+ return;
+ cause = cause.getCause();
+ }
+ assertFalse(e.toString(), true);
+ }
+ assertFalse("No exception caught", true);
+ }
+
+ public void testFactorySetWrong2() throws Exception {
+ AmqBrowseCommand command = new AmqBrowseCommand();
+ CommandContext context = new CommandContext();
+
+ context.setFormatter(new CommandShellOutputFormatter(System.out));
+
+ command.setCommandContext(context);
+
+ List<String> tokens = new ArrayList<String>();
+ tokens.addAll(DEFAULT_OPTIONS);
+ tokens.add("--passwordFactory");
+ tokens.add("java.lang.Object");
+ tokens.add("--password");
+ tokens.add(origPassword);
+ tokens.addAll(DEFAULT_TOKENS);
+
+ try {
+ command.execute(tokens);
+ } catch (Throwable e) {
+ Throwable cause = e;
+ while (null != cause) {
+ if (cause instanceof java.lang.ClassCastException)
+ return;
+ cause = cause.getCause();
+ }
+ assertFalse(e.toString(), true);
+ }
+ assertFalse("No exception caught", true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java
new file mode 100644
index 0000000..03f9fc5
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/DummyConnectionFactory.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.console.command;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+import java.net.URI;
+
+public class DummyConnectionFactory extends ActiveMQConnectionFactory {
+ public DummyConnectionFactory() {
+ super();
+ }
+
+ public DummyConnectionFactory(String userName, String password, String brokerURL) {
+ super(userName, password, brokerURL);
+ }
+
+ public DummyConnectionFactory(String userName, String password, URI brokerURL) {
+ super(userName, password, brokerURL);
+ }
+
+ public DummyConnectionFactory(String brokerURL) {
+ super(brokerURL);
+ }
+
+ public DummyConnectionFactory(URI brokerURL) {
+ super(brokerURL);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java
new file mode 100644
index 0000000..fa57684
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/InvalidConnectionFactory.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.console.command;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+public class InvalidConnectionFactory extends ActiveMQConnectionFactory {
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/60979268/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java
new file mode 100644
index 0000000..a0f9b05
--- /dev/null
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/console/command/LowercasingPasswordFactory.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.console.command;
+
+public class LowercasingPasswordFactory implements PasswordFactory {
+ @Override
+ public String getPassword(String password) {
+ return password.toLowerCase();
+ }
+
+}