[jboss-cvs] JBossAS SVN: r86812 - in branches/Branch_5_x: testsuite/src/main/org/jboss/test/profileservice/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Apr 5 07:33:32 EDT 2009


Author: emuckenhuber
Date: 2009-04-05 07:33:31 -0400 (Sun, 05 Apr 2009)
New Revision: 86812

Modified:
   branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
   branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Log:
set jms destination MOs to runtime = true, to enable ManagedOperations

Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java	2009-04-05 11:30:00 UTC (rev 86811)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java	2009-04-05 11:33:31 UTC (rev 86812)
@@ -52,7 +52,8 @@
  */
 @ManagementObject(
       componentType = @ManagementComponent(type = "JMSDestination", subtype = "Queue"),
-      properties = ManagementProperties.EXPLICIT)
+      properties = ManagementProperties.EXPLICIT,
+      isRuntime = true)
 public class QueueServiceMO implements Serializable
 {
    private static final long serialVersionUID = 8483702123881698540L;

Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java	2009-04-05 11:30:00 UTC (rev 86811)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java	2009-04-05 11:33:31 UTC (rev 86812)
@@ -50,7 +50,8 @@
  */
 @ManagementObject(
       componentType = @ManagementComponent(type = "JMSDestination", subtype = "Topic"),
-      properties = ManagementProperties.EXPLICIT)
+      properties = ManagementProperties.EXPLICIT,
+      isRuntime = true)
 public class TopicServiceMO implements Serializable
 {
    private static final long serialVersionUID = -2972719964517681496L;

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-05 11:30:00 UTC (rev 86811)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-05 11:33:31 UTC (rev 86812)
@@ -26,6 +26,13 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -34,6 +41,7 @@
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.types.MapCompositeMetaType;
 import org.jboss.metatype.api.types.MetaType;
@@ -42,6 +50,7 @@
 import org.jboss.metatype.api.values.CompositeValueSupport;
 import org.jboss.metatype.api.values.MapCompositeValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
 
@@ -83,13 +92,15 @@
       suite.addTest(new JmsDestinationUnitTestCase("testTopicTemplate"));
       suite.addTest(new JmsDestinationUnitTestCase("testDLQ"));
       suite.addTest(new JmsDestinationUnitTestCase("testCreateQueue"));
+      suite.addTest(new JmsDestinationUnitTestCase("testQueueMetrics"));
+      suite.addTest(new JmsDestinationUnitTestCase("testQueueOperations"));
       suite.addTest(new JmsDestinationUnitTestCase("testRemoveQueue"));
+      suite.addTest(new JmsDestinationUnitTestCase("testCreateTopic"));
+      suite.addTest(new JmsDestinationUnitTestCase("testTopicOperations"));
+      suite.addTest(new JmsDestinationUnitTestCase("testRemoveTopic"));
       suite.addTest(new JmsDestinationUnitTestCase("testCreateSecureQueue"));
       suite.addTest(new JmsDestinationUnitTestCase("testRemoveSecureQueue"));
-      suite.addTest(new JmsDestinationUnitTestCase("testCreateTopic"));
-      suite.addTest(new JmsDestinationUnitTestCase("testRemoveTopic"));
 
-
       return suite;
    }  
 
@@ -150,31 +161,46 @@
       Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
       String jndiName = getName();
       propValues.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+      propValues.put("downCacheSize", SimpleValueSupport.wrap(1999));
       ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
       createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
       ManagedComponent queue = activeView.getComponent("testCreateQueue", type);
       assertNotNull(queue);
       assertEquals("testCreateQueue", queue.getName());
       log.info(queue.getProperties().keySet());
+      assertEquals("downCacheSize", queue.getProperty("downCacheSize").getValue(), new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 1999));
    }
-
-   public void testCreateQueueAndUpdate() throws Exception
+   
+   public void testQueueMetrics() throws Exception
    {
-      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
-      String jndiName = getName();
-      propValues.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+      Queue queue = (Queue) getInitialContext().lookup("testCreateQueue");
+      assertNotNull(queue);
+      QueueConnectionFactory qCf = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
+      QueueConnection c = qCf.createQueueConnection();
+      c.start();
+      QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+      QueueSender sender = s.createSender(queue);
+      
+      sender.send(s.createTextMessage("Hey!"));
+      c.stop();
+      c.close();
+      
       ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
-      createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
-      ManagedComponent queue = activeView.getComponent("testCreateQueueAndUpdate", type);
-      assertNotNull(queue);
-      assertEquals("testCreateQueueAndUpdate", queue.getName());
-      log.info(queue.getProperties());
-      // downCacheSize, createdProgrammatically, scheduledMessageCount, maxSize, messageStatistics, securityConfig, JNDIName, consumerCount, messageCounterHistoryDayLimit, messageCount, redeliveryDelay, maxDeliveryAttempts, fullSize, messageCounter, pageSize, deliveringCount, expiryQueue, DLQ, name, clustered, serverPeer
-      ManagedProperty pageSize = queue.getProperty("pageSize");
-      log.info("pageSize: "+pageSize);
-      pageSize.setValue(null);
-      activeView.updateComponent(queue);
+      ManagedComponent component = getManagementView().getComponent("testCreateQueue", type);
+      ManagedProperty property = component.getProperty("messageCount");
+      assertNotNull(property);
+      assertTrue((Integer) ((SimpleValue)property.getValue()).getValue() > 0);
    }
+   
+   public void testQueueOperations() throws Exception
+   {
+      ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
+      ManagedComponent component = getManagementView().getComponent("testCreateQueue", type);
+      ManagedOperation o = getOperation(component, "listMessageCounterAsHTML", new String[0]);
+      MetaValue v = o.invoke(new MetaValue[0]);
+      assertNotNull("null operation return value", v);
+      log.debug("result" + v);
+   }
 
    public void testMultipleQueues() throws Exception
    {
@@ -256,6 +282,16 @@
       assertEquals("testCreateTopic", topic.getName());
    }
 
+   public void testTopicOperations() throws Exception
+   {
+      ComponentType type = KnownComponentTypes.JMSDestination.Topic.getType();
+      ManagedComponent component = getManagementView().getComponent("testCreateTopic", type);
+      ManagedOperation o = getOperation(component, "listAllSubscriptionsAsHTML", new String[0]);
+      MetaValue v = o.invoke(new MetaValue[0]);
+      assertNotNull("null operation return value", v);
+      log.debug("result" + v);
+   }
+   
    public void testRemoveTopic() throws Exception
    {
       removeDeployment("testCreateTopic-service.xml");
@@ -296,6 +332,21 @@
       assertNull("queue should be removed" + queue, queue);
    }
    
+   protected ManagedOperation getOperation(ManagedComponent comp, String name, String[] signature)
+   {
+      assertNotNull(comp);
+      ManagedOperation operation = null;
+      for(ManagedOperation o : comp.getOperations())
+      {
+         if(o.getName().equals(name))
+         {
+            if(Arrays.equals(signature, o.getReflectionSignature()))
+               operation = o;
+         }
+      }
+      assertNotNull("null operation", operation);
+      return operation;
+   }
    
    protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
    {




More information about the jboss-cvs-commits mailing list