Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 894D519944 for ; Mon, 21 Mar 2016 22:55:18 +0000 (UTC) Received: (qmail 59348 invoked by uid 500); 21 Mar 2016 22:55:18 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 59259 invoked by uid 500); 21 Mar 2016 22:55:18 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 58519 invoked by uid 99); 21 Mar 2016 22:55:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2016 22:55:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7099BE0158; Mon, 21 Mar 2016 22:55:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Mon, 21 Mar 2016 22:55:26 -0000 Message-Id: <1658f5d5951e492a8ebc4e365282bb5d@git.apache.org> In-Reply-To: <39ed6e3df8aa4d6d9beb4a0f6108c239@git.apache.org> References: <39ed6e3df8aa4d6d9beb4a0f6108c239@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/68] [abbrv] activemq-artemis git commit: open wire changes equivalent to ab16f7098fb52d2b4c40627ed110e1776525f208 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java deleted file mode 100644 index 80ab8e1..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/VerifySteadyEnqueueRate.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * 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.bugs; - -import junit.framework.TestCase; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.store.kahadb.KahaDBStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.jms.Connection; -import java.io.File; -import java.text.DateFormat; -import java.util.Date; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - -public class VerifySteadyEnqueueRate extends TestCase { - - private static final Logger LOG = LoggerFactory.getLogger(VerifySteadyEnqueueRate.class); - - private static int max_messages = 1000000; - private final String destinationName = getName() + "_Queue"; - private BrokerService broker; - final boolean useTopic = false; - - protected static final String payload = new String(new byte[24]); - - @Override - public void setUp() throws Exception { - startBroker(); - } - - @Override - public void tearDown() throws Exception { - broker.stop(); - } - - @SuppressWarnings("unused") - public void testEnqueueRateCanMeetSLA() throws Exception { - if (true) { - return; - } - doTestEnqueue(false); - } - - private void doTestEnqueue(final boolean transacted) throws Exception { - final long min = 100; - final AtomicLong total = new AtomicLong(0); - final AtomicLong slaViolations = new AtomicLong(0); - final AtomicLong max = new AtomicLong(0); - final int numThreads = 6; - - Runnable runner = new Runnable() { - - @Override - public void run() { - try { - MessageSender producer = new MessageSender(destinationName, createConnection(), transacted, useTopic); - - for (int i = 0; i < max_messages; i++) { - long startT = System.currentTimeMillis(); - producer.send(payload); - long endT = System.currentTimeMillis(); - long duration = endT - startT; - - total.incrementAndGet(); - - if (duration > max.get()) { - max.set(duration); - } - - if (duration > min) { - slaViolations.incrementAndGet(); - System.err.println("SLA violation @ " + Thread.currentThread().getName() + " " + DateFormat.getTimeInstance().format(new Date(startT)) + " at message " + i + " send time=" + duration + " - Total SLA violations: " + slaViolations.get() + "/" + total.get() + " (" + String.format("%.6f", 100.0 * slaViolations.get() / total.get()) + "%)"); - } - } - - } - catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - System.out.println("Max Violation = " + max + " - Total SLA violations: " + slaViolations.get() + "/" + total.get() + " (" + String.format("%.6f", 100.0 * slaViolations.get() / total.get()) + "%)"); - } - }; - ExecutorService executor = Executors.newCachedThreadPool(); - - for (int i = 0; i < numThreads; i++) { - executor.execute(runner); - } - - executor.shutdown(); - while (!executor.isTerminated()) { - executor.awaitTermination(10, TimeUnit.SECONDS); - } - } - - private Connection createConnection() throws Exception { - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getConnectUri()); - return factory.createConnection(); - } - - private void startBroker() throws Exception { - broker = new BrokerService(); - //broker.setDeleteAllMessagesOnStartup(true); - broker.setPersistent(true); - broker.setUseJmx(true); - - KahaDBStore kaha = new KahaDBStore(); - kaha.setDirectory(new File("target/activemq-data/kahadb")); - // The setEnableJournalDiskSyncs(false) setting is a little dangerous right now, as I have not verified - // what happens if the index is updated but a journal update is lost. - // Index is going to be in consistent, but can it be repaired? - kaha.setEnableJournalDiskSyncs(false); - // Using a bigger journal file size makes he take fewer spikes as it is not switching files as often. - kaha.setJournalMaxFileLength(1024 * 1024 * 100); - - // small batch means more frequent and smaller writes - kaha.setIndexWriteBatchSize(100); - // do the index write in a separate thread - kaha.setEnableIndexWriteAsync(true); - - broker.setPersistenceAdapter(kaha); - - broker.addConnector("tcp://localhost:0").setName("Default"); - broker.start(); - LOG.info("Starting broker.."); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java deleted file mode 100644 index 89b89db..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java +++ /dev/null @@ -1,158 +0,0 @@ -/* ==================================================================== - 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.bugs.amq1095; - -import java.net.URI; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.TextMessage; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import junit.framework.TestCase; - -import org.apache.activemq.broker.BrokerFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQTopic; - -/** - *

- * Common functionality for ActiveMQ test cases. - *

- * - * @author Rainer Klute <rainer.klute@dp-itsolutions.de> - * @version $Id: ActiveMQTestCase.java 12 2007-08-14 12:02:02Z rke $ - * @since 2007-08-10 - */ -public class ActiveMQTestCase extends TestCase { - - private Context context; - private BrokerService broker; - protected Connection connection; - protected Destination destination; - private final List consumersToEmpty = new LinkedList<>(); - protected final long RECEIVE_TIMEOUT = 500; - - /** - *

Constructor

- */ - public ActiveMQTestCase() { - } - - /** - *

Constructor

- * - * @param name the test case's name - */ - public ActiveMQTestCase(final String name) { - super(name); - } - - /** - *

Sets up the JUnit testing environment. - */ - @Override - protected void setUp() { - URI uri; - try { - /* Copy all system properties starting with "java.naming." to the initial context. */ - final Properties systemProperties = System.getProperties(); - final Properties jndiProperties = new Properties(); - for (final Iterator i = systemProperties.keySet().iterator(); i.hasNext(); ) { - final String key = (String) i.next(); - if (key.startsWith("java.naming.") || key.startsWith("topic.") || - key.startsWith("queue.")) { - final String value = (String) systemProperties.get(key); - jndiProperties.put(key, value); - } - } - context = new InitialContext(jndiProperties); - uri = new URI("xbean:org/apache/activemq/bugs/amq1095/activemq.xml"); - broker = BrokerFactory.createBroker(uri); - broker.start(); - } - catch (Exception ex) { - throw new RuntimeException(ex); - } - - final ConnectionFactory connectionFactory; - try { - /* Lookup the connection factory. */ - connectionFactory = (ConnectionFactory) context.lookup("TopicConnectionFactory"); - - destination = new ActiveMQTopic("TestTopic"); - - /* Create a connection: */ - connection = connectionFactory.createConnection(); - connection.setClientID("sampleClientID"); - } - catch (JMSException ex1) { - ex1.printStackTrace(); - fail(ex1.toString()); - } - catch (NamingException ex2) { - ex2.printStackTrace(); - fail(ex2.toString()); - } - catch (Throwable ex3) { - ex3.printStackTrace(); - fail(ex3.toString()); - } - } - - /** - *

- * Tear down the testing environment by receiving any messages that might be - * left in the topic after a failure and shutting down the broker properly. - * This is quite important for subsequent test cases that assume the topic - * to be empty. - *

- */ - @Override - protected void tearDown() throws Exception { - TextMessage msg; - try { - for (final Iterator i = consumersToEmpty.iterator(); i.hasNext(); ) { - final MessageConsumer consumer = i.next(); - if (consumer != null) - do - msg = (TextMessage) consumer.receive(RECEIVE_TIMEOUT); while (msg != null); - } - } - catch (Exception e) { - } - if (connection != null) { - connection.stop(); - } - broker.stop(); - } - - protected void registerToBeEmptiedOnShutdown(final MessageConsumer consumer) { - consumersToEmpty.add(consumer); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java deleted file mode 100644 index 49b704b..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* ==================================================================== - 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.bugs.amq1095; - -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -/** - *

- * Test cases for various ActiveMQ functionalities. - *

- * - *
    - *
  • - *

    - * Durable subscriptions are used. - *

    - *
  • - *
  • - *

    - * The Kaha persistence manager is used. - *

    - *
  • - *
  • - *

    - * An already existing Kaha directory is used. Everything runs fine if the - * ActiveMQ broker creates a new Kaha directory. - *

    - *
  • - *
- * - * @author Rainer Klute <rainer.klute@dp-itsolutions.de> - * @version $Id: MessageSelectorTest.java 12 2007-08-14 12:02:02Z rke $ - * @since 2007-08-09 - */ -public class MessageSelectorTest extends ActiveMQTestCase { - - private MessageConsumer consumer1; - private MessageConsumer consumer2; - - /** - *

Constructor

- */ - public MessageSelectorTest() { - } - - /** - *

Constructor

- * - * @param name the test case's name - */ - public MessageSelectorTest(final String name) { - super(name); - } - - /** - *

- * Tests whether message selectors work for durable subscribers. - *

- */ - public void testMessageSelectorForDurableSubscribersRunA() { - runMessageSelectorTest(true); - } - - /** - *

- * Tests whether message selectors work for durable subscribers. - *

- */ - public void testMessageSelectorForDurableSubscribersRunB() { - runMessageSelectorTest(true); - } - - /** - *

- * Tests whether message selectors work for non-durable subscribers. - *

- */ - public void testMessageSelectorForNonDurableSubscribers() { - runMessageSelectorTest(false); - } - - /** - *

- * Tests whether message selectors work. This is done by sending two - * messages to a topic. Both have an int property with different values. Two - * subscribers use message selectors to receive the messages. Each one - * should receive exactly one of the messages. - *

- */ - private void runMessageSelectorTest(final boolean isDurableSubscriber) { - try { - final String PROPERTY_CONSUMER = "consumer"; - final String CONSUMER_1 = "Consumer 1"; - final String CONSUMER_2 = "Consumer 2"; - final String MESSAGE_1 = "Message to " + CONSUMER_1; - final String MESSAGE_2 = "Message to " + CONSUMER_2; - - assertNotNull(connection); - assertNotNull(destination); - - final Session producingSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - final MessageProducer producer = producingSession.createProducer(destination); - - final Session consumingSession1 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - final Session consumingSession2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - if (isDurableSubscriber) { - consumer1 = consumingSession1.createDurableSubscriber((Topic) destination, CONSUMER_1, PROPERTY_CONSUMER + " = 1", false); - consumer2 = consumingSession2.createDurableSubscriber((Topic) destination, CONSUMER_2, PROPERTY_CONSUMER + " = 2", false); - } - else { - consumer1 = consumingSession1.createConsumer(destination, PROPERTY_CONSUMER + " = 1"); - consumer2 = consumingSession2.createConsumer(destination, PROPERTY_CONSUMER + " = 2"); - } - registerToBeEmptiedOnShutdown(consumer1); - registerToBeEmptiedOnShutdown(consumer2); - - connection.start(); - - TextMessage msg1; - TextMessage msg2; - int propertyValue; - String contents; - - /* Try to receive any messages from the consumers. There shouldn't be any yet. */ - msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT); - if (msg1 != null) { - final StringBuffer msg = new StringBuffer("The consumer read a message that was left over from a former ActiveMQ broker run."); - propertyValue = msg1.getIntProperty(PROPERTY_CONSUMER); - contents = msg1.getText(); - if (propertyValue != 1) // Is the property value as expected? - { - msg.append(" That message does not match the consumer's message selector."); - fail(msg.toString()); - } - assertEquals(1, propertyValue); - assertEquals(MESSAGE_1, contents); - } - msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT); - if (msg2 != null) { - final StringBuffer msg = new StringBuffer("The consumer read a message that was left over from a former ActiveMQ broker run."); - propertyValue = msg2.getIntProperty(PROPERTY_CONSUMER); - contents = msg2.getText(); - if (propertyValue != 2) // Is the property value as expected? - { - msg.append(" That message does not match the consumer's message selector."); - fail(msg.toString()); - } - assertEquals(2, propertyValue); - assertEquals(MESSAGE_2, contents); - } - - /* Send two messages. Each is targeted at one of the consumers. */ - TextMessage msg; - msg = producingSession.createTextMessage(); - msg.setText(MESSAGE_1); - msg.setIntProperty(PROPERTY_CONSUMER, 1); - producer.send(msg); - - msg = producingSession.createTextMessage(); - msg.setText(MESSAGE_2); - msg.setIntProperty(PROPERTY_CONSUMER, 2); - producer.send(msg); - - /* Receive the messages that have just been sent. */ - - /* Use consumer 1 to receive one of the messages. The receive() - * method is called twice to make sure there is nothing else in - * stock for this consumer. */ - msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT); - assertNotNull(msg1); - propertyValue = msg1.getIntProperty(PROPERTY_CONSUMER); - contents = msg1.getText(); - assertEquals(1, propertyValue); - assertEquals(MESSAGE_1, contents); - msg1 = (TextMessage) consumer1.receive(RECEIVE_TIMEOUT); - assertNull(msg1); - - /* Use consumer 2 to receive the other message. The receive() - * method is called twice to make sure there is nothing else in - * stock for this consumer. */ - msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT); - assertNotNull(msg2); - propertyValue = msg2.getIntProperty(PROPERTY_CONSUMER); - contents = msg2.getText(); - assertEquals(2, propertyValue); - assertEquals(MESSAGE_2, contents); - msg2 = (TextMessage) consumer2.receive(RECEIVE_TIMEOUT); - assertNull(msg2); - } - catch (JMSException ex) { - ex.printStackTrace(); - fail(); - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml deleted file mode 100644 index c89e261..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/activemq.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java deleted file mode 100644 index b74887f..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsClient.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * 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.bugs.amq1974; - -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.leveldb.LevelDBStore; -import org.apache.activemq.network.DiscoveryNetworkConnector; -import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent; - -import javax.jms.*; -import java.io.File; -import java.net.URISyntaxException; -import java.util.concurrent.CountDownLatch; - -public class TryJmsClient { - - private final BrokerService broker = new BrokerService(); - - public static void main(String[] args) throws Exception { - new TryJmsClient().start(); - } - - private void start() throws Exception { - - broker.setUseJmx(false); - broker.setPersistent(true); - broker.setBrokerName("TestBroker"); - broker.getSystemUsage().setSendFailIfNoSpace(true); - - broker.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024); - - LevelDBStore persist = new LevelDBStore(); - persist.setDirectory(new File("/tmp/broker2")); - persist.setLogSize(20 * 1024 * 1024); - broker.setPersistenceAdapter(persist); - - String brokerUrl = "tcp://localhost:4501"; - broker.addConnector(brokerUrl); - - broker.start(); - - addNetworkBroker(); - - startUsageMonitor(broker); - - startMessageSend(); - - new CountDownLatch(1).await(); - } - - private void startUsageMonitor(final BrokerService brokerService) { - new Thread(new Runnable() { - @Override - public void run() { - while (true) { - try { - Thread.sleep(10000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - System.out.println("ActiveMQ memeory " + brokerService.getSystemUsage().getMemoryUsage().getPercentUsage() + " " + brokerService.getSystemUsage().getMemoryUsage().getUsage()); - System.out.println("ActiveMQ message store " + brokerService.getSystemUsage().getStoreUsage().getPercentUsage()); - System.out.println("ActiveMQ temp space " + brokerService.getSystemUsage().getTempUsage().getPercentUsage()); - } - } - }).start(); - } - - private void addNetworkBroker() throws Exception { - - DiscoveryNetworkConnector dnc = new DiscoveryNetworkConnector(); - dnc.setNetworkTTL(1); - dnc.setBrokerName("TestBroker"); - dnc.setName("Broker1Connector"); - dnc.setDynamicOnly(true); - - SimpleDiscoveryAgent discoveryAgent = new SimpleDiscoveryAgent(); - String remoteUrl = "tcp://localhost:4500"; - discoveryAgent.setServices(remoteUrl); - - dnc.setDiscoveryAgent(discoveryAgent); - - broker.addNetworkConnector(dnc); - dnc.start(); - } - - private void startMessageSend() { - new Thread(new MessageSend()).start(); - } - - private class MessageSend implements Runnable { - - @Override - public void run() { - try { - String url = "vm://TestBroker"; - ActiveMQConnection connection = ActiveMQConnection.makeConnection(url); - connection.setDispatchAsync(true); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination dest = session.createTopic("TestDestination"); - - MessageProducer producer = session.createProducer(dest); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - - for (int i = 0; i < 99999999; i++) { - TextMessage message = session.createTextMessage("test" + i); - - /* - try { - Thread.sleep(1); - } catch (InterruptedException e) { - e.printStackTrace(); - } - */ - - try { - producer.send(message); - } - catch (Exception e) { - e.printStackTrace(); - System.out.println("TOTAL number of messages sent " + i); - break; - } - - if (i % 1000 == 0) { - System.out.println("sent message " + message.getJMSMessageID()); - } - } - } - catch (JMSException e) { - e.printStackTrace(); - } - catch (URISyntaxException e) { - e.printStackTrace(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java deleted file mode 100644 index 91ca459..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq1974/TryJmsManager.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * 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.bugs.amq1974; - -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.leveldb.LevelDBStore; -import org.apache.activemq.network.DiscoveryNetworkConnector; -import org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgent; - -import javax.jms.*; -import java.io.File; -import java.net.URISyntaxException; -import java.util.concurrent.CountDownLatch; - -public class TryJmsManager { - - private final BrokerService broker = new BrokerService(); - - public static void main(String[] args) throws Exception { - new TryJmsManager().start(); - } - - private void start() throws Exception { - - broker.setUseJmx(false); - broker.setPersistent(true); - broker.setBrokerName("TestBroker"); - broker.getSystemUsage().setSendFailIfNoSpace(true); - - broker.getSystemUsage().getMemoryUsage().setLimit(10 * 1024 * 1024); - - LevelDBStore persist = new LevelDBStore(); - persist.setDirectory(new File("/tmp/broker1")); - persist.setLogSize(20 * 1024 * 1024); - broker.setPersistenceAdapter(persist); - - String brokerUrl = "tcp://localhost:4500"; - broker.addConnector(brokerUrl); - - broker.start(); - - addNetworkBroker(); - - startUsageMonitor(broker); - - startMessageConsumer(); - - new CountDownLatch(1).await(); - } - - private void startUsageMonitor(final BrokerService brokerService) { - new Thread(new Runnable() { - @Override - public void run() { - while (true) { - try { - Thread.sleep(10000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - System.out.println("ActiveMQ memeory " + brokerService.getSystemUsage().getMemoryUsage().getPercentUsage() + " " + brokerService.getSystemUsage().getMemoryUsage().getUsage()); - System.out.println("ActiveMQ message store " + brokerService.getSystemUsage().getStoreUsage().getPercentUsage()); - System.out.println("ActiveMQ temp space " + brokerService.getSystemUsage().getTempUsage().getPercentUsage()); - } - } - }).start(); - } - - private void addNetworkBroker() throws Exception { - DiscoveryNetworkConnector dnc = new DiscoveryNetworkConnector(); - dnc.setNetworkTTL(1); - dnc.setBrokerName("TestBroker"); - dnc.setName("Broker1Connector"); - dnc.setDynamicOnly(true); - - SimpleDiscoveryAgent discoveryAgent = new SimpleDiscoveryAgent(); - String remoteUrl = "tcp://localhost:4501"; - discoveryAgent.setServices(remoteUrl); - - dnc.setDiscoveryAgent(discoveryAgent); - - broker.addNetworkConnector(dnc); - dnc.start(); - } - - private void startMessageConsumer() throws JMSException, URISyntaxException { - String url = "vm://TestBroker"; - ActiveMQConnection connection = ActiveMQConnection.makeConnection(url); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination dest = session.createTopic("TestDestination"); - - MessageConsumer consumer = session.createConsumer(dest); - consumer.setMessageListener(new MessageListener() { - - @Override - public void onMessage(Message message) { - try { - System.out.println("got message " + message.getJMSMessageID()); - } - catch (JMSException e) { - e.printStackTrace(); - } - } - }); - - connection.start(); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml deleted file mode 100644 index 9b82ae1..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker1.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml deleted file mode 100644 index 0b68aed..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/JaasStompSSLBroker2.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties deleted file mode 100644 index ad1398f..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/groups2.properties +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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. - */ -admins=system,dave -tempDestinationAdmins=system,user,dave -users=system,tester,user,dave,admin -guests=guest http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config deleted file mode 100644 index 898a174..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/login.config +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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. - */ -CertLogin { - org.apache.activemq.jaas.TextFileCertificateLoginModule required - debug=true - org.apache.activemq.jaas.textfiledn.user="users2.properties - org.apache.activemq.jaas.textfiledn.group="groups2.properties"; -}; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties deleted file mode 100644 index 6c19d19..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/conf/users2.properties +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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. - */ -guests=myguests -system=manager -admin=apassword -user=password -guest=password -tester=mypassword -dave=CN=Hello Dave Stanley, OU=FuseSource, O=Progress, L=Unknown, ST=MA, C=US http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/broker2.ks deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ks deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq3625/keys/client2.ts deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml deleted file mode 100644 index 325e354..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/InconsistentConnectorPropertiesBehaviour.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml deleted file mode 100644 index a245028..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/JaasStompSSLBroker.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties deleted file mode 100644 index fcfe558..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/dns.properties +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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. - */ -client=CN=client, OU=activemq, O=apache http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties deleted file mode 100644 index 4171c5f..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/groups.properties +++ /dev/null @@ -1,18 +0,0 @@ -/** - * 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. - */ -admins=system,client -guests=guest http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config deleted file mode 100644 index c3d87c1..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/login.config +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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. - */ -activemq-domain { - - org.apache.activemq.jaas.PropertiesLoginModule requisite - debug=true - org.apache.activemq.jaas.properties.user="users.properties" - org.apache.activemq.jaas.properties.group="groups.properties"; -}; - -activemq-ssl-domain { - org.apache.activemq.jaas.TextFileCertificateLoginModule required - debug=true - org.apache.activemq.jaas.textfiledn.user="dns.properties" - org.apache.activemq.jaas.textfiledn.group="groups.properties"; -}; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties deleted file mode 100644 index 2915bdb..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq4126/users.properties +++ /dev/null @@ -1,18 +0,0 @@ -/** - * 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. - */ -system=manager -guest=password \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml deleted file mode 100644 index 660fff5..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/amq5035/activemq.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java deleted file mode 100644 index 385564e..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/EmbeddedActiveMQ.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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.bugs.embedded; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.log4j.Logger; - -public class EmbeddedActiveMQ { - - private static Logger logger = Logger.getLogger(EmbeddedActiveMQ.class); - - public static void main(String[] args) { - - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - BrokerService brokerService = null; - Connection connection = null; - - logger.info("Start..."); - try { - brokerService = new BrokerService(); - brokerService.setBrokerName("TestMQ"); - brokerService.setUseJmx(true); - logger.info("Broker '" + brokerService.getBrokerName() + "' is starting........"); - brokerService.start(); - ConnectionFactory fac = new ActiveMQConnectionFactory("vm://TestMQ"); - connection = fac.createConnection(); - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = session.createQueue("TEST.QUEUE"); - MessageProducer producer = session.createProducer(queue); - for (int i = 0; i < 1000; i++) { - Message msg = session.createTextMessage("test" + i); - producer.send(msg); - } - logger.info(ThreadExplorer.show("Active threads after start:")); - System.out.println("Press return to stop........"); - String key = br.readLine(); - } - - catch (Exception e) { - e.printStackTrace(); - } - finally { - try { - br.close(); - logger.info("Broker '" + brokerService.getBrokerName() + "' is stopping........"); - connection.close(); - brokerService.stop(); - sleep(8); - logger.info(ThreadExplorer.show("Active threads after stop:")); - - } - catch (Exception e) { - e.printStackTrace(); - } - } - - logger.info("Waiting for list theads is greater then 1 ..."); - int numTh = ThreadExplorer.active(); - - while (numTh > 2) { - sleep(3); - numTh = ThreadExplorer.active(); - logger.info(ThreadExplorer.show("Still active threads:")); - } - - System.out.println("Stop..."); - } - - private static void sleep(int second) { - try { - logger.info("Waiting for " + second + "s..."); - Thread.sleep(second * 1000L); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java deleted file mode 100644 index 4f500c4..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/bugs/embedded/ThreadExplorer.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * 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.bugs.embedded; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; - -public class ThreadExplorer { - - static Logger logger = Logger.getLogger(ThreadExplorer.class); - - public static Thread[] listThreads() { - - int nThreads = Thread.activeCount(); - Thread ret[] = new Thread[nThreads]; - - Thread.enumerate(ret); - - return ret; - - } - - /** - * Helper function to access a thread per name (ignoring case) - * - * @param name - * @return - */ - public static Thread fetchThread(String name) { - Thread[] threadArray = listThreads(); - // for (Thread t : threadArray) - for (int i = 0; i < threadArray.length; i++) { - Thread t = threadArray[i]; - if (t.getName().equalsIgnoreCase(name)) - return t; - } - return null; - } - - /** - * Allow for killing threads - * - * @param threadName - * @param isStarredExp (regular expressions with *) - */ - @SuppressWarnings("deprecation") - public static int kill(String threadName, boolean isStarredExp, String motivation) { - String me = "ThreadExplorer.kill: "; - if (logger.isDebugEnabled()) { - logger.debug("Entering " + me + " with " + threadName + " isStarred: " + isStarredExp); - } - int ret = 0; - Pattern mypattern = null; - if (isStarredExp) { - String realreg = threadName.toLowerCase().replaceAll("\\*", "\\.\\*"); - mypattern = Pattern.compile(realreg); - - } - Thread[] threads = listThreads(); - for (int i = 0; i < threads.length; i++) { - Thread thread = threads[i]; - if (thread == null) - continue; - // kill the thread unless it is not current thread - boolean matches = false; - - if (isStarredExp) { - Matcher matcher = mypattern.matcher(thread.getName().toLowerCase()); - matches = matcher.matches(); - } - else { - matches = (thread.getName().equalsIgnoreCase(threadName)); - } - if (matches && (Thread.currentThread() != thread) && !thread.getName().equals("main")) { - if (logger.isInfoEnabled()) - logger.info("Killing thread named [" + thread.getName() + "]"); // , removing its uncaught - // exception handler to - // avoid ThreadDeath - // exception tracing - // "+motivation ); - - ret++; - - // PK leaving uncaught exception handler otherwise master push - // cannot recover from this error - // thread.setUncaughtExceptionHandler(null); - try { - thread.stop(); - } - catch (ThreadDeath e) { - logger.warn("Thread already death.", e); - } - - } - } - return ret; - } - - public static String show(String title) { - StringBuffer out = new StringBuffer(); - Thread[] threadArray = ThreadExplorer.listThreads(); - - out.append(title + "\n"); - for (int i = 0; i < threadArray.length; i++) { - Thread thread = threadArray[i]; - - if (thread != null) { - out.append("* [" + thread.getName() + "] " + (thread.isDaemon() ? "(Daemon)" : "") + " Group: " + thread.getThreadGroup().getName() + "\n"); - } - else { - out.append("* ThreadDeath: " + thread + "\n"); - } - - } - return out.toString(); - } - - public static int active() { - int count = 0; - Thread[] threadArray = ThreadExplorer.listThreads(); - - for (int i = 0; i < threadArray.length; i++) { - Thread thread = threadArray[i]; - if (thread != null) { - count++; - } - } - - return count; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java index 370dd35..d95a82b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/CompressionOverNetworkTest.java @@ -24,6 +24,7 @@ import java.net.URI; import java.util.Arrays; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.jms.BytesMessage; import javax.jms.Connection; @@ -240,7 +241,8 @@ public class CompressionOverNetworkTest { if (bridges.length > 0) { LOG.info(brokerService + " bridges " + Arrays.toString(bridges)); DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0]; - ConcurrentHashMap forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap(); + ConcurrentMap forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap(); + LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges); if (!forwardingBridges.isEmpty()) { for (DemandSubscription demandSubscription : forwardingBridges.values()) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java index 27c0e58..34c9a1b 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/NetworkLoopBackTest.java @@ -33,7 +33,8 @@ public class NetworkLoopBackTest { TransportConnector transportConnector = brokerServce.addConnector("nio://0.0.0.0:0"); // connection filter is bypassed when scheme is different - final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")"); + final NetworkConnector networkConnector = brokerServce.addNetworkConnector("static:(tcp://" + + transportConnector.getConnectUri().getHost() + ":" + transportConnector.getConnectUri().getPort() + ")"); brokerServce.start(); brokerServce.waitUntilStarted(); @@ -46,7 +47,7 @@ public class NetworkLoopBackTest { } }); - final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.elements().nextElement(); + final DemandForwardingBridgeSupport loopbackBridge = (DemandForwardingBridgeSupport) networkConnector.bridges.values().iterator().next(); assertTrue("nc started", networkConnector.isStarted()); assertTrue("It should get disposed", Wait.waitFor(new Wait.Condition() { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java index a18012e..171fae1 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/network/SimpleNetworkTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue; import java.net.URI; import java.util.Arrays; -import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.jms.Connection; import javax.jms.DeliveryMode; @@ -176,8 +176,8 @@ public class SimpleNetworkTest { if (bridges.length > 0) { LOG.info(brokerService + " bridges " + Arrays.toString(bridges)); DemandForwardingBridgeSupport demandForwardingBridgeSupport = (DemandForwardingBridgeSupport) bridges[0]; - ConcurrentHashMap forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap(); - LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges); + ConcurrentMap forwardingBridges = demandForwardingBridgeSupport.getLocalSubscriptionMap(); + LOG.info(brokerService + " bridge " + demandForwardingBridgeSupport + ", localSubs: " + forwardingBridges); if (!forwardingBridges.isEmpty()) { for (DemandSubscription demandSubscription : forwardingBridges.values()) { if (demandSubscription.getLocalInfo().getDestination().equals(destination)) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java deleted file mode 100644 index e28288b..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/AutoStorePerDestinationTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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.store; - -import java.util.ArrayList; - -import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter; -import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter; - -public class AutoStorePerDestinationTest extends StorePerDestinationTest { - - // use perDestinationFlag to get multiple stores from one match all adapter - @Override - public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception { - - MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter(); - if (deleteAllMessages) { - multiKahaDBPersistenceAdapter.deleteAllMessages(); - } - ArrayList adapters = new ArrayList<>(); - - FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter(); - template.setPersistenceAdapter(createStore(deleteAllMessages)); - template.setPerDestination(true); - adapters.add(template); - - multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters); - brokerService = createBroker(multiKahaDBPersistenceAdapter); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4c717ca5/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java ---------------------------------------------------------------------- diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java deleted file mode 100644 index 028fb55..0000000 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/store/LevelDBStorePerDestinationTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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.store; - -import org.apache.activemq.leveldb.LevelDBStore; -import org.junit.Test; - -import java.io.IOException; - -public class LevelDBStorePerDestinationTest extends StorePerDestinationTest { - - @Override - protected PersistenceAdapter createStore(boolean delete) throws IOException { - LevelDBStore store = new LevelDBStore(); - store.setLogSize(maxFileLength); - if (delete) { - store.deleteAllMessages(); - } - return store; - } - - @Test - @Override - public void testRollbackRecovery() throws Exception { - } - - @Test - @Override - public void testCommitRecovery() throws Exception { - } - -} \ No newline at end of file