You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/02/06 23:56:13 UTC
svn commit: r1443267 [2/4] - in
/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq: ./
advisory/ blob/ broker/jmx/ broker/policy/ broker/store/ bugs/amq1095/
config/ console/command/ filter/ jndi/ load/ memory/ network/ network/jms/
...
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/SpringTestSupport.java Wed Feb 6 22:56:12 2013
@@ -22,25 +22,26 @@ import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.context.support.AbstractApplicationContext;
/**
* A useful base class for spring based unit test cases
- *
- *
+ *
+ *
*/
public abstract class SpringTestSupport extends TestCase {
protected AbstractApplicationContext context;
+ @Override
protected void setUp() throws Exception {
context = createApplicationContext();
}
protected abstract AbstractApplicationContext createApplicationContext();;
+ @Override
protected void tearDown() throws Exception {
if (context != null) {
context.destroy();
@@ -55,7 +56,7 @@ public abstract class SpringTestSupport
return bean;
}
- protected void assertSetEquals(String description, Object[] expected, Set actual) {
+ protected void assertSetEquals(String description, Object[] expected, Set<?> actual) {
Set<Object> expectedSet = new HashSet<Object>();
expectedSet.addAll(Arrays.asList(expected));
assertEquals(description, expectedSet, actual);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/TestSupport.java Wed Feb 6 22:56:12 2013
@@ -18,7 +18,6 @@ package org.apache.activemq;
import java.io.File;
import java.io.IOException;
-import java.util.Enumeration;
import java.util.Map;
import javax.jms.Connection;
@@ -27,8 +26,6 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;
-import junit.framework.TestCase;
-
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.region.DestinationStatistics;
import org.apache.activemq.broker.region.RegionBroker;
@@ -42,13 +39,11 @@ import org.apache.activemq.store.jdbc.JD
import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
import org.apache.activemq.store.leveldb.LevelDBPersistenceAdapter;
import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Useful base class for unit test cases
- *
- *
+ *
+ *
*/
public abstract class TestSupport extends CombinationTestSupport {
@@ -146,7 +141,7 @@ public abstract class TestSupport extend
recursiveDelete(new File(System.getProperty("derby.system.home")));
}
}
-
+
public static DestinationStatistics getDestinationStatistics(BrokerService broker, ActiveMQDestination destination) {
DestinationStatistics result = null;
org.apache.activemq.broker.region.Destination dest = getDestination(broker, destination);
@@ -155,7 +150,7 @@ public abstract class TestSupport extend
}
return result;
}
-
+
public static org.apache.activemq.broker.region.Destination getDestination(BrokerService target, ActiveMQDestination destination) {
org.apache.activemq.broker.region.Destination result = null;
for (org.apache.activemq.broker.region.Destination dest : getDestinationMap(target, destination).values()) {
@@ -184,7 +179,7 @@ public abstract class TestSupport extend
public PersistenceAdapter setDefaultPersistenceAdapter(BrokerService broker) throws IOException {
return setPersistenceAdapter(broker, defaultPersistenceAdapter);
}
-
+
public PersistenceAdapter setPersistenceAdapter(BrokerService broker, PersistenceAdapterChoice choice) throws IOException {
PersistenceAdapter adapter = null;
switch (choice) {
@@ -212,7 +207,7 @@ public abstract class TestSupport extend
* Test if base directory contains spaces
*/
protected void assertBaseDirectoryContainsSpaces() {
- assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" "));
+ assertFalse("Base directory cannot contain spaces.", new File(System.getProperty("basedir", ".")).getAbsoluteFile().toString().contains(" "));
}
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java Wed Feb 6 22:56:12 2013
@@ -33,14 +33,13 @@ import org.apache.activemq.broker.region
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ConsumerControl;
-import org.apache.activemq.command.ConsumerInfo;
import org.apache.activemq.command.ExceptionResponse;
import org.apache.activemq.spring.SpringConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport {
@@ -99,7 +98,7 @@ public class ZeroPrefetchConsumerTest ex
}
// now lets receive it
MessageConsumer consumer = session.createConsumer(queue);
-
+
session.createConsumer(queue);
TextMessage answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg1");
@@ -145,7 +144,7 @@ public class ZeroPrefetchConsumerTest ex
answer = (TextMessage)consumer.receiveNoWait();
assertNull("Should have not received a message!", answer);
}
-
+
public void testTwoConsumers() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -164,7 +163,7 @@ public class ZeroPrefetchConsumerTest ex
answer = (TextMessage)consumer2.receiveNoWait();
assertNull("Should have not received a message!", answer);
}
-
+
// https://issues.apache.org/activemq/browse/AMQ-2567
public void testManyMessageConsumer() throws Exception {
doTestManyMessageConsumer(true);
@@ -173,7 +172,7 @@ public class ZeroPrefetchConsumerTest ex
public void testManyMessageConsumerNoTransaction() throws Exception {
doTestManyMessageConsumer(false);
}
-
+
private void doTestManyMessageConsumer(boolean transacted) throws Exception {
Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
@@ -191,7 +190,7 @@ public class ZeroPrefetchConsumerTest ex
}
// now lets receive it
MessageConsumer consumer = session.createConsumer(queue);
-
+
MessageConsumer consumer2 = session.createConsumer(queue);
TextMessage answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg1");
@@ -214,26 +213,26 @@ public class ZeroPrefetchConsumerTest ex
if (transacted) {
session.commit();
}
- // Now using other consumer
+ // Now using other consumer
// this call should return the next message (Msg5) still left on the queue
answer = (TextMessage)consumer2.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg5");
if (transacted) {
session.commit();
}
- // Now using other consumer
+ // Now using other consumer
// this call should return the next message (Msg5) still left on the queue
answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg6");
// read one more message without commit
- // Now using other consumer
+ // Now using other consumer
// this call should return the next message (Msg5) still left on the queue
answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg7");
if (transacted) {
session.commit();
}
- // Now using other consumer
+ // Now using other consumer
// this call should return the next message (Msg5) still left on the queue
answer = (TextMessage)consumer2.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg8");
@@ -251,7 +250,7 @@ public class ZeroPrefetchConsumerTest ex
public void testManyMessageConsumerWithSendNoTransaction() throws Exception {
doTestManyMessageConsumerWithSend(false);
}
-
+
private void doTestManyMessageConsumerWithSend(boolean transacted) throws Exception {
Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
@@ -269,7 +268,7 @@ public class ZeroPrefetchConsumerTest ex
}
// now lets receive it
MessageConsumer consumer = session.createConsumer(queue);
-
+
MessageConsumer consumer2 = session.createConsumer(queue);
TextMessage answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg1");
@@ -297,23 +296,23 @@ public class ZeroPrefetchConsumerTest ex
if (transacted) {
session.commit();
}
-
+
answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg6");
// read one more message without commit
- // and using other consumer
+ // and using other consumer
answer = (TextMessage)consumer2.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg7");
if (transacted) {
session.commit();
}
-
+
answer = (TextMessage)consumer2.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg8");
if (transacted) {
session.commit();
}
-
+
answer = (TextMessage)consumer.receive(5000);
assertEquals("Should have received a message!", answer.getText(), "Msg9");
if (transacted) {
@@ -372,6 +371,7 @@ public class ZeroPrefetchConsumerTest ex
return brokerService;
}
+ @Override
protected void setUp() throws Exception {
bindAddress = "tcp://localhost:0";
super.setUp();
@@ -380,12 +380,14 @@ public class ZeroPrefetchConsumerTest ex
connection.start();
queue = createQueue();
}
-
+
+ @Override
protected void startBroker() throws Exception {
super.startBroker();
bindAddress = broker.getTransportConnectors().get(0).getConnectUri().toString();
}
+ @Override
protected void tearDown() throws Exception {
connection.close();
super.tearDown();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTempDestinationTests.java Wed Feb 6 22:56:12 2013
@@ -16,7 +16,23 @@
*/
package org.apache.activemq.advisory;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.Topic;
+
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
@@ -26,10 +42,6 @@ import org.apache.activemq.broker.region
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQMessage;
-import javax.jms.*;
-import java.util.ArrayList;
-import java.util.List;
-
public class AdvisoryTempDestinationTests extends TestCase {
protected static final int MESSAGE_COUNT = 2000;
@@ -44,6 +56,7 @@ public class AdvisoryTempDestinationTest
TemporaryQueue queue = s.createTemporaryQueue();
MessageConsumer consumer = s.createConsumer(queue);
consumer.setMessageListener(new MessageListener() {
+ @Override
public void onMessage(Message message) {
}
});
@@ -66,6 +79,7 @@ public class AdvisoryTempDestinationTest
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = s.createTemporaryQueue();
MessageConsumer consumer = s.createConsumer(queue);
+ assertNotNull(consumer);
Topic advisoryTopic = AdvisorySupport
.getSlowConsumerAdvisoryTopic((ActiveMQDestination) queue);
@@ -86,6 +100,7 @@ public class AdvisoryTempDestinationTest
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue queue = s.createTemporaryQueue();
MessageConsumer consumer = s.createConsumer(queue);
+ assertNotNull(consumer);
Topic advisoryTopic = AdvisorySupport.getMessageDeliveredAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
@@ -130,6 +145,7 @@ public class AdvisoryTempDestinationTest
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
+ assertNotNull(consumer);
Topic advisoryTopic = AdvisorySupport.getExpiredMessageTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
@@ -146,6 +162,7 @@ public class AdvisoryTempDestinationTest
assertNotNull(msg);
}
+ @Override
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker();
@@ -156,6 +173,7 @@ public class AdvisoryTempDestinationTest
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
connection.close();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java Wed Feb 6 22:56:12 2013
@@ -26,7 +26,9 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;
+
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQPrefetchPolicy;
@@ -38,7 +40,7 @@ import org.apache.activemq.command.Activ
import org.apache.activemq.command.ActiveMQMessage;
/**
- *
+ *
*/
public class AdvisoryTests extends TestCase {
protected static final int MESSAGE_COUNT = 2000;
@@ -46,13 +48,14 @@ public class AdvisoryTests extends TestC
protected Connection connection;
protected String bindAddress = ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL;
protected int topicCount;
-
+
public void testNoSlowConsumerAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
consumer.setMessageListener(new MessageListener() {
+ @Override
public void onMessage(Message message) {
}
});
@@ -70,12 +73,13 @@ public class AdvisoryTests extends TestC
Message msg = advisoryConsumer.receive(1000);
assertNull(msg);
}
-
+
public void testSlowConsumerAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
-
+ assertNotNull(consumer);
+
Topic advisoryTopic = AdvisorySupport
.getSlowConsumerAdvisoryTopic((ActiveMQDestination) queue);
s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -90,56 +94,58 @@ public class AdvisoryTests extends TestC
Message msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
}
-
- public void testMessageDeliveryAdvisory() throws Exception {
+
+ public void testMessageDeliveryAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
-
+ assertNotNull(consumer);
+
Topic advisoryTopic = AdvisorySupport.getMessageDeliveredAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);
-
+
BytesMessage m = s.createBytesMessage();
m.writeBytes(new byte[1024]);
producer.send(m);
-
+
Message msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
}
-
- public void testMessageConsumedAdvisory() throws Exception {
+
+ public void testMessageConsumedAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
-
+
Topic advisoryTopic = AdvisorySupport.getMessageConsumedAdvisoryTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);
-
+
BytesMessage m = s.createBytesMessage();
m.writeBytes(new byte[1024]);
producer.send(m);
String id = m.getJMSMessageID();
Message msg = consumer.receive(1000);
assertNotNull(msg);
-
+
msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
-
+
ActiveMQMessage message = (ActiveMQMessage) msg;
ActiveMQMessage payload = (ActiveMQMessage) message.getDataStructure();
String originalId = payload.getJMSMessageID();
assertEquals(originalId, id);
}
-
+
public void testMessageExpiredAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName());
MessageConsumer consumer = s.createConsumer(queue);
-
+ assertNotNull(consumer);
+
Topic advisoryTopic = AdvisorySupport.getExpiredMessageTopic((ActiveMQDestination) queue);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
@@ -150,16 +156,17 @@ public class AdvisoryTests extends TestC
m.writeBytes(new byte[1024]);
producer.send(m);
}
-
+
Message msg = advisoryConsumer.receive(2000);
assertNotNull(msg);
}
-
+
public void xtestMessageDiscardedAdvisory() throws Exception {
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = s.createTopic(getClass().getName());
MessageConsumer consumer = s.createConsumer(topic);
-
+ assertNotNull(consumer);
+
Topic advisoryTopic = AdvisorySupport.getMessageDiscardedAdvisoryTopic((ActiveMQDestination) topic);
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
//start throwing messages at the consumer
@@ -169,12 +176,12 @@ public class AdvisoryTests extends TestC
BytesMessage m = s.createBytesMessage();
producer.send(m);
}
-
+
Message msg = advisoryConsumer.receive(1000);
assertNotNull(msg);
}
-
+ @Override
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker();
@@ -185,6 +192,7 @@ public class AdvisoryTests extends TestC
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
connection.close();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/ProducerListenerTest.java Wed Feb 6 22:56:12 2013
@@ -30,8 +30,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
- *
+ *
+ *
*/
public class ProducerListenerTest extends EmbeddedBrokerTestSupport implements ProducerListener {
private static final Logger LOG = LoggerFactory.getLogger(ProducerListenerTest.class);
@@ -78,10 +78,12 @@ public class ProducerListenerTest extend
assertConsumerEvent(0, false);
}
+ @Override
public void onProducerEvent(ProducerEvent event) {
eventQueue.add(event);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -91,6 +93,7 @@ public class ProducerListenerTest extend
producerEventSource.setProducerListener(this);
}
+ @Override
protected void tearDown() throws Exception {
if (producerEventSource != null) {
producerEventSource.stop();
@@ -119,6 +122,8 @@ public class ProducerListenerTest extend
Session answer = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = answer.createProducer(destination);
+ assertNotNull(producer);
+
return answer;
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobDownloadStrategyTest.java Wed Feb 6 22:56:12 2013
@@ -24,8 +24,6 @@ import java.net.URL;
import javax.jms.JMSException;
-import junit.framework.Assert;
-
import org.apache.activemq.command.ActiveMQBlobMessage;
public class FTPBlobDownloadStrategyTest extends FTPTestSupport {
@@ -34,7 +32,7 @@ public class FTPBlobDownloadStrategyTest
public void testDownload() throws Exception {
setConnection();
-
+
// create file
File uploadFile = new File(ftpHomeDirFile, "test.txt");
FileWriter wrt = new FileWriter(uploadFile);
@@ -46,7 +44,7 @@ public class FTPBlobDownloadStrategyTest
}
wrt.close();
-
+
ActiveMQBlobMessage message = new ActiveMQBlobMessage();
BlobDownloadStrategy strategy = new FTPBlobDownloadStrategy(new BlobTransferPolicy());
InputStream stream;
@@ -59,16 +57,16 @@ public class FTPBlobDownloadStrategyTest
sb.append((char)i);
i = stream.read();
}
- Assert.assertEquals("hello world", sb.toString().substring(0, "hello world".length()));
- Assert.assertEquals(FILE_SIZE, sb.toString().substring("hello world".length()).length());
+ assertEquals("hello world", sb.toString().substring(0, "hello world".length()));
+ assertEquals(FILE_SIZE, sb.toString().substring("hello world".length()).length());
assertTrue(uploadFile.exists());
strategy.deleteFile(message);
assertFalse(uploadFile.exists());
-
+
} catch (Exception e) {
e.printStackTrace();
- Assert.assertTrue(false);
+ assertTrue(false);
}
}
@@ -79,15 +77,15 @@ public class FTPBlobDownloadStrategyTest
message.setURL(new URL("ftp://" + userNamePass + "_wrong:" + userNamePass + "@localhost:" + ftpPort + "/ftptest/"));
strategy.getInputStream(message);
} catch(JMSException e) {
- Assert.assertEquals("Wrong Exception", "Cant Authentificate to FTP-Server", e.getMessage());
+ assertEquals("Wrong Exception", "Cant Authentificate to FTP-Server", e.getMessage());
return;
} catch(Exception e) {
System.out.println(e);
- Assert.assertTrue("Wrong Exception "+ e, false);
+ assertTrue("Wrong Exception "+ e, false);
return;
}
- Assert.assertTrue("Expect Exception", false);
+ assertTrue("Expect Exception", false);
}
public void testWrongFTPPort() throws MalformedURLException {
@@ -97,15 +95,14 @@ public class FTPBlobDownloadStrategyTest
message.setURL(new URL("ftp://" + userNamePass + ":" + userNamePass + "@localhost:" + 422 + "/ftptest/"));
strategy.getInputStream(message);
} catch(JMSException e) {
- Assert.assertEquals("Wrong Exception", "Problem connecting the FTP-server", e.getMessage());
+ assertEquals("Wrong Exception", "Problem connecting the FTP-server", e.getMessage());
return;
} catch(Exception e) {
e.printStackTrace();
- Assert.assertTrue("Wrong Exception "+ e, false);
+ assertTrue("Wrong Exception "+ e, false);
return;
}
- Assert.assertTrue("Expect Exception", false);
+ assertTrue("Expect Exception", false);
}
-
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobTest.java Wed Feb 6 22:56:12 2013
@@ -26,13 +26,10 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
-import junit.framework.Assert;
-
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.BlobMessage;
import org.apache.activemq.command.ActiveMQBlobMessage;
-
public class FTPBlobTest extends FTPTestSupport {
public void testBlobFile() throws Exception {
@@ -57,7 +54,7 @@ public class FTPBlobTest extends FTPTest
// check message send
Message msg = consumer.receive(1000);
- Assert.assertTrue(msg instanceof ActiveMQBlobMessage);
+ assertTrue(msg instanceof ActiveMQBlobMessage);
assertEquals("name is correct", "fileName", ((ActiveMQBlobMessage)msg).getName());
InputStream input = ((ActiveMQBlobMessage) msg).getInputStream();
@@ -68,8 +65,8 @@ public class FTPBlobTest extends FTPTest
i = input.read();
}
input.close();
- File uploaded = new File(ftpHomeDirFile, msg.getJMSMessageID().toString().replace(":", "_"));
- Assert.assertEquals(content, b.toString());
+ File uploaded = new File(ftpHomeDirFile, msg.getJMSMessageID().toString().replace(":", "_"));
+ assertEquals(content, b.toString());
assertTrue(uploaded.exists());
((ActiveMQBlobMessage)msg).deleteFile();
assertFalse(uploaded.exists());
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FTPBlobUploadStrategyTest.java Wed Feb 6 22:56:12 2013
@@ -23,8 +23,6 @@ import java.io.FileWriter;
import javax.jms.JMSException;
import javax.jms.Session;
-import junit.framework.Assert;
-
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.command.ActiveMQBlobMessage;
@@ -35,22 +33,22 @@ public class FTPBlobUploadStrategyTest e
public void testFileUpload() throws Exception {
setConnection();
- File file = File.createTempFile("amq-data-file-", ".dat");
+ File file = File.createTempFile("amq-data-file-", ".dat");
// lets write some data
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.append("hello world");
writer.close();
-
+
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
((ActiveMQConnection)connection).setCopyMessageOnSend(false);
-
+
ActiveMQBlobMessage message = (ActiveMQBlobMessage) ((ActiveMQSession)session).createBlobMessage(file);
message.setMessageId(new MessageId("testmessage"));
message.onSend();
- Assert.assertEquals(ftpUrl + "testmessage", message.getURL().toString());
+ assertEquals(ftpUrl + "testmessage", message.getURL().toString());
File uploaded = new File(ftpHomeDirFile, "testmessage");
assertTrue("File doesn't exists", uploaded.exists());
- }
+ }
public void testWriteDenied() throws Exception {
userNamePass = "guest";
@@ -60,10 +58,10 @@ public class FTPBlobUploadStrategyTest e
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.append("hello world");
writer.close();
-
+
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
((ActiveMQConnection)connection).setCopyMessageOnSend(false);
-
+
ActiveMQBlobMessage message = (ActiveMQBlobMessage) ((ActiveMQSession)session).createBlobMessage(file);
message.setMessageId(new MessageId("testmessage"));
try {
@@ -74,5 +72,5 @@ public class FTPBlobUploadStrategyTest e
}
fail("Should have failed with permission denied exception!");
}
-
+
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/blob/FilesystemBlobTest.java Wed Feb 6 22:56:12 2013
@@ -27,8 +27,6 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
-import junit.framework.Assert;
-
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.BlobMessage;
import org.apache.activemq.EmbeddedBrokerTestSupport;
@@ -40,23 +38,23 @@ import org.slf4j.LoggerFactory;
public class FilesystemBlobTest extends EmbeddedBrokerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(FilesystemBlobTest.class);
-
+
private Connection connection;
- private String tmpDir = System.getProperty("user.dir") + "/target/FilesystemBlobTest";
- public void setUp() throws Exception {
+ private final String tmpDir = System.getProperty("user.dir") + "/target/FilesystemBlobTest";
+ @Override
+ public void setUp() throws Exception {
super.setUp();
// replace \ with / to let it work on windows too
String fileUrl = "file:///" +tmpDir.replaceAll("\\\\", "/");
LOG.info("Using file: " + fileUrl);
bindAddress = "vm://localhost?jms.blobTransferPolicy.defaultUploadUrl=" + fileUrl;
-
+
connectionFactory = createConnectionFactory();
-
+
connection = createConnection();
- connection.start();
+ connection.start();
}
-
-
+
public void testBlobFile() throws Exception {
// first create Message
File file = File.createTempFile("amq-data-file-", ".dat");
@@ -77,7 +75,7 @@ public class FilesystemBlobTest extends
// check message send
Message msg = consumer.receive(1000);
- Assert.assertTrue(msg instanceof ActiveMQBlobMessage);
+ assertTrue(msg instanceof ActiveMQBlobMessage);
InputStream input = ((ActiveMQBlobMessage) msg).getInputStream();
StringBuilder b = new StringBuilder();
@@ -87,19 +85,20 @@ public class FilesystemBlobTest extends
i = input.read();
}
input.close();
- File uploaded = new File(tmpDir, msg.getJMSMessageID().toString().replace(":", "_"));
- Assert.assertEquals(content, b.toString());
+ File uploaded = new File(tmpDir, msg.getJMSMessageID().toString().replace(":", "_"));
+ assertEquals(content, b.toString());
assertTrue(uploaded.exists());
((ActiveMQBlobMessage)msg).deleteFile();
assertFalse(uploaded.exists());
}
+ @Override
protected void tearDown() throws Exception {
if (connection != null) {
connection.stop();
}
super.tearDown();
-
+
IOHelper.deleteFile(new File(tmpDir));
}
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java Wed Feb 6 22:56:12 2013
@@ -16,9 +16,13 @@
*/
package org.apache.activemq.broker.jmx;
+import static org.junit.Assert.assertEquals;
+
import java.net.Socket;
import java.util.Set;
+
import javax.management.ObjectName;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
@@ -28,9 +32,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class TransportConnectorMBeanTest {
private static final Logger LOG = LoggerFactory.getLogger(TransportConnectorMBeanTest.class);
@@ -73,7 +74,7 @@ public class TransportConnectorMBeanTest
}
private String extractLocalPort(ActiveMQConnection connection) throws Exception {
- Socket socket = (Socket) connection.getTransport().narrow(Socket.class);
+ Socket socket = connection.getTransport().narrow(Socket.class);
return String.valueOf(socket.getLocalPort());
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java Wed Feb 6 22:56:12 2013
@@ -35,11 +35,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class IndividualDeadLetterTest extends DeadLetterTest {
private static final Logger LOG = LoggerFactory.getLogger(IndividualDeadLetterTest.class);
+ @Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
@@ -56,11 +57,12 @@ public class IndividualDeadLetterTest ex
return broker;
}
+ @Override
protected Destination createDlqDestination() {
String prefix = topic ? "ActiveMQ.DLQ.Topic." : "ActiveMQ.DLQ.Queue.";
return new ActiveMQQueue(prefix + getClass().getName() + "." + getName());
}
-
+
public void testDLQBrowsing() throws Exception {
super.topic = false;
deliveryMode = DeliveryMode.PERSISTENT;
@@ -97,9 +99,9 @@ public class IndividualDeadLetterTest ex
assertNull("The message shouldn't be sent to another DLQ", testConsumer.receive(1000));
}
-
+
protected void browseDlq() throws Exception {
- Enumeration messages = dlqBrowser.getEnumeration();
+ Enumeration<?> messages = dlqBrowser.getEnumeration();
while (messages.hasMoreElements()) {
LOG.info("Browsing: " + messages.nextElement());
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/NoRetryDeadLetterTest.java Wed Feb 6 22:56:12 2013
@@ -18,12 +18,10 @@ package org.apache.activemq.broker.polic
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.RedeliveryPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class NoRetryDeadLetterTest extends DeadLetterTest {
- private static final Logger LOG = LoggerFactory.getLogger(NoRetryDeadLetterTest.class);
+ @Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory connectionFactory = super.createConnectionFactory();
RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
@@ -31,5 +29,5 @@ public class NoRetryDeadLetterTest exten
connectionFactory.setRedeliveryPolicy(redeliveryPolicy);
return connectionFactory;
}
-
+
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PerDurableConsumerDeadLetterTest.java Wed Feb 6 22:56:12 2013
@@ -16,21 +16,13 @@
*/
package org.apache.activemq.broker.policy;
-import java.util.Enumeration;
-import javax.jms.DeliveryMode;
import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import org.apache.activemq.ActiveMQConnection;
+
import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
import org.apache.activemq.broker.region.policy.IndividualDeadLetterStrategy;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* for durable subs, allow a dlq per subscriber such that poison messages are not duplicates
@@ -38,10 +30,10 @@ import org.slf4j.LoggerFactory;
* https://issues.apache.org/jira/browse/AMQ-3003
*/
public class PerDurableConsumerDeadLetterTest extends DeadLetterTest {
- private static final Logger LOG = LoggerFactory.getLogger(PerDurableConsumerDeadLetterTest.class);
private static final String CLIENT_ID = "george";
+ @Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
@@ -59,10 +51,12 @@ public class PerDurableConsumerDeadLette
return broker;
}
+ @Override
protected String createClientId() {
return CLIENT_ID;
}
+ @Override
protected Destination createDlqDestination() {
String prefix = topic ? "ActiveMQ.DLQ.Topic." : "ActiveMQ.DLQ.Queue.";
String destinationName = prefix + getClass().getName() + "." + getName();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/PriorityNetworkDispatchPolicyTest.java Wed Feb 6 22:56:12 2013
@@ -16,23 +16,26 @@
*/
package org.apache.activemq.broker.policy;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.region.Subscription;
import org.apache.activemq.broker.region.TopicSubscription;
import org.apache.activemq.broker.region.policy.PriorityNetworkDispatchPolicy;
-import org.apache.activemq.command.*;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ConsumerId;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.MessageId;
import org.apache.activemq.usage.SystemUsage;
-import org.apache.derby.iapi.jdbc.BrokeredStatement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
public class PriorityNetworkDispatchPolicyTest {
PriorityNetworkDispatchPolicy underTest = new PriorityNetworkDispatchPolicy();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/SimpleDispatchPolicyTest.java Wed Feb 6 22:56:12 2013
@@ -18,6 +18,8 @@ package org.apache.activemq.broker.polic
import java.util.Iterator;
+import javax.jms.MessageConsumer;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.QueueSubscriptionTest;
import org.apache.activemq.broker.region.policy.FixedCountSubscriptionRecoveryPolicy;
@@ -28,6 +30,7 @@ import org.apache.activemq.util.MessageI
public class SimpleDispatchPolicyTest extends QueueSubscriptionTest {
+ @Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
@@ -42,24 +45,26 @@ public class SimpleDispatchPolicyTest ex
return broker;
}
+ @Override
public void testOneProducerTwoConsumersSmallMessagesLargePrefetch() throws Exception {
super.testOneProducerTwoConsumersSmallMessagesLargePrefetch();
// One consumer should have received all messages, and the rest none
- // assertOneConsumerReceivedAllMessages(messageCount);
+ // assertOneConsumerReceivedAllMessages(messageCount);
}
+ @Override
public void testOneProducerTwoConsumersLargeMessagesLargePrefetch() throws Exception {
super.testOneProducerTwoConsumersLargeMessagesLargePrefetch();
// One consumer should have received all messages, and the rest none
- // assertOneConsumerReceivedAllMessages(messageCount);
+ // assertOneConsumerReceivedAllMessages(messageCount);
}
public void assertOneConsumerReceivedAllMessages(int messageCount) throws Exception {
boolean found = false;
- for (Iterator i = consumers.keySet().iterator(); i.hasNext();) {
- MessageIdList messageIdList = (MessageIdList)consumers.get(i.next());
+ for (Iterator<MessageConsumer> i = consumers.keySet().iterator(); i.hasNext();) {
+ MessageIdList messageIdList = consumers.get(i.next());
int count = messageIdList.getMessageCount();
if (count > 0) {
if (found) {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/StrictOrderDispatchPolicyTest.java Wed Feb 6 22:56:12 2013
@@ -18,6 +18,8 @@ package org.apache.activemq.broker.polic
import java.util.Iterator;
+import javax.jms.MessageConsumer;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TopicSubscriptionTest;
import org.apache.activemq.broker.region.policy.PolicyEntry;
@@ -27,6 +29,7 @@ import org.apache.activemq.util.MessageI
public class StrictOrderDispatchPolicyTest extends TopicSubscriptionTest {
+ @Override
protected BrokerService createBroker() throws Exception {
BrokerService broker = super.createBroker();
@@ -41,48 +44,56 @@ public class StrictOrderDispatchPolicyTe
return broker;
}
+ @Override
public void testOneProducerTwoConsumersLargeMessagesOnePrefetch() throws Exception {
super.testOneProducerTwoConsumersLargeMessagesOnePrefetch();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testOneProducerTwoConsumersSmallMessagesOnePrefetch() throws Exception {
super.testOneProducerTwoConsumersSmallMessagesOnePrefetch();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testOneProducerTwoConsumersSmallMessagesLargePrefetch() throws Exception {
super.testOneProducerTwoConsumersSmallMessagesLargePrefetch();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testOneProducerTwoConsumersLargeMessagesLargePrefetch() throws Exception {
super.testOneProducerTwoConsumersLargeMessagesLargePrefetch();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testOneProducerManyConsumersFewMessages() throws Exception {
super.testOneProducerManyConsumersFewMessages();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testOneProducerManyConsumersManyMessages() throws Exception {
super.testOneProducerManyConsumersManyMessages();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testManyProducersOneConsumer() throws Exception {
super.testManyProducersOneConsumer();
assertReceivedMessagesAreOrdered();
}
+ @Override
public void testManyProducersManyConsumers() throws Exception {
super.testManyProducersManyConsumers();
@@ -96,7 +107,7 @@ public class StrictOrderDispatchPolicyTe
}
// Get basis of order
- Iterator i = consumers.keySet().iterator();
+ Iterator<MessageConsumer> i = consumers.keySet().iterator();
MessageIdList messageOrder = (MessageIdList)consumers.get(i.next());
for (; i.hasNext();) {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/broker/store/LoadTester.java Wed Feb 6 22:56:12 2013
@@ -34,29 +34,29 @@ import org.apache.activemq.JmsTestSuppor
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.ProgressPrinter;
-import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.memory.list.SimpleMessageList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class LoadTester extends JmsTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(LoadTester.class);
-
+
protected int messageSize = 1024 * 64;
protected int produceCount = 10000;
+ @Override
protected BrokerService createBroker() throws Exception {
return BrokerFactory.createBroker(new URI("xbean:org/apache/activemq/broker/store/loadtester.xml"));
}
+ @Override
protected ConnectionFactory createConnectionFactory() throws URISyntaxException, IOException {
- ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(((TransportConnector)broker.getTransportConnectors().get(0)).getServer().getConnectURI());
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getServer().getConnectURI());
factory.setUseAsyncSend(true);
return factory;
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/ActiveMQTestCase.java Wed Feb 6 22:56:12 2013
@@ -17,7 +17,6 @@
package org.apache.activemq.bugs.amq1095;
-import java.io.File;
import java.net.URI;
import java.util.Iterator;
import java.util.LinkedList;
@@ -34,7 +33,6 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.activemq.broker.BrokerFactory;
@@ -45,7 +43,7 @@ import org.apache.activemq.command.Activ
* <p>
* Common functionality for ActiveMQ test cases.
* </p>
- *
+ *
* @author Rainer Klute <a
* href="mailto:rainer.klute@dp-itsolutions.de"><rainer.klute@dp-itsolutions.de></a>
* @since 2007-08-10
@@ -57,15 +55,15 @@ public class ActiveMQTestCase extends Te
private BrokerService broker;
protected Connection connection;
protected Destination destination;
- private List<MessageConsumer> consumersToEmpty = new LinkedList<MessageConsumer>();
+ private final List<MessageConsumer> consumersToEmpty = new LinkedList<MessageConsumer>();
protected final long RECEIVE_TIMEOUT = 500;
/** <p>Constructor</p> */
public ActiveMQTestCase()
{}
-
- /** <p>Constructor</p>
+
+ /** <p>Constructor</p>
* @param name the test case's name
*/
public ActiveMQTestCase(final String name)
@@ -76,6 +74,7 @@ public class ActiveMQTestCase extends Te
/**
* <p>Sets up the JUnit testing environment.
*/
+ @Override
protected void setUp()
{
URI uri;
@@ -84,7 +83,7 @@ public class ActiveMQTestCase extends Te
/* 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();)
+ for (final Iterator<Object> i = systemProperties.keySet().iterator(); i.hasNext();)
{
final String key = (String) i.next();
if (key.startsWith("java.naming.") || key.startsWith("topic.") ||
@@ -94,7 +93,7 @@ public class ActiveMQTestCase extends Te
jndiProperties.put(key, value);
}
}
- context = new InitialContext(jndiProperties);
+ context = new InitialContext(jndiProperties);
uri = new URI("xbean:org/apache/activemq/bugs/amq1095/activemq.xml");
broker = BrokerFactory.createBroker(uri);
broker.start();
@@ -119,15 +118,15 @@ public class ActiveMQTestCase extends Te
catch (JMSException ex1)
{
ex1.printStackTrace();
- Assert.fail(ex1.toString());
+ fail(ex1.toString());
}
catch (NamingException ex2) {
ex2.printStackTrace();
- Assert.fail(ex2.toString());
+ fail(ex2.toString());
}
catch (Throwable ex3) {
ex3.printStackTrace();
- Assert.fail(ex3.toString());
+ fail(ex3.toString());
}
}
@@ -140,19 +139,20 @@ public class ActiveMQTestCase extends Te
* to be empty.
* </p>
*/
+ @Override
protected void tearDown() throws Exception {
TextMessage msg;
try {
- for (final Iterator i = consumersToEmpty.iterator(); i.hasNext();)
- {
- final MessageConsumer consumer = (MessageConsumer) i.next();
- if (consumer != null)
- do
- msg = (TextMessage) consumer.receive(RECEIVE_TIMEOUT);
- while (msg != null);
- }
- } catch (Exception e) {
- }
+ for (final Iterator<MessageConsumer> 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();
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/amq1095/MessageSelectorTest.java Wed Feb 6 22:56:12 2013
@@ -24,14 +24,11 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
-import junit.framework.Assert;
-
-
/**
* <p>
* Test cases for various ActiveMQ functionalities.
* </p>
- *
+ *
* <ul>
* <li>
* <p>
@@ -50,7 +47,7 @@ import junit.framework.Assert;
* </p>
* </li>
* </ul>
- *
+ *
* @author Rainer Klute <a
* href="mailto:rainer.klute@dp-itsolutions.de"><rainer.klute@dp-itsolutions.de></a>
* @since 2007-08-09
@@ -64,7 +61,7 @@ public class MessageSelectorTest extends
/** <p>Constructor</p> */
public MessageSelectorTest()
{}
-
+
/** <p>Constructor</p>
* @param name the test case's name
*/
@@ -102,7 +99,7 @@ public class MessageSelectorTest extends
{
runMessageSelectorTest(false);
}
-
+
/**
* <p>
* Tests whether message selectors work. This is done by sending two
@@ -223,7 +220,7 @@ public class MessageSelectorTest extends
catch (JMSException ex)
{
ex.printStackTrace();
- Assert.fail();
+ fail();
}
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/BrokerXmlConfigFromJNDITest.java Wed Feb 6 22:56:12 2013
@@ -26,15 +26,16 @@ import org.apache.activemq.ActiveMQConne
import org.apache.activemq.test.JmsTopicSendReceiveWithTwoConnectionsTest;
/**
- *
+ *
*/
public class BrokerXmlConfigFromJNDITest extends JmsTopicSendReceiveWithTwoConnectionsTest {
+ @Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
assertBaseDirectoryContainsSpaces();
// we could put these properties into a jndi.properties
// on the classpath instead
- Hashtable properties = new Hashtable();
+ Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
// configure the embedded broker using an XML config file
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java?rev=1443267&r1=1443266&r2=1443267&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/config/ConfigUsingDestinationOptions.java Wed Feb 6 22:56:12 2013
@@ -22,6 +22,7 @@ import javax.jms.JMSException;
import javax.jms.Session;
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQMessageConsumer;
import org.apache.activemq.command.ActiveMQQueue;
@@ -55,7 +56,7 @@ public class ConfigUsingDestinationOptio
// JMS selector should be priority
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test||1");
- fail("Selector should be invalid");
+ fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}
@@ -63,7 +64,7 @@ public class ConfigUsingDestinationOptio
// Test setting using JMS destinations
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue);
- fail("Selector should be invalid");
+ fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}