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/07 17:43:17 UTC
svn commit: r1443600 [1/4] - in
/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq:
perf/ security/ selector/ spring/ store/ store/jdbc/ store/kahadb/
store/kahadb/perf/ test/message/ test/retroactive/ transport/
transport/failover/ ...
Author: tabish
Date: Thu Feb 7 16:43:15 2013
New Revision: 1443600
URL: http://svn.apache.org/viewvc?rev=1443600&view=rev
Log:
Fix a bunch of warnings covering deprecated asserts and such.
Modified:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCXACommitExceptionTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/LeaseDatabaseLockerTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBFastEnqueueTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryBrokerTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBStoreRecoveryExpiryTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/PBMesssagesTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/perf/KahaBulkLoadingTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapAndListPropertyTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/test/message/NestedMapMessageTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerTestWithSimpleMessageListTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/test/retroactive/RetroactiveConsumerWithMessageQueryTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/StubTransportListener.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverDuplicateTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBackupsTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransportBrokerTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/peer/PeerTransportTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/reliable/UnreliableUdpTransportTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/tcp/QualityOfServiceUtilsTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SocketTstFactory.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextBrokerServiceTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/transport/tcp/SslContextNBrokerServiceTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AMQStackOverFlowTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AbstractTwoBrokerNetworkConnectorWildcardIncludedDestinationTestSupport.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/AdvisoryTopicDeletionTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BrokerQueueNetworkWithDisconnectTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/BrowseOverNetworkTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSentMessageTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ChangeSessionDeliveryModeTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/CompositePublishTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DiscriminatingConsumerLoadTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessConcurrentCommitActivateNoDuplicateTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubProcessWithRestartTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionSelectorTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionUnsubscribeTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ExpiredMessagesTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/JdbcDurableSubDupTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupCloseTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MessageGroupDelayedTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MyObject.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/NewConsumerCreatesDestinationTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/QueueBrowsingTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyNoAdvisoryNetworkTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/RequestReplyToTopicViaThreeNetworkHopsTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/SingleBrokerVirtualDestinationsWithWildcardTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestSupport.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerQueueNetworkUsingTcpTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerStompTemporaryQueueTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTempQueueNetworkTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ThreeBrokerTopicNetworkUsingTcpTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TopicDurableConnectStatsTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TransactionTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerQueueClientsReconnectTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TwoBrokerTopicSendReceiveTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/util/MessageIdList.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ConnectorXBeanConfigTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/ManagementContextXBeanConfigTest.java
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/xbean/MultipleTestsWithEmbeddedBrokerTest.java
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/ConnectionChurnTest.java Thu Feb 7 16:43:15 2013
@@ -18,10 +18,13 @@ package org.apache.activemq.perf;
import java.util.ArrayList;
import java.util.List;
+
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
+
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
@@ -30,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class ConnectionChurnTest extends TestCase {
protected static final int CONNECTION_COUNT = 200;
@@ -41,7 +44,7 @@ public class ConnectionChurnTest extends
public void testPerformance() throws Exception {
ConnectionFactory factory = createConnectionFactory();
- List<Connection> list = new ArrayList();
+ List<Connection> list = new ArrayList<Connection>();
for (int i = 0; i < CONNECTION_COUNT; i++) {
Connection connection = factory.createConnection();
connection.start();
@@ -64,6 +67,7 @@ public class ConnectionChurnTest extends
list.clear();
}
+ @Override
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker();
@@ -71,6 +75,7 @@ public class ConnectionChurnTest extends
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
if (broker != null) {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveDurableTopicTest.java Thu Feb 7 16:43:15 2013
@@ -24,16 +24,17 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Topic;
import javax.jms.TopicSubscriber;
-import junit.framework.Assert;
+
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class InactiveDurableTopicTest extends TestCase {
private static final transient Logger LOG = LoggerFactory.getLogger(InactiveDurableTopicTest.class);
@@ -137,7 +138,7 @@ public class InactiveDurableTopicTest ex
LOG.info("Sent " + loop + " messages");
}
}
- Assert.assertEquals(loop, MESSAGE_COUNT);
+ assertEquals(loop, MESSAGE_COUNT);
publisher.close();
session.close();
connection.stop();
@@ -169,12 +170,12 @@ public class InactiveDurableTopicTest ex
assertNotNull(subscriber);
int loop;
for (loop = 0; loop < MESSAGE_COUNT; loop++) {
- Message msg = subscriber.receive();
+ subscriber.receive();
if (loop % 500 == 0) {
LOG.debug("Received " + loop + " messages");
}
}
- this.assertEquals(loop, MESSAGE_COUNT);
+ assertEquals(loop, MESSAGE_COUNT);
subscriber.close();
session.close();
connection.close();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/InactiveQueueTest.java Thu Feb 7 16:43:15 2013
@@ -22,16 +22,16 @@ import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
-import javax.jms.TopicSubscriber;
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class InactiveQueueTest extends TestCase {
private static final transient Logger LOG = LoggerFactory.getLogger(InactiveQueueTest.class);
@@ -39,20 +39,19 @@ public class InactiveQueueTest extends T
private static final int MESSAGE_COUNT = 0;
private static final String DEFAULT_PASSWORD = "";
private static final String USERNAME = "testuser";
- private static final String CLIENTID = "mytestclient";
private static final String QUEUE_NAME = "testevent";
private static final int DELIVERY_MODE = javax.jms.DeliveryMode.PERSISTENT;
private static final int DELIVERY_PRIORITY = javax.jms.Message.DEFAULT_PRIORITY;
-
+
ActiveMQConnectionFactory connectionFactory;
BrokerService broker;
private Connection connection;
private MessageProducer publisher;
- private TopicSubscriber subscriber;
private Destination destination;
private Session session;
+ @Override
protected void setUp() throws Exception {
super.setUp();
broker = new BrokerService();
@@ -77,6 +76,7 @@ public class InactiveQueueTest extends T
connectionFactory.setUseAsyncSend(true);
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
broker.stop();
@@ -104,7 +104,7 @@ public class InactiveQueueTest extends T
}
}
Thread.sleep(1000000);
- this.assertEquals(loop, MESSAGE_COUNT);
+ assertEquals(loop, MESSAGE_COUNT);
publisher.close();
session.close();
connection.stop();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/MemoryAllocationTest.java Thu Feb 7 16:43:15 2013
@@ -21,7 +21,6 @@ import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
-import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TemporaryQueue;
@@ -35,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class MemoryAllocationTest extends TestCase {
@@ -81,6 +80,7 @@ public class MemoryAllocationTest extend
}
}
+ @Override
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker();
@@ -88,6 +88,7 @@ public class MemoryAllocationTest extend
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/NetworkedSyncTest.java Thu Feb 7 16:43:15 2013
@@ -33,9 +33,9 @@ import org.apache.activemq.ActiveMQConne
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.xbean.BrokerFactoryBean;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
@@ -59,7 +59,7 @@ public class NetworkedSyncTest extends T
super(name);
LOG.info("Testcase started.");
}
-
+
public static void main(String args[]) {
TestRunner.run(NetworkedSyncTest.class);
}
@@ -67,10 +67,12 @@ public class NetworkedSyncTest extends T
/**
* @throws java.lang.Exception
*/
+ @Override
protected void setUp() throws Exception {
LOG.info("setUp() called.");
ClassPathXmlApplicationContext context1 = null;
BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(config));
+ assertNotNull(brokerFactory);
/* start up first broker instance */
try {
@@ -125,6 +127,7 @@ public class NetworkedSyncTest extends T
/**
* @throws java.lang.Exception
*/
+ @Override
protected void tearDown() throws Exception {
LOG.info("tearDown() called.");
@@ -148,7 +151,7 @@ public class NetworkedSyncTest extends T
LOG.info("testMessageExchange() called.");
long start = System.currentTimeMillis();
-
+
// create producer and consumer threads
Thread producer = new Thread(new Producer());
Thread consumer = new Thread(new Consumer());
@@ -156,22 +159,22 @@ public class NetworkedSyncTest extends T
consumer.start();
Thread.sleep(2000);
producer.start();
-
+
// wait for threads to finish
producer.join();
consumer.join();
long end = System.currentTimeMillis();
-
+
System.out.println("Duration: "+(end-start));
}
}
/**
* Message producer running as a separate thread, connecting to broker1
- *
+ *
* @author tmielke
- *
+ *
*/
class Producer implements Runnable {
@@ -180,6 +183,7 @@ class Producer implements Runnable {
/**
* connect to broker and constantly send messages
*/
+ @Override
public void run() {
Connection connection = null;
@@ -192,6 +196,7 @@ class Producer implements Runnable {
connection = amq.createConnection();
connection.setExceptionListener(new javax.jms.ExceptionListener() {
+ @Override
public void onException(javax.jms.JMSException e) {
e.printStackTrace();
}
@@ -241,16 +246,17 @@ class Producer implements Runnable {
/*
* * Message consumer running as a separate thread, connecting to broker2
* @author tmielke
- *
+ *
*/
class Consumer implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(Consumer.class);;
-
+
/**
* connect to broker and receive messages
*/
+ @Override
public void run() {
Connection connection = null;
Session session = null;
@@ -264,6 +270,7 @@ class Consumer implements Runnable {
connection.setClientID("tmielke");
connection.setExceptionListener(new javax.jms.ExceptionListener() {
+ @Override
public void onException(javax.jms.JMSException e) {
e.printStackTrace();
}
@@ -276,11 +283,11 @@ class Consumer implements Runnable {
long counter = 0;
// Wait for a message
- for (int i = 0; i < NetworkedSyncTest.MESSAGE_COUNT; i++) {
+ for (int i = 0; i < NetworkedSyncTest.MESSAGE_COUNT; i++) {
Message message2 = consumer.receive();
if (message2 instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message2;
- String text = textMessage.getText();
+ textMessage.getText();
// logger.info("Received: " + text);
} else {
LOG.error("Received message of unsupported type. Expecting TextMessage. "+ message2);
@@ -289,7 +296,7 @@ class Consumer implements Runnable {
if ((counter % 1000) == 0)
LOG.info("received " + counter + " messages");
-
+
}
} catch (Exception e) {
LOG.error("Error in Consumer: " + e);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java Thu Feb 7 16:43:15 2013
@@ -19,34 +19,39 @@ package org.apache.activemq.perf;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
import javax.jms.Session;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class QueueConnectionMemoryTest extends SimpleQueueTest {
private static final transient Logger LOG = LoggerFactory.getLogger(QueueConnectionMemoryTest.class);
+ @Override
protected void setUp() throws Exception {
}
+ @Override
protected void tearDown() throws Exception {
}
+ @Override
protected Destination createDestination(Session s, String destinationName) throws JMSException {
return s.createTemporaryQueue();
}
+ @Override
public void testPerformance() throws JMSException {
// just cancel super class test
}
+ @Override
protected void configureBroker(BrokerService answer,String uri) throws Exception {
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
answer.setPersistenceAdapter(adaptor);
@@ -61,14 +66,14 @@ public class QueueConnectionMemoryTest e
factory = createConnectionFactory(bindAddress);
Connection con = factory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Destination destination = createDestination(session, destinationName);
+ createDestination(session, destinationName);
con.close();
for (int i = 0; i < 3; i++) {
Connection connection = factory.createConnection();
connection.start();
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = s.createTemporaryQueue();
- MessageConsumer consumer = s.createConsumer(dest);
+ s.createConsumer(dest);
LOG.debug("Created connnection: " + i);
Thread.sleep(1000);
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/RunBroker.java Thu Feb 7 16:43:15 2013
@@ -17,6 +17,7 @@
package org.apache.activemq.perf;
import java.io.File;
+
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
import org.apache.activemq.util.IOHelper;
@@ -29,7 +30,6 @@ public class RunBroker {
KahaDBPersistenceAdapter kahaDB = new KahaDBPersistenceAdapter();
File dataFileDir = new File("target/test-amq-data/perfTest/kahadb");
IOHelper.deleteChildren(dataFileDir);
- File archiveDir = new File(dataFileDir, "archive");
kahaDB.setDirectory(dataFileDir);
// The setEnableJournalDiskSyncs(false) setting is a little
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java Thu Feb 7 16:43:15 2013
@@ -21,32 +21,34 @@ import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session;
+
import junit.framework.TestCase;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class SimpleTopicTest extends TestCase {
private static final Logger LOG = LoggerFactory.getLogger(SimpleTopicTest.class);
-
+
protected BrokerService broker;
- protected String clientURI="tcp://localhost:61616?wireFormat.cacheEnabled=true&wireFormat.tightEncodingEnabled=true&jms.useAsyncSend=false&wireFormat.maxInactivityDuration=0";
- //protected String clientURI="tcp://localhost:61616";
- protected String bindAddress="tcp://localhost:61616?wireFormat.maxInactivityDuration=0";
- //protected String bindAddress = "tcp://localhost:61616";
- //protected String bindAddress="vm://localhost?marshal=true";
- //protected String bindAddress="vm://localhost";
+ protected String clientURI = "tcp://localhost:61616?wireFormat.cacheEnabled=true&wireFormat.tightEncodingEnabled=true&jms.useAsyncSend=false&wireFormat.maxInactivityDuration=0";
+ // protected String clientURI="tcp://localhost:61616";
+ protected String bindAddress = "tcp://localhost:61616?wireFormat.maxInactivityDuration=0";
+ // protected String bindAddress = "tcp://localhost:61616";
+ // protected String bindAddress="vm://localhost?marshal=true";
+ // protected String bindAddress="vm://localhost";
protected PerfProducer[] producers;
protected PerfConsumer[] consumers;
protected String destinationName = getClass().getName();
protected int sampleCount = 20;
protected long sampleInternal = 10000;
- protected int numberOfDestinations=1;
+ protected int numberOfDestinations = 1;
protected int numberOfConsumers = 1;
protected int numberofProducers = 1;
protected int totalNumberOfProducers;
@@ -54,12 +56,13 @@ public class SimpleTopicTest extends Tes
protected int playloadSize = 12;
protected byte[] array;
protected ConnectionFactory factory;
-
- /**
+
+ /**
* Sets up a test where the producer and consumer have their own connection.
- *
+ *
* @see junit.framework.TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker(bindAddress);
@@ -67,18 +70,17 @@ public class SimpleTopicTest extends Tes
factory = createConnectionFactory(clientURI);
Connection con = factory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-
+
LOG.info("Running " + numberofProducers + " producer(s) and " + numberOfConsumers + " consumer(s) per " + numberOfDestinations + " Destination(s)");
-
- totalNumberOfConsumers=numberOfConsumers*numberOfDestinations;
- totalNumberOfProducers=numberofProducers*numberOfDestinations;
+
+ totalNumberOfConsumers = numberOfConsumers * numberOfDestinations;
+ totalNumberOfProducers = numberofProducers * numberOfDestinations;
producers = new PerfProducer[totalNumberOfProducers];
consumers = new PerfConsumer[totalNumberOfConsumers];
int consumerCount = 0;
int producerCount = 0;
- for (int k =0; k < numberOfDestinations;k++) {
- Destination destination = createDestination(session, destinationName+":"+k);
+ for (int k = 0; k < numberOfDestinations; k++) {
+ Destination destination = createDestination(session, destinationName + ":" + k);
LOG.info("Testing against destination: " + destination);
for (int i = 0; i < numberOfConsumers; i++) {
consumers[consumerCount] = createConsumer(factory, destination, consumerCount);
@@ -87,7 +89,7 @@ public class SimpleTopicTest extends Tes
for (int i = 0; i < numberofProducers; i++) {
array = new byte[playloadSize];
for (int j = i; j < array.length; j++) {
- array[j] = (byte)j;
+ array[j] = (byte) j;
}
producers[producerCount] = createProducer(factory, destination, i, array);
producerCount++;
@@ -97,6 +99,7 @@ public class SimpleTopicTest extends Tes
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
for (int i = 0; i < numberOfConsumers; i++) {
@@ -117,12 +120,12 @@ public class SimpleTopicTest extends Tes
/**
* Factory method to create a new broker
- *
+ *
* @throws Exception
*/
protected BrokerService createBroker(String uri) throws Exception {
BrokerService answer = new BrokerService();
- configureBroker(answer,uri);
+ configureBroker(answer, uri);
answer.start();
return answer;
}
@@ -134,9 +137,8 @@ public class SimpleTopicTest extends Tes
protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException {
return new PerfConsumer(fac, dest);
}
-
-
- protected void configureBroker(BrokerService answer,String uri) throws Exception {
+
+ protected void configureBroker(BrokerService answer, String uri) throws Exception {
answer.setDeleteAllMessagesOnStartup(true);
answer.addConnector(uri);
answer.setUseShutdownHook(false);
@@ -167,34 +169,33 @@ public class SimpleTopicTest extends Tes
}
}
+ @SuppressWarnings("unused")
protected void dumpProducerRate() {
int totalRate = 0;
int totalCount = 0;
- String producerString="Producers:";
+ String producerString = "Producers:";
for (int i = 0; i < producers.length; i++) {
PerfRate rate = producers[i].getRate().cloneAndReset();
totalRate += rate.getRate();
totalCount += rate.getTotalCount();
- producerString+="["+i+":"+rate.getRate() + ","+rate.getTotalCount()+"];";
+ producerString += "[" + i + ":" + rate.getRate() + "," + rate.getTotalCount() + "];";
}
if (producers != null && producers.length > 0) {
int avgRate = totalRate / producers.length;
- System.out.println("Avg producer rate = " + avgRate
- + " msg/sec | Total rate = " + totalRate + ", sent = "
- + totalCount);
- // System.out.println(producerString);
+ System.out.println("Avg producer rate = " + avgRate + " msg/sec | Total rate = " + totalRate + ", sent = " + totalCount);
+ // System.out.println(producerString);
}
}
protected void dumpConsumerRate() {
int totalRate = 0;
int totalCount = 0;
- String consumerString="Consumers:";
+ String consumerString = "Consumers:";
for (int i = 0; i < consumers.length; i++) {
PerfRate rate = consumers[i].getRate().cloneAndReset();
totalRate += rate.getRate();
totalCount += rate.getTotalCount();
- consumerString+="["+i+":"+rate.getRate() + ","+rate.getTotalCount()+"];";
+ consumerString += "[" + i + ":" + rate.getRate() + "," + rate.getTotalCount() + "];";
}
if (consumers != null && consumers.length > 0) {
int avgRate = totalRate / consumers.length;
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java Thu Feb 7 16:43:15 2013
@@ -16,21 +16,9 @@
*/
package org.apache.activemq.security;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.activemq.jaas.GroupPrincipal;
-import org.apache.activemq.util.Wait;
-import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.model.ldif.LdifReader;
-import org.apache.directory.shared.ldap.model.message.ModifyRequest;
-import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
-import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.name.Rdn;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -46,25 +34,37 @@ import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.directory.DirContext;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.jaas.GroupPrincipal;
+import org.apache.activemq.util.Wait;
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
+import org.apache.directory.shared.ldap.model.ldif.LdifReader;
+import org.apache.directory.shared.ldap.model.message.ModifyRequest;
+import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends AbstractLdapTestUnit {
static final GroupPrincipal GUESTS = new GroupPrincipal("guests");
static final GroupPrincipal USERS = new GroupPrincipal("users");
static final GroupPrincipal ADMINS = new GroupPrincipal("admins");
-
+
protected LdapConnection connection;
protected SimpleCachedLDAPAuthorizationMap map;
-
+
@Before
public void setup() throws Exception {
connection = getLdapConnection();
map = createMap();
}
-
+
@After
public void cleanup() throws Exception {
if (connection != null) {
@@ -74,7 +74,7 @@ public abstract class AbstractCachedLDAP
// Ignore
}
}
-
+
if (map != null) {
map.destroy();
}
@@ -91,7 +91,7 @@ public abstract class AbstractCachedLDAP
Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
}
-
+
@Test
public void testSynchronousUpdate() throws Exception {
map.setRefreshInterval(1);
@@ -103,16 +103,18 @@ public abstract class AbstractCachedLDAP
Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
-
+
LdifReader reader = new LdifReader(getRemoveLdif());
for (LdifEntry entry : reader) {
connection.delete(entry.getDn());
}
-
+
+ reader.close();
+
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
-
+
assertNull(map.getTempDestinationReadACLs());
assertNull(map.getTempDestinationWriteACLs());
assertNull(map.getTempDestinationAdminACLs());
@@ -144,7 +146,7 @@ public abstract class AbstractCachedLDAP
@Test
public void testTemporary() throws Exception {
map.query();
-
+
Thread.sleep(1000);
Set<?> readACLs = map.getTempDestinationReadACLs();
assertEquals("set size: " + readACLs, 2, readACLs.size());
@@ -165,6 +167,8 @@ public abstract class AbstractCachedLDAP
connection.add(entry.getEntry());
}
+ reader.close();
+
Thread.sleep(2000);
failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
@@ -184,16 +188,17 @@ public abstract class AbstractCachedLDAP
connection.delete(entry.getDn());
}
+ reader.close();
Thread.sleep(2000);
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
-
+
assertTrue(map.getTempDestinationReadACLs() == null || map.getTempDestinationReadACLs().isEmpty());
assertTrue(map.getTempDestinationWriteACLs() == null || map.getTempDestinationWriteACLs().isEmpty());
assertTrue(map.getTempDestinationAdminACLs() == null || map.getTempDestinationAdminACLs().isEmpty());
}
-
+
@Test
public void testRenameDestination() throws Exception {
map.query();
@@ -214,30 +219,30 @@ public abstract class AbstractCachedLDAP
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.BAR"));
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
}
-
+
@Test
public void testRenamePermission() throws Exception {
map.query();
-
+
// Test for a permission rename
connection.delete(new Dn("cn=Read,cn=TEST.FOO," + getQueueBaseDn()));
-
+
Thread.sleep(2000);
-
+
Set<?> failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
-
+
failedACLs = map.getWriteACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
-
+
connection.rename(new Dn("cn=Write,cn=TEST.FOO," + getQueueBaseDn()),
new Rdn("cn=Read"));
-
+
Thread.sleep(2000);
-
+
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
-
+
failedACLs = map.getWriteACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 0, failedACLs.size());
}
@@ -262,16 +267,16 @@ public abstract class AbstractCachedLDAP
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 1, failedACLs.size());
-
+
// Change destination entry
request = new ModifyRequestImpl();
request.setName(new Dn("cn=TEST.FOO," + getQueueBaseDn()));
request.add("description", "This is a description! In fact, it is a very good description.");
-
+
connection.modify(request);
Thread.sleep(2000);
-
+
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
assertEquals("set size: " + failedACLs, 1, failedACLs.size());
}
@@ -304,6 +309,7 @@ public abstract class AbstractCachedLDAP
// wait for the context to be closed
// as we can't rely on ldar server isStarted()
Wait.waitFor(new Wait.Condition() {
+ @Override
public boolean isSatisified() throws Exception {
if (sync) {
return !map.isContextAlive();
@@ -328,40 +334,41 @@ public abstract class AbstractCachedLDAP
connection.add(entry.getEntry());
}
+ reader.close();
Thread.sleep(2000);
failedACLs = map.getReadACLs(new ActiveMQQueue("FAILED"));
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
}
-
+
protected SimpleCachedLDAPAuthorizationMap createMap() {
return new SimpleCachedLDAPAuthorizationMap();
}
-
+
protected abstract InputStream getAddLdif();
-
+
protected abstract InputStream getRemoveLdif();
-
+
protected void setupModifyRequest(ModifyRequest request) {
request.remove("member", "cn=users");
}
-
+
protected abstract String getQueueBaseDn();
-
+
protected abstract LdapConnection getLdapConnection() throws Exception;
-
+
public static void cleanAndLoad(String deleteFromDn, String ldifResourcePath,
String ldapHost, int ldapPort, String ldapUser, String ldapPass,
DirContext context) throws Exception {
// Cleanup everything used for testing.
List<String> dns = new LinkedList<String>();
dns.add(deleteFromDn);
-
+
while (!dns.isEmpty()) {
String name = dns.get(dns.size() - 1);
Context currentContext = (Context) context.lookup(name);
NamingEnumeration<NameClassPair> namingEnum = currentContext.list("");
-
+
if (namingEnum.hasMore()) {
while (namingEnum.hasMore()) {
dns.add(namingEnum.next().getNameInNamespace());
@@ -371,13 +378,14 @@ public abstract class AbstractCachedLDAP
dns.remove(dns.size() - 1);
}
}
-
+
// A bit of a hacked approach to loading an LDIF into OpenLDAP since there isn't an easy way to do it
// otherwise. This approach invokes the command line tool programmatically but has
// to short-circuit the call to System.exit that the command line tool makes when it finishes.
// We are assuming that there isn't already a security manager in place.
final SecurityManager securityManager = new SecurityManager() {
+ @Override
public void checkPermission(java.security.Permission permission) {
if (permission.getName().contains("exitVM")) {
throw new SecurityException("System.exit calls disabled for the moment.");
@@ -387,13 +395,13 @@ public abstract class AbstractCachedLDAP
System.setSecurityManager(securityManager);
-
+
File file = new File(AbstractCachedLDAPAuthorizationMapLegacyTest.class.getClassLoader().getResource(
ldifResourcePath).toURI());
-
+
Class<?> clazz = Class.forName("LDAPModify");
Method mainMethod = clazz.getMethod("main", String[].class);
-
+
try {
mainMethod.invoke(null, new Object[] {
new String[] {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasCertificateAuthenticationBrokerTest.java Thu Feb 7 16:43:15 2013
@@ -27,6 +27,7 @@ import javax.security.auth.login.AppConf
import javax.security.auth.login.Configuration;
import junit.framework.TestCase;
+
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.StubBroker;
import org.apache.activemq.command.ConnectionInfo;
@@ -42,6 +43,7 @@ public class JaasCertificateAuthenticati
ConnectionContext connectionContext;
ConnectionInfo connectionInfo;
+ @Override
protected void setUp() throws Exception {
receiveBroker = new StubBroker();
@@ -53,6 +55,7 @@ public class JaasCertificateAuthenticati
connectionInfo.setTransportContext(new StubX509Certificate[] {});
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -110,14 +113,14 @@ public class JaasCertificateAuthenticati
assertEquals("Number of addConnection calls to underlying Broker must match number of calls made to " + "AuthenticationBroker.", 1, receiveBroker.addConnectionData.size());
- ConnectionContext receivedContext = ((StubBroker.AddConnectionData)receiveBroker.addConnectionData.getFirst()).connectionContext;
+ ConnectionContext receivedContext = receiveBroker.addConnectionData.getFirst().connectionContext;
assertEquals("The SecurityContext's userName must be set to that of the UserPrincipal.", dnUserName, receivedContext.getSecurityContext().getUserName());
- Set receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
+ Set<Principal> receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
- for (Iterator iter = receivedPrincipals.iterator(); iter.hasNext();) {
- Principal currentPrincipal = (Principal)iter.next();
+ for (Iterator<Principal> iter = receivedPrincipals.iterator(); iter.hasNext();) {
+ Principal currentPrincipal = iter.next();
if (currentPrincipal instanceof UserPrincipal) {
if (userNames.remove(currentPrincipal.getName())) {
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/JaasDualAuthenticationBrokerTest.java Thu Feb 7 16:43:15 2013
@@ -17,7 +17,18 @@
package org.apache.activemq.security;
+import java.net.URI;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.net.ssl.SSLServerSocket;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+
import junit.framework.TestCase;
+
import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.broker.Connector;
import org.apache.activemq.broker.StubBroker;
@@ -25,17 +36,11 @@ import org.apache.activemq.broker.Transp
import org.apache.activemq.command.ConnectionInfo;
import org.apache.activemq.jaas.GroupPrincipal;
import org.apache.activemq.jaas.UserPrincipal;
-import org.apache.activemq.transport.tcp.*;
-
-import javax.net.ssl.SSLServerSocket;
-import javax.security.auth.login.AppConfigurationEntry;
-import javax.security.auth.login.Configuration;
-import java.net.URI;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+import org.apache.activemq.transport.tcp.SslTransportServer;
+import org.apache.activemq.transport.tcp.StubSSLServerSocket;
+import org.apache.activemq.transport.tcp.StubSSLSocketFactory;
+import org.apache.activemq.transport.tcp.StubX509Certificate;
+import org.apache.activemq.transport.tcp.TcpTransportServer;
/**
*
@@ -81,6 +86,7 @@ public class JaasDualAuthenticationBroke
Configuration.setConfiguration(jaasConfig);
}
+ @Override
protected void setUp() throws Exception {
receiveBroker = new StubBroker();
@@ -101,7 +107,7 @@ public class JaasDualAuthenticationBroke
sslTransportServer.bind();
try {
- nonSslTransportServer = new TcpTransportServer(null, new URI("tcp://localhost:61613"), socketFactory);
+ nonSslTransportServer = new TcpTransportServer(null, new URI("tcp://localhost:61613"), socketFactory);
} catch (Exception e) {
fail("Unable to create TcpTransportServer.");
}
@@ -112,6 +118,7 @@ public class JaasDualAuthenticationBroke
createLoginConfig();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
}
@@ -136,13 +143,13 @@ public class JaasDualAuthenticationBroke
assertEquals("The SecurityContext's userName must be set to that of the UserPrincipal.",
DN_USERNAME, receivedContext.getSecurityContext().getUserName());
- Set receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
+ Set<Principal> receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
assertEquals("2 Principals received", 2, receivedPrincipals.size());
-
- for (Iterator iter = receivedPrincipals.iterator(); iter.hasNext();) {
- Principal currentPrincipal = (Principal)iter.next();
+
+ for (Iterator<Principal> iter = receivedPrincipals.iterator(); iter.hasNext();) {
+ Principal currentPrincipal = iter.next();
if (currentPrincipal instanceof UserPrincipal) {
assertEquals("UserPrincipal is '" + DN_USERNAME + "'", DN_USERNAME, currentPrincipal.getName());
@@ -166,7 +173,7 @@ public class JaasDualAuthenticationBroke
Connector connector = new TransportConnector(nonSslTransportServer);
connectionContext.setConnector(connector);
connectionInfo.setUserName(INSECURE_USERNAME);
-
+
try {
authBroker.addConnection(connectionContext, connectionInfo);
} catch (Exception e) {
@@ -181,11 +188,11 @@ public class JaasDualAuthenticationBroke
assertEquals("The SecurityContext's userName must be set to that of the UserPrincipal.",
INSECURE_USERNAME, receivedContext.getSecurityContext().getUserName());
- Set receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
+ Set<Principal> receivedPrincipals = receivedContext.getSecurityContext().getPrincipals();
assertEquals("2 Principals received", 2, receivedPrincipals.size());
- for (Iterator iter = receivedPrincipals.iterator(); iter.hasNext();) {
- Principal currentPrincipal = (Principal)iter.next();
+ for (Iterator<Principal> iter = receivedPrincipals.iterator(); iter.hasNext();) {
+ Principal currentPrincipal = iter.next();
if (currentPrincipal instanceof UserPrincipal) {
assertEquals("UserPrincipal is '" + INSECURE_USERNAME + "'",
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPAuthorizationMapTest.java Thu Feb 7 16:43:15 2013
@@ -16,6 +16,17 @@
*/
package org.apache.activemq.security;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.text.MessageFormat;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.DirContext;
+
import org.apache.activemq.advisory.AdvisorySupport;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQQueue;
@@ -31,29 +42,16 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.directory.DirContext;
-import java.text.MessageFormat;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
/**
- * This test assumes setup like in file 'AMQauth.ldif'. Contents of this file is
- * attached below in comments.
- *
+ * This test assumes setup like in file 'AMQauth.ldif'. Contents of this file is attached below in comments.
+ *
* @author ngcutura
*
*
*/
-@RunWith( FrameworkRunner.class )
-@CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP")})
-@ApplyLdifFiles(
- "org/apache/activemq/security/AMQauth.ldif"
-)
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports = { @CreateTransport(protocol = "LDAP") })
+@ApplyLdifFiles("org/apache/activemq/security/AMQauth.ldif")
public class LDAPAuthorizationMapTest extends AbstractLdapTestUnit {
private static LDAPAuthorizationMap authMap;
@@ -73,9 +71,9 @@ public class LDAPAuthorizationMapTest ex
public void testOpen() throws Exception {
DirContext ctx = authMap.open();
HashSet<String> set = new HashSet<String>();
- NamingEnumeration list = ctx.list("ou=destinations,o=ActiveMQ,ou=system");
+ NamingEnumeration<NameClassPair> list = ctx.list("ou=destinations,o=ActiveMQ,ou=system");
while (list.hasMore()) {
- NameClassPair ncp = (NameClassPair) list.next();
+ NameClassPair ncp = list.next();
set.add(ncp.getName());
}
assertTrue(set.contains("ou=topics"));
@@ -83,80 +81,76 @@ public class LDAPAuthorizationMapTest ex
}
/*
- * Test method for
- * 'org.apache.activemq.security.LDAPAuthorizationMap.getAdminACLs(ActiveMQDestination)'
+ * Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getAdminACLs(ActiveMQDestination)'
*/
@Test
public void testGetAdminACLs() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1");
- Set aclsq1 = authMap.getAdminACLs(q1);
+ Set<GroupPrincipal> aclsq1 = authMap.getAdminACLs(q1);
assertEquals(1, aclsq1.size());
assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
ActiveMQDestination t1 = new ActiveMQTopic("topic1");
- Set aclst1 = authMap.getAdminACLs(t1);
+ Set<GroupPrincipal> aclst1 = authMap.getAdminACLs(t1);
assertEquals(1, aclst1.size());
assertTrue(aclst1.contains(new GroupPrincipal("role1")));
}
/*
- * Test method for
- * 'org.apache.activemq.security.LDAPAuthorizationMap.getReadACLs(ActiveMQDestination)'
+ * Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getReadACLs(ActiveMQDestination)'
*/
@Test
public void testGetReadACLs() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1");
- Set aclsq1 = authMap.getReadACLs(q1);
+ Set<GroupPrincipal> aclsq1 = authMap.getReadACLs(q1);
assertEquals(1, aclsq1.size());
assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
ActiveMQDestination t1 = new ActiveMQTopic("topic1");
- Set aclst1 = authMap.getReadACLs(t1);
+ Set<GroupPrincipal> aclst1 = authMap.getReadACLs(t1);
assertEquals(1, aclst1.size());
assertTrue(aclst1.contains(new GroupPrincipal("role2")));
}
/*
- * Test method for
- * 'org.apache.activemq.security.LDAPAuthorizationMap.getWriteACLs(ActiveMQDestination)'
+ * Test method for 'org.apache.activemq.security.LDAPAuthorizationMap.getWriteACLs(ActiveMQDestination)'
*/
@Test
public void testGetWriteACLs() {
ActiveMQDestination q1 = new ActiveMQQueue("queue1");
- Set aclsq1 = authMap.getWriteACLs(q1);
+ Set<GroupPrincipal> aclsq1 = authMap.getWriteACLs(q1);
assertEquals(2, aclsq1.size());
assertTrue(aclsq1.contains(new GroupPrincipal("role1")));
assertTrue(aclsq1.contains(new GroupPrincipal("role2")));
ActiveMQDestination t1 = new ActiveMQTopic("topic1");
- Set aclst1 = authMap.getWriteACLs(t1);
+ Set<GroupPrincipal> aclst1 = authMap.getWriteACLs(t1);
assertEquals(1, aclst1.size());
assertTrue(aclst1.contains(new GroupPrincipal("role3")));
}
@Test
public void testComposite() {
- ActiveMQDestination q1 = new ActiveMQQueue("queue1,topic://topic1");
- Set aclsq1 = authMap.getWriteACLs(q1);
- assertEquals(0, aclsq1.size());
+ ActiveMQDestination q1 = new ActiveMQQueue("queue1,topic://topic1");
+ Set<GroupPrincipal> aclsq1 = authMap.getWriteACLs(q1);
+ assertEquals(0, aclsq1.size());
}
@Test
public void testAdvisory() {
ActiveMQDestination dest = AdvisorySupport.getConnectionAdvisoryTopic();
- Set acls = authMap.getWriteACLs(dest);
+ Set<GroupPrincipal> acls = authMap.getWriteACLs(dest);
assertEquals(1, acls.size());
assertTrue(acls.contains(new GroupPrincipal("role3")));
}
- @Test
+ @Test
public void testTemp() {
- Set acls = authMap.getTempDestinationAdminACLs();
+ Set<GroupPrincipal> acls = authMap.getTempDestinationAdminACLs();
assertEquals(1, acls.size());
assertTrue(acls.contains(new GroupPrincipal("role1")));
}
-
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/LDAPSecurityTest.java Thu Feb 7 16:43:15 2013
@@ -16,10 +16,20 @@
*/
package org.apache.activemq.security;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.annotations.ApplyLdifFiles;
@@ -31,11 +41,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import javax.jms.*;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
@RunWith( FrameworkRunner.class )
@CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP")})
@@ -51,7 +56,7 @@ public class LDAPSecurityTest extends Ab
@Before
public void setup() throws Exception {
System.setProperty("ldapPort", String.valueOf(getLdapServer().getPort()));
-
+
broker = BrokerFactory.createBroker("xbean:org/apache/activemq/security/activemq-ldap.xml");
broker.start();
broker.waitUntilStarted();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SimpleAnonymousPluginTest.java Thu Feb 7 16:43:15 2013
@@ -25,13 +25,9 @@ import org.apache.activemq.CombinationTe
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class SimpleAnonymousPluginTest extends SimpleAuthenticationPluginTest {
- private static final Logger LOG = LoggerFactory.getLogger(SimpleAnonymousPluginTest.class);
-
public static Test suite() {
return suite(SimpleAnonymousPluginTest.class);
}
@@ -40,10 +36,12 @@ public class SimpleAnonymousPluginTest e
junit.textui.TestRunner.run(suite());
}
+ @Override
protected BrokerService createBroker() throws Exception {
return createBroker("org/apache/activemq/security/simple-anonymous-broker.xml");
- }
-
+ }
+
+ @Override
public void testInvalidAuthentication() throws JMSException {
try {
@@ -64,8 +62,8 @@ public class SimpleAnonymousPluginTest e
} catch (JMSException e) {
}
}
-
-
+
+
public void testAnonymousReceiveSucceeds() throws JMSException {
doReceive(false);
}
@@ -73,7 +71,7 @@ public class SimpleAnonymousPluginTest e
public void testAnonymousReceiveFails() throws JMSException {
doReceive(true);
}
-
+
public void testAnonymousSendFails() throws JMSException {
doSend(true);
}
@@ -81,7 +79,7 @@ public class SimpleAnonymousPluginTest e
public void testAnonymousSendSucceeds() throws JMSException {
doSend(false);
}
-
+
/**
* @see {@link CombinationTestSupport}
*/
@@ -99,7 +97,7 @@ public class SimpleAnonymousPluginTest e
addCombinationValues("password", new Object[] {});
addCombinationValues("destination", new Object[] {new ActiveMQQueue("TEST"), new ActiveMQTopic("TEST"), new ActiveMQQueue("USERS.FOO"), new ActiveMQTopic("USERS.FOO") });
}
-
+
/**
* @see {@link CombinationTestSupport}
*/
@@ -117,5 +115,5 @@ public class SimpleAnonymousPluginTest e
addCombinationValues("password", new Object[] {});
addCombinationValues("destination", new Object[] {new ActiveMQQueue("GUEST.BAR"), new ActiveMQTopic("GUEST.BAR")});
}
-
+
}
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/StubLoginModule.java Thu Feb 7 16:43:15 2013
@@ -39,6 +39,8 @@ public class StubLoginModule implements
private String groupNames[];
private boolean allowLogin;
+ @Override
+ @SuppressWarnings("rawtypes")
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
String allowLoginString = (String)(options.get(ALLOW_LOGIN_PROPERTY));
String usersString = (String)(options.get(USERS_PROPERTY));
@@ -51,6 +53,7 @@ public class StubLoginModule implements
groupNames = groupsString.split(",");
}
+ @Override
public boolean login() throws LoginException {
if (!allowLogin) {
throw new FailedLoginException("Login was not allowed (as specified in configuration).");
@@ -59,6 +62,7 @@ public class StubLoginModule implements
return true;
}
+ @Override
public boolean commit() throws LoginException {
if (!allowLogin) {
throw new FailedLoginException("Login was not allowed (as specified in configuration).");
@@ -79,10 +83,12 @@ public class StubLoginModule implements
return true;
}
+ @Override
public boolean abort() throws LoginException {
return true;
}
+ @Override
public boolean logout() throws LoginException {
subject.getPrincipals().clear();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorParserTest.java Thu Feb 7 16:43:15 2013
@@ -17,18 +17,18 @@
package org.apache.activemq.selector;
import junit.framework.TestCase;
+
import org.apache.activemq.filter.BooleanExpression;
import org.apache.activemq.filter.ComparisonExpression;
import org.apache.activemq.filter.Expression;
import org.apache.activemq.filter.LogicExpression;
import org.apache.activemq.filter.PropertyExpression;
import org.apache.activemq.filter.XPathExpression;
-import org.apache.activemq.spring.ConsumerBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- *
+ *
*/
public class SelectorParserTest extends TestCase {
private static final Logger LOG = LoggerFactory.getLogger(SelectorParserTest.class);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java Thu Feb 7 16:43:15 2013
@@ -21,6 +21,7 @@ import javax.jms.JMSException;
import javax.jms.Message;
import junit.framework.TestCase;
+
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.command.ActiveMQTopic;
@@ -28,7 +29,7 @@ import org.apache.activemq.filter.Boolea
import org.apache.activemq.filter.MessageEvaluationContext;
/**
- *
+ *
*/
public class SelectorTest extends TestCase {
@@ -54,33 +55,33 @@ public class SelectorTest extends TestCa
assertSelector(message, "XPATH '//root/b=\"b\"'", true);
assertSelector(message, "XPATH '//root/b=\"c\"'", false);
assertSelector(message, "XPATH '//root/b!=\"c\"'", true);
-
+
assertSelector(message, "XPATH '//root/*[@key=''second'']'", true);
assertSelector(message, "XPATH '//root/*[@key=''third'']'", false);
assertSelector(message, "XPATH '//root/a[@key=''first'']'", true);
assertSelector(message, "XPATH '//root/a[@num=1]'", true);
assertSelector(message, "XPATH '//root/a[@key=''second'']'", false);
-
+
assertSelector(message, "XPATH '/root/*[@key=''first'' or @key=''third'']'", true);
assertSelector(message, "XPATH '//root/*[@key=''third'' or @key=''forth'']'", false);
assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''second'']'", true);
assertSelector(message, "XPATH '/root/b=''b'' and /root/b[@key=''first'']'", false);
-
+
assertSelector(message, "XPATH 'not(//root/a)'", false);
assertSelector(message, "XPATH 'not(//root/c)'", true);
assertSelector(message, "XPATH '//root/a[not(@key=''first'')]'", false);
assertSelector(message, "XPATH '//root/a[not(not(@key=''first''))]'", true);
-
+
assertSelector(message, "XPATH 'string(//root/b)'", true);
assertSelector(message, "XPATH 'string(//root/a)'", false);
-
+
assertSelector(message, "XPATH 'sum(//@num) < 10'", true);
assertSelector(message, "XPATH 'sum(//@num) > 10'", false);
-
+
assertSelector(message, "XPATH '//root/a[@num > 1]'", false);
- assertSelector(message, "XPATH '//root/b[@num > 1]'", true);
-
+ assertSelector(message, "XPATH '//root/b[@num > 1]'", true);
+
}
public void testJMSPropertySelectors() throws Exception {
@@ -272,44 +273,21 @@ public class SelectorTest extends TestCa
public void testFloatComparisons() throws Exception {
Message message = createMessage();
- // JMS 1.1 Section 3.8.1.1 : Approximate literals use the Java
- // floating-point literal syntax.
- // We will use the java varible x to demo valid floating point syntaxs.
- double x;
-
- // test decimals like x.x
- x = 1.0;
- x = -1.1;
- x = 1.0E1;
- x = 1.1E1;
- x = -1.1E1;
assertSelector(message, "1.0 < 1.1", true);
assertSelector(message, "-1.1 < 1.0", true);
assertSelector(message, "1.0E1 < 1.1E1", true);
assertSelector(message, "-1.1E1 < 1.0E1", true);
- // test decimals like x.
- x = 1.;
- x = 1.E1;
assertSelector(message, "1. < 1.1", true);
assertSelector(message, "-1.1 < 1.", true);
assertSelector(message, "1.E1 < 1.1E1", true);
assertSelector(message, "-1.1E1 < 1.E1", true);
- // test decimals like .x
- x = .5;
- x = -.5;
- x = .5E1;
assertSelector(message, ".1 < .5", true);
assertSelector(message, "-.5 < .1", true);
assertSelector(message, ".1E1 < .5E1", true);
assertSelector(message, "-.5E1 < .1E1", true);
- // test exponents
- x = 4E10;
- x = -4E10;
- x = 5E+10;
- x = 5E-10;
assertSelector(message, "4E10 < 5E10", true);
assertSelector(message, "5E8 < 5E10", true);
assertSelector(message, "-4E10 < 2E10", true);
@@ -361,10 +339,10 @@ public class SelectorTest extends TestCa
message.setByteProperty("byteProp", (byte)123);
message.setByteProperty("byteProp2", (byte)33);
message.setShortProperty("shortProp", (short)123);
- message.setIntProperty("intProp", (int)123);
- message.setLongProperty("longProp", (long)123);
- message.setFloatProperty("floatProp", (float)123);
- message.setDoubleProperty("doubleProp", (double)123);
+ message.setIntProperty("intProp", 123);
+ message.setLongProperty("longProp", 123);
+ message.setFloatProperty("floatProp", 123);
+ message.setDoubleProperty("doubleProp", 123);
message.setIntProperty("rank", 123);
message.setIntProperty("version", 2);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/ConsumerBean.java Thu Feb 7 16:43:15 2013
@@ -22,7 +22,7 @@ import java.util.List;
import javax.jms.Message;
import javax.jms.MessageListener;
-import junit.framework.Assert;
+import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,7 +37,6 @@ public class ConsumerBean extends Assert
public ConsumerBean() {
}
-
/**
* @return all the messages on the list so far, clearing the buffer
*/
@@ -55,6 +54,7 @@ public class ConsumerBean extends Assert
*
* @param message
*/
+ @Override
public void onMessage(Message message) {
synchronized (messages) {
messages.add(message);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/spring/SpringTestSupport.java Thu Feb 7 16:43:15 2013
@@ -19,15 +19,17 @@ package org.apache.activemq.spring;
import java.util.Iterator;
import java.util.List;
+import javax.jms.Message;
+
import junit.framework.TestCase;
-import org.apache.activemq.test.JmsTopicSendReceiveTest;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
- *
+ *
*/
public class SpringTestSupport extends TestCase {
private static final Logger LOG = LoggerFactory.getLogger(SpringTest.class);
@@ -64,9 +66,9 @@ public class SpringTestSupport extends T
consumer.waitForMessagesToArrive(producer.getMessageCount());
// now lets check that the consumer has received some messages
- List messages = consumer.flushMessages();
+ List<Message> messages = consumer.flushMessages();
LOG.info("Consumer has received messages....");
- for (Iterator iter = messages.iterator(); iter.hasNext();) {
+ for (Iterator<Message> iter = messages.iterator(); iter.hasNext();) {
Object message = iter.next();
LOG.info("Received: " + message);
}
@@ -79,6 +81,7 @@ public class SpringTestSupport extends T
*
* @throws Exception
*/
+ @Override
protected void tearDown() throws Exception {
if (consumer != null) {
consumer.stop();
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/MessagePriorityTest.java Thu Feb 7 16:43:15 2013
@@ -43,16 +43,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
abstract public class MessagePriorityTest extends CombinationTestSupport {
-
+
private static final Logger LOG = LoggerFactory.getLogger(MessagePriorityTest.class);
BrokerService broker;
PersistenceAdapter adapter;
-
+
protected ActiveMQConnectionFactory factory;
protected Connection conn;
protected Session sess;
-
+
public boolean useCache = true;
public int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
public boolean dispatchAsync = true;
@@ -64,9 +64,10 @@ abstract public class MessagePriorityTes
public int MSG_NUM = 600;
public int HIGH_PRI = 7;
public int LOW_PRI = 3;
-
+
abstract protected PersistenceAdapter createPersistenceAdapter(boolean delete) throws Exception;
-
+
+ @Override
protected void setUp() throws Exception {
broker = new BrokerService();
broker.setBrokerName("priorityTest");
@@ -96,7 +97,7 @@ abstract public class MessagePriorityTes
broker.setDestinationPolicy(policyMap);
broker.start();
broker.waitUntilStarted();
-
+
factory = new ActiveMQConnectionFactory("vm://priorityTest");
ActiveMQPrefetchPolicy prefetch = new ActiveMQPrefetchPolicy();
prefetch.setAll(prefetchVal);
@@ -108,7 +109,8 @@ abstract public class MessagePriorityTes
conn.start();
sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
-
+
+ @Override
protected void tearDown() throws Exception {
try {
sess.close();
@@ -119,11 +121,11 @@ abstract public class MessagePriorityTes
broker.waitUntilStopped();
}
}
-
+
public void testStoreConfigured() throws Exception {
final Queue queue = sess.createQueue("TEST");
final Topic topic = sess.createTopic("TEST");
-
+
MessageProducer queueProducer = sess.createProducer(queue);
MessageProducer topicProducer = sess.createProducer(topic);
@@ -142,24 +144,25 @@ abstract public class MessagePriorityTes
}
});
assertTrue(broker.getRegionBroker().getDestinationMap().get(topic).getMessageStore().isPrioritizedMessages());
-
+
queueProducer.close();
topicProducer.close();
-
+
}
-
+
protected class ProducerThread extends Thread {
int priority;
int messageCount;
ActiveMQDestination dest;
-
+
public ProducerThread(ActiveMQDestination dest, int messageCount, int priority) {
this.messageCount = messageCount;
this.priority = priority;
this.dest = dest;
}
-
+
+ @Override
public void run() {
try {
MessageProducer producer = sess.createProducer(dest);
@@ -178,28 +181,28 @@ abstract public class MessagePriorityTes
}
public void setMessageCount(int messageCount) {
- this.messageCount = messageCount;
+ this.messageCount = messageCount;
}
-
+
}
-
+
public void initCombosForTestQueues() {
addCombinationValues("useCache", new Object[] {new Boolean(true), new Boolean(false)});
addCombinationValues("deliveryMode", new Object[] {new Integer(DeliveryMode.NON_PERSISTENT), new Integer(DeliveryMode.PERSISTENT)});
}
-
+
public void testQueues() throws Exception {
ActiveMQQueue queue = (ActiveMQQueue)sess.createQueue("TEST");
ProducerThread lowPri = new ProducerThread(queue, MSG_NUM, LOW_PRI);
ProducerThread highPri = new ProducerThread(queue, MSG_NUM, HIGH_PRI);
-
+
lowPri.start();
highPri.start();
-
+
lowPri.join();
highPri.join();
-
+
MessageConsumer queueConsumer = sess.createConsumer(queue);
for (int i = 0; i < MSG_NUM * 2; i++) {
Message msg = queueConsumer.receive(5000);
@@ -219,21 +222,21 @@ abstract public class MessagePriorityTes
public void initCombosForTestDurableSubs() {
addCombinationValues("prefetchVal", new Object[] {new Integer(1000), new Integer(MSG_NUM/4)});
}
-
+
public void testDurableSubs() throws Exception {
ActiveMQTopic topic = (ActiveMQTopic)sess.createTopic("TEST");
TopicSubscriber sub = sess.createDurableSubscriber(topic, "priority");
sub.close();
-
+
ProducerThread lowPri = new ProducerThread(topic, MSG_NUM, LOW_PRI);
ProducerThread highPri = new ProducerThread(topic, MSG_NUM, HIGH_PRI);
-
+
lowPri.start();
highPri.start();
-
+
lowPri.join();
highPri.join();
-
+
sub = sess.createDurableSubscriber(topic, "priority");
for (int i = 0; i < MSG_NUM * 2; i++) {
Message msg = sub.receive(5000);
@@ -271,7 +274,7 @@ abstract public class MessagePriorityTes
addCombinationValues("dispatchAsync", new Object[] {Boolean.FALSE});
addCombinationValues("useCache", new Object[] {Boolean.TRUE, Boolean.FALSE});
}
-
+
public void testDurableSubsReconnect() throws Exception {
ActiveMQTopic topic = (ActiveMQTopic)sess.createTopic("TEST");
final String subName = "priorityDisconnect";
@@ -362,7 +365,7 @@ abstract public class MessagePriorityTes
assertNotNull("Message was null", msg);
LOG.info("received hi? : " + msg);
assertEquals("high priority", HIGH_PRI, msg.getJMSPriority());
-
+
if (i % batchSize*2 == 0) {
msg = sub.receive(15000);
assertNotNull("Message was null", msg);
@@ -414,7 +417,6 @@ abstract public class MessagePriorityTes
LOG.info("Ordered priority messages sent");
sub = sess.createDurableSubscriber(topic, subName);
- int count = 0;
Message msg = sub.receive(15000);
assertNotNull("Message was null", msg);
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/DatabaseLockerConfigTest.java Thu Feb 7 16:43:15 2013
@@ -16,11 +16,11 @@
*/
package org.apache.activemq.store.jdbc;
+import static org.junit.Assert.assertEquals;
+
import org.apache.activemq.broker.AbstractLocker;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
-
public class DatabaseLockerConfigTest {
@Test
Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java?rev=1443600&r1=1443599&r2=1443600&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java (original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/store/jdbc/JDBCMessagePriorityTest.java Thu Feb 7 16:43:15 2013
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Vector;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Message;
@@ -32,15 +33,17 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicSubscriber;
+
import junit.framework.Test;
+
import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.store.MessagePriorityTest;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.util.Wait;
+import org.apache.derby.jdbc.EmbeddedDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.derby.jdbc.EmbeddedDataSource;
public class JDBCMessagePriorityTest extends MessagePriorityTest {
@@ -62,6 +65,7 @@ public class JDBCMessagePriorityTest ext
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
try {
@@ -154,7 +158,7 @@ public class JDBCMessagePriorityTest ext
}
final int closeFrequency = MSG_NUM / 2;
- HashMap dups = new HashMap();
+ HashMap<String, String> dups = new HashMap<String, String>();
sub = consumerSession.createDurableSubscriber(topic, subName);
for (int i = 0; i < MSG_NUM * maxPriority; i++) {
Message msg = sub.receive(10000);
@@ -228,6 +232,7 @@ public class JDBCMessagePriorityTest ext
sub = consumerSession.createDurableSubscriber(topic, subName);
final AtomicInteger count = new AtomicInteger();
sub.setMessageListener(new MessageListener() {
+ @Override
public void onMessage(Message message) {
try {
count.incrementAndGet();
@@ -273,6 +278,7 @@ public class JDBCMessagePriorityTest ext
assertTrue("max X times as slow with consumer:" + withConsumerAve + " , noConsumerMax:" + noConsumerAve,
withConsumerAve < noConsumerAve * reasonableMultiplier);
Wait.waitFor(new Wait.Condition() {
+ @Override
public boolean isSatisified() throws Exception {
LOG.info("count: " + count.get());
return TO_SEND * 2 == count.get();
@@ -422,6 +428,7 @@ public class JDBCMessagePriorityTest ext
}));
}
+ @SuppressWarnings("unused")
private int messageTableDump() throws Exception {
int count = -1;
java.sql.Connection c = dataSource.getConnection();