activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r886790 - in /activemq/activemq-systest: ./ branches/ tags/ trunk/ trunk/src/ trunk/src/main/ trunk/src/main/java/ trunk/src/main/java/org/ trunk/src/main/java/org/apache/ trunk/src/main/java/org/apache/activemq/ trunk/src/main/java/org/apa...
Date Thu, 03 Dec 2009 14:25:43 GMT
Author: dejanb
Date: Thu Dec  3 14:25:41 2009
New Revision: 886790

URL: http://svn.apache.org/viewvc?rev=886790&view=rev
Log:
Initial commit of systest subproject

Added:
    activemq/activemq-systest/
    activemq/activemq-systest/branches/
    activemq/activemq-systest/tags/
    activemq/activemq-systest/trunk/
    activemq/activemq-systest/trunk/pom.xml
    activemq/activemq-systest/trunk/src/
    activemq/activemq-systest/trunk/src/main/
    activemq/activemq-systest/trunk/src/main/java/
    activemq/activemq-systest/trunk/src/main/java/org/
    activemq/activemq-systest/trunk/src/main/java/org/apache/
    activemq/activemq-systest/trunk/src/main/java/org/apache/activemq/
    activemq/activemq-systest/trunk/src/main/java/org/apache/activemq/activemq/
    activemq/activemq-systest/trunk/src/main/java/org/apache/activemq/activemq/systest/
    activemq/activemq-systest/trunk/src/test/
    activemq/activemq-systest/trunk/src/test/java/
    activemq/activemq-systest/trunk/src/test/java/org/
    activemq/activemq-systest/trunk/src/test/java/org/apache/
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ConsumerThread.java
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/JDBCSpringTest.java
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/MessageDrivenPojo.java
    activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ProducerThread.java
    activemq/activemq-systest/trunk/src/test/resources/
    activemq/activemq-systest/trunk/src/test/resources/activemq-spring-jdbc.xml
    activemq/activemq-systest/trunk/src/test/resources/log4j.properties

Added: activemq/activemq-systest/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/pom.xml?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/pom.xml (added)
+++ activemq/activemq-systest/trunk/pom.xml Thu Dec  3 14:25:41 2009
@@ -0,0 +1,135 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.activemq</groupId>
+  <artifactId>activemq-systest</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>ActiveMQ :: System Tests</name>
+  <description>Complex and long-running tests for ActiveMQ</description>
+  
+  <properties>
+  	<activemq-version>5.4-SNAPSHOT</activemq-version>
+  	<spring-version>2.5.6</spring-version>
+  </properties>
+  
+  <dependencies>
+  	<dependency>
+  		<groupId>org.apache.activemq</groupId>
+  		<artifactId>activemq-core</artifactId>
+  		<version>${activemq-version}</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.apache.activemq</groupId>
+  		<artifactId>activemq-pool</artifactId>
+  		<version>${activemq-version}</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.springframework</groupId>
+  		<artifactId>spring</artifactId>
+  		<version>${spring-version}</version>
+  	</dependency>
+  	<dependency>
+    	<groupId>org.apache.xbean</groupId>
+    	<artifactId>xbean-spring</artifactId>
+    	<version>3.6</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging-api</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+    	<groupId>log4j</groupId>
+    	<artifactId>log4j</artifactId>
+    	<version>1.2.14</version>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.derby</groupId>
+    	<artifactId>derby</artifactId>
+    	<version>10.1.3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <optimize>true</optimize>
+          <debug>true</debug>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>pertest</forkMode>
+          <childDelegation>false</childDelegation>
+          <useFile>true</useFile>
+          <argLine>-Xmx512M</argLine>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <failIfNoTests>false</failIfNoTests>
+
+           <systemProperties>
+            <property>
+              <name>org.apache.activemq.default.directory.prefix</name>
+              <value>target/</value>
+            </property>
+            <!-- Uncomment the following if you want to configure custom logging (using
src/test/resources/log4j.properties)
+                 while running mvn:test
+                 Note: if you want to see log messages on the console window remove
+                       "redirectTestOutputToFile" from the parent pom
+            -->
+            <!--           
+            <property>
+              <name>log4j.configuration</name>
+              <value>file:target/test-classes/log4j.properties</value>
+            </property>
+            -->
+          </systemProperties>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-clean-plugin</artifactId>
+        <configuration>
+          <filesets>
+            <fileset>
+            	<directory>${basedir}</directory>
+            	 <includes>
+            	 	<include>derby.log</include>
+            	 	<include>derbydb</include>
+            	 </includes>
+            </fileset>
+          </filesets>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ConsumerThread.java
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ConsumerThread.java?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ConsumerThread.java
(added)
+++ activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ConsumerThread.java
Thu Dec  3 14:25:41 2009
@@ -0,0 +1,169 @@
+/**
+ * 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.activemq.systest;
+
+
+import java.util.Random;
+
+import javax.jms.ConnectionFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.jms.connection.SingleConnectionFactory;
+import org.springframework.jms.listener.DefaultMessageListenerContainer;
+
+public class ConsumerThread extends Thread {	
+	private DefaultMessageListenerContainer container;
+	private MessageDrivenPojo messageListener;	
+	private boolean run;
+	private String destination;
+	private ConnectionFactory connectionFactory;
+	private boolean durable;			
+	private int concurrentConsumers;
+	private boolean sessionTransacted;
+	private boolean pubSubDomain;
+	private boolean running;
+	private Log log = LogFactory.getLog(ConsumerThread.class);
+	private int numberOfQueues;
+	private String consumerName;
+	
+	@Override
+	public void run() {		
+		run = true;
+		createContainer();		
+		container.initialize();				
+		container.start();
+		
+		running = true;
+		
+		while (run) {
+			try {
+				Thread.sleep(100);
+			} catch (InterruptedException e) {
+				e.printStackTrace();			
+			}			
+		}
+		
+		container.stop();
+		container.destroy();
+		
+		if (connectionFactory instanceof SingleConnectionFactory) {
+			((SingleConnectionFactory)connectionFactory).destroy();
+		}
+		
+		log.info("ConsumerThread closing down");
+	}
+
+	private DefaultMessageListenerContainer createContainer() {
+		Random generator = new Random(consumerName.hashCode());
+		int queueSuffix = generator.nextInt(numberOfQueues);
+		
+		
+		container = new DefaultMessageListenerContainer();				
+		container.setPubSubDomain(pubSubDomain);
+		container.setDestinationName(destination + queueSuffix);				
+		container.setMessageListener(messageListener);
+		container.setConnectionFactory(connectionFactory);	
+		container.setConcurrentConsumers(concurrentConsumers);
+		container.setSessionTransacted(sessionTransacted);
+
+		container.afterPropertiesSet();
+		log.info("subscribing to " + destination + queueSuffix);
+		return container;
+	}
+		
+	/**
+	 * @param messageListener the messageListener to set
+	 */
+	public void setMessageDrivenPojo(MessageDrivenPojo messageListener) {
+		this.messageListener = messageListener;
+	}
+
+	/**
+	 * @param run the run to set
+	 */
+	public void setRun(boolean run) {
+		this.run = run;
+	}
+
+	/**
+	 * @param destination the destination to set
+	 */
+	public void setDestination(String destination) {
+		this.destination = destination;
+	}
+	
+	public void setNumberOfQueues(int no) {
+		this.numberOfQueues = no;
+	}
+	
+	public int getNumberOfQueues() {
+		return this.numberOfQueues;
+	}
+	
+
+	public void setConsumerName(String name) {
+		this.consumerName = name;
+	}
+
+	/**
+	 * @param connectionFactory the connectionFactory to set
+	 */
+	public void setConnectionFactory(ConnectionFactory connectionFactory) {
+		this.connectionFactory = connectionFactory;
+	}
+
+	/**
+	 * @param durable the durable to set
+	 */
+	public void setDurable(boolean durable) {
+		this.durable = durable;
+	}
+
+	/**
+	 * @param concurrentConsumers the concurrentConsumers to set
+	 */
+	public void setConcurrentConsumers(int concurrentConsumers) {
+		this.concurrentConsumers = concurrentConsumers;
+	}
+
+	/**
+	 * @param sessionTransacted the sessionTransacted to set
+	 */
+	public void setSessionTransacted(boolean sessionTransacted) {
+		this.sessionTransacted = sessionTransacted;
+	}
+
+	/**
+	 * @param pubSubDomain the pubSubDomain to set
+	 */
+	public void setPubSubDomain(boolean pubSubDomain) {
+		this.pubSubDomain = pubSubDomain;
+	}
+	
+	/**
+	 * @return the messageListener
+	 */
+	public MessageDrivenPojo getMessageDrivenPojo() {
+		return messageListener;
+	}	
+	
+	public boolean isRunning() {
+		return running;
+	}
+}

Added: activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/JDBCSpringTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/JDBCSpringTest.java?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/JDBCSpringTest.java
(added)
+++ activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/JDBCSpringTest.java
Thu Dec  3 14:25:41 2009
@@ -0,0 +1,150 @@
+/**
+ * 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.activemq.systest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.ConnectionFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQPrefetchPolicy;
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class JDBCSpringTest extends TestCase {	
+	
+	private static Log log = LogFactory.getLog(JDBCSpringTest.class);
+	
+      int numberOfConsumerThreads = 20;
+      int numberOfProducerThreads = 20;
+      int numberOfMessages = 50;
+      int numberOfQueues = 5;
+      String url = "tcp://localhost:61616";
+	
+      BrokerService broker;
+      
+    public void setUp() throws Exception {
+    	broker = BrokerFactory.createBroker("xbean:activemq-spring-jdbc.xml");
+    	broker.start();
+    	broker.waitUntilStarted();
+    }
+    
+    
+	protected void tearDown() throws Exception {
+		broker.stop();
+		broker.waitUntilStopped();
+	}
+
+
+	public void testJDBCSpringTest() throws Exception {
+		log.info("Using " + numberOfConsumerThreads + " consumers, " + 
+				numberOfProducerThreads + " producers, " + 
+				numberOfMessages + " messages per publisher, and " +
+				numberOfQueues + " queues.");
+		
+		ConnectionFactory connectionFactory;
+
+		ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
+		prefetch.setQueuePrefetch(1);
+		ActiveMQConnectionFactory	amq = new ActiveMQConnectionFactory(url);
+		amq.setPrefetchPolicy(prefetch);
+	  
+		connectionFactory = new PooledConnectionFactory(amq);
+		((PooledConnectionFactory)connectionFactory).setMaxConnections(5);
+
+
+		StringBuffer buffer = new StringBuffer();		
+		for (int i=0; i<2048; i++) {
+			buffer.append(".");
+		}		
+		String twoKbMessage = buffer.toString();
+		
+		List<ProducerThread> ProducerThreads = new ArrayList<ProducerThread>();
+		for (int i=0; i<numberOfProducerThreads; i++) {
+			ProducerThread thread = new ProducerThread();
+			thread.setMessage(twoKbMessage);
+			thread.setNumberOfMessagesToSend(numberOfMessages);
+			thread.setNumberOfQueues(numberOfQueues);
+			thread.setQueuePrefix("AMQ-2436.queue.");
+			thread.setConnectionFactory(connectionFactory);
+			//thread.setSendDelay(100);
+			ProducerThreads.add(thread);
+		}
+		
+		List<Thread> ConsumerThreads = new ArrayList<Thread>();
+		for (int i=0; i<numberOfConsumerThreads; i++) {
+			ConsumerThread thread = new ConsumerThread();
+			MessageDrivenPojo mdp1 = new MessageDrivenPojo();
+			thread.setMessageDrivenPojo(mdp1);
+			thread.setConcurrentConsumers(1);
+			thread.setConnectionFactory(connectionFactory);
+			thread.setDestination("AMQ-2436.queue.");
+			thread.setPubSubDomain(false);
+			thread.setSessionTransacted(true);
+			thread.setNumberOfQueues(numberOfQueues);
+			thread.setConsumerName("consumer" + i);
+			ConsumerThreads.add(thread);
+			thread.start();
+		}
+		
+		
+		for (ProducerThread thread : ProducerThreads) {
+			thread.start();
+		}
+		
+		boolean finished = false;	
+		int previous = 0;
+		while (!finished) {
+                    
+			int totalMessages = 0;	
+			for (Thread thread : ConsumerThreads) {
+				totalMessages += ((ConsumerThread)thread).getMessageDrivenPojo().getMessageCount();
+			}
+			log.info(totalMessages + " received so far...");
+			if (totalMessages != 0 && previous == totalMessages) {
+				for (Thread thread : ConsumerThreads) {
+					((ConsumerThread)thread).setRun(false);
+				}
+				fail("Received " + totalMessages + ", expected " + (numberOfMessages * numberOfProducerThreads));
+			}
+			previous = totalMessages;
+			
+			if (totalMessages >= (numberOfMessages * numberOfProducerThreads)) {
+				finished = true;
+				log.info("Received all " + totalMessages + " messages. Finishing.");
+				
+				for (Thread thread : ConsumerThreads) {
+					((ConsumerThread)thread).setRun(false);
+				}
+				for (Thread thread : ConsumerThreads) {
+					thread.join();
+				}
+
+			} else {
+				Thread.sleep(1000);
+			}
+		}
+	}	
+    
+}

Added: activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/MessageDrivenPojo.java
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/MessageDrivenPojo.java?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/MessageDrivenPojo.java
(added)
+++ activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/MessageDrivenPojo.java
Thu Dec  3 14:25:41 2009
@@ -0,0 +1,81 @@
+/**
+ * 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.activemq.systest;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MessageDrivenPojo implements MessageListener, Serializable {
+	private Log log = LogFactory.getLog(MessageDrivenPojo.class);
+	private AtomicInteger messageCount = new AtomicInteger();	
+
+	/*
+	 * (non-Javadoc)
+	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
+	 */
+	public void onMessage(Message message) {				
+		messageCount.incrementAndGet();
+		
+		if (log.isDebugEnabled()) {
+			try {
+				logMessage(message);
+			} catch (Exception e) {
+				log.error("Error:", e);
+			}
+		}
+		
+		try {
+			Thread.sleep(200);
+		} catch (InterruptedException ex ) {
+			log.error(ex);
+		}
+	}
+	
+	private void logMessage(Message message) throws Exception {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append("\nJMSMessageID:");
+		buffer.append(message.getJMSMessageID());
+		buffer.append("\nJMSCorrelationID:");
+		buffer.append(message.getJMSMessageID());
+		buffer.append("\nMessage Contents:\n");
+		
+		if (message instanceof TextMessage) { 
+			buffer.append(((TextMessage)message).getText());
+		} else {
+			buffer.append(message.toString());
+		}
+		
+		log.debug(buffer.toString());
+	}
+
+	/**
+	 * @return the stats
+	 */
+	protected int getMessageCount() {
+		return messageCount.get();
+	}		
+}

Added: activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ProducerThread.java
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ProducerThread.java?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ProducerThread.java
(added)
+++ activemq/activemq-systest/trunk/src/test/java/org/apache/activemq/activemq/systest/ProducerThread.java
Thu Dec  3 14:25:41 2009
@@ -0,0 +1,117 @@
+/**
+ * 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.activemq.systest;
+
+import java.util.Random;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.springframework.jms.core.JmsTemplate;
+import org.springframework.jms.core.MessageCreator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class ProducerThread extends Thread {	
+	private JmsTemplate jmsTemplate;
+	private int numberOfTopics;
+	private int numberOfMessagesToSend;	
+	private int messagesSent;
+	private Random generator;
+	private String queuePrefix;
+	private ConnectionFactory connectionFactory;
+	private String message;	
+	private MessageCreator messageCreator;
+	private int sendDelay;
+	private Log log = LogFactory.getLog(ProducerThread.class);
+	
+	@Override
+	public void run() {
+		initialize();
+		Random generator = new Random(Thread.currentThread().getName().hashCode());
+		
+		while (messagesSent < numberOfMessagesToSend) {
+			int queueSuffix = generator.nextInt(numberOfTopics);			
+			jmsTemplate.send(queuePrefix + queueSuffix, messageCreator);			
+			messagesSent++;
+			log.debug(Thread.currentThread().getName() + 
+					": sent msg #" + messagesSent);
+			try {
+				Thread.sleep(sendDelay);
+			} catch (InterruptedException e) {				
+				e.printStackTrace();
+			}
+		}
+		
+		log.info("ProducerThread shutting down.");
+	}
+	
+	private void initialize() {
+		jmsTemplate = new JmsTemplate();
+		jmsTemplate.setPubSubDomain(false);
+		jmsTemplate.setConnectionFactory(connectionFactory);
+		
+		messageCreator = new MessageCreator() {
+			public Message createMessage(Session session) throws JMSException {
+				return session.createTextMessage(message);
+			}			
+		};
+	}
+
+	/**
+	 * @param numberOfTopics the numberOfTopics to set
+	 */
+	protected void setNumberOfQueues(int numberOfTopics) {
+		this.numberOfTopics = numberOfTopics;
+	}
+	/**
+	 * @param queuePrefix the queuePrefix to set
+	 */
+	protected void setQueuePrefix(String queuePrefix) {
+		this.queuePrefix = queuePrefix;
+	}
+	/**
+	 * @param connectionFactory the connectionFactory to set
+	 */
+	protected void setConnectionFactory(ConnectionFactory connectionFactory) {
+		this.connectionFactory = connectionFactory;
+	}
+	/**
+	 * @param message the message to set
+	 */
+	protected void setMessage(String message) {
+		this.message = message;
+	}
+
+	/**
+	 * @param numberOfMessagesToSend the numberOfMessagesToSend to set
+	 */
+	protected void setNumberOfMessagesToSend(int numberOfMessagesToSend) {
+		this.numberOfMessagesToSend = numberOfMessagesToSend;
+	}
+	
+	public void setSendDelay(int sendDelay) {
+		this.sendDelay = sendDelay;
+	}
+	
+	public int getMessagesSent() {
+		return messagesSent;
+	}
+}

Added: activemq/activemq-systest/trunk/src/test/resources/activemq-spring-jdbc.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/resources/activemq-spring-jdbc.xml?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/resources/activemq-spring-jdbc.xml (added)
+++ activemq/activemq-systest/trunk/src/test/resources/activemq-spring-jdbc.xml Thu Dec  3
14:25:41 2009
@@ -0,0 +1,69 @@
+<!--
+    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 -->
+<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
  
+  http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="target/"
useJmx="false" deleteAllMessagesOnStartup="true">
+         
+        <persistenceAdapter>
+            <jdbcPersistenceAdapter dataSource="#derby-ds" dataDirectory="target/"/>
+        </persistenceAdapter>
+        
+        <destinationPolicy>
+            <policyMap>
+                <policyEntries>
+                    <policyEntry queue=">" memoryLimit="10240"/>
+                    <policyEntry topic=">" memoryLimit="10240">
+                    </policyEntry>
+                </policyEntries>
+            </policyMap>
+        </destinationPolicy>
+        
+        
+        <systemUsage>
+            <systemUsage>
+                <memoryUsage>
+                    <memoryUsage limit="102400"/>
+                </memoryUsage>
+                <storeUsage>
+                    <storeUsage limit="1 gb" name="foo"/>
+                </storeUsage>
+                <tempUsage>
+                    <tempUsage limit="100 mb"/>
+                </tempUsage>
+            </systemUsage>
+        </systemUsage>
+
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
+        </transportConnectors>
+    </broker>
+
+
+    <bean id="derby-ds" class="org.apache.derby.jdbc.EmbeddedDataSource">
+      <property name="databaseName" value="derbydb"/>
+      <property name="createDatabase" value="create"/>
+    </bean>
+
+</beans>
+<!-- END SNIPPET: example -->

Added: activemq/activemq-systest/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-systest/trunk/src/test/resources/log4j.properties?rev=886790&view=auto
==============================================================================
--- activemq/activemq-systest/trunk/src/test/resources/log4j.properties (added)
+++ activemq/activemq-systest/trunk/src/test/resources/log4j.properties Thu Dec  3 14:25:41
2009
@@ -0,0 +1,37 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out, stdout
+
+log4j.logger.org.apache.activemq.spring=WARN
+#log4j.logger.org.apache.activemq.usecases=DEBUG
+#log4j.logger.org.apache.activemq.broker.region=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/activemq-test.log
+log4j.appender.out.append=true



Mime
View raw message