activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1428458 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Date Thu, 03 Jan 2013 16:33:18 GMT
Author: tabish
Date: Thu Jan  3 16:33:17 2013
New Revision: 1428458

URL: http://svn.apache.org/viewvc?rev=1428458&view=rev
Log:
fix test case after changes in https://issues.apache.org/jira/browse/AMQ-4237 broke the test's
MBean lookup

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java?rev=1428458&r1=1428457&r2=1428458&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Thu Jan  3 16:33:17 2013
@@ -43,60 +43,60 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class SecurityJMXTest extends TestCase {
-	
-	private static final Logger LOG = LoggerFactory.getLogger(SimpleAuthenticationPluginTest.class);
-	private BrokerService broker; 
-	
-	public void setUp() throws Exception {
-		broker = createBroker();
-		broker.waitUntilStarted();
-
-		Thread.sleep(1000);
-	}
-
-	public void tearDown() throws Exception {
-	    broker.stop();
-	}
+
+    private static final Logger LOG = LoggerFactory.getLogger(SimpleAuthenticationPluginTest.class);
+    private BrokerService broker;
+
+    @Override
+    public void setUp() throws Exception {
+        broker = createBroker();
+        broker.waitUntilStarted();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        broker.stop();
+    }
 
     public void testMoveMessages() throws Exception {
         JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
         JMXConnector connector = JMXConnectorFactory.connect(url, null);
         connector.connect();
         MBeanServerConnection connection = connector.getMBeanServerConnection();
-        ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=TEST.Q");
-        QueueViewMBean queueMbean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection,
name, QueueViewMBean.class, true);
+        ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,"
+
+                "destinationType=Queue,destinationName=TEST.Q");
+        QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection,
name, QueueViewMBean.class, true);
         String msgId = queueMbean.sendTextMessage("test", "system", "manager");
         queueMbean.moveMessageTo(msgId, "TEST1.Q");
     }
-    
-    
+
     public void testBrowseExpiredMessages() throws Exception {
         JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
         JMXConnector connector = JMXConnectorFactory.connect(url, null);
         connector.connect();
         MBeanServerConnection connection = connector.getMBeanServerConnection();
-        ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=TEST.Q");
-        QueueViewMBean queueMbean = (QueueViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection,
name, QueueViewMBean.class, true);
+        ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost,"
+
+                "destinationType=Queue,destinationName=TEST.Q");
+        QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection,
name, QueueViewMBean.class, true);
         HashMap<String, String> headers = new HashMap<String, String>();
         headers.put("JMSExpiration", Long.toString(System.currentTimeMillis() + 2000));
         headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
-        String msgId = queueMbean.sendTextMessage(headers, "test", "system", "manager");
+        queueMbean.sendTextMessage(headers, "test", "system", "manager");
         // allow message to expire on the queue
         TimeUnit.SECONDS.sleep(4);
-        
+
         Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system",
"manager");
         c.start();
-        
+
         // browser consumer will force expriation check on addConsumer
         QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new
ActiveMQQueue("TEST.Q"));
         assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements());
-        
+
         // verify dlq got the message, no security exception as brokers context is now used
-        browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
 
+        browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
         assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements());
     }
-    
-	
+
     protected BrokerService createBroker() throws Exception {
         return createBroker("org/apache/activemq/security/simple-auth-broker.xml");
     }
@@ -105,5 +105,4 @@ public class SecurityJMXTest extends Tes
         LOG.info("Loading broker configuration from the classpath with URI: " + uri);
         return BrokerFactory.createBroker(new URI("xbean:" + uri));
     }
-	
 }



Mime
View raw message