[jboss-cvs] JBossAS SVN: r86934 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 7 11:49:01 EDT 2009
Author: emuckenhuber
Date: 2009-04-07 11:49:00 -0400 (Tue, 07 Apr 2009)
New Revision: 86934
Modified:
trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Log:
test topic metrics
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-07 15:46:31 UTC (rev 86933)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-07 15:49:00 UTC (rev 86934)
@@ -32,6 +32,11 @@
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -46,6 +51,7 @@
import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
@@ -62,6 +68,11 @@
public class JmsDestinationUnitTestCase extends AbstractProfileServiceTest
{
+ /** The queue type. */
+ public static final ComponentType QueueType = KnownComponentTypes.JMSDestination.Queue.getType();
+ /** The topic type. */
+ public static final ComponentType TopicType = KnownComponentTypes.JMSDestination.Topic.getType();
+
/** The meta type. */
protected static final MapCompositeMetaType securityConfType;
@@ -96,6 +107,7 @@
suite.addTest(new JmsDestinationUnitTestCase("testQueueOperations"));
suite.addTest(new JmsDestinationUnitTestCase("testRemoveQueue"));
suite.addTest(new JmsDestinationUnitTestCase("testCreateTopic"));
+ suite.addTest(new JmsDestinationUnitTestCase("testTopicMetrics"));
suite.addTest(new JmsDestinationUnitTestCase("testTopicOperations"));
suite.addTest(new JmsDestinationUnitTestCase("testRemoveTopic"));
suite.addTest(new JmsDestinationUnitTestCase("testCreateSecureQueue"));
@@ -145,8 +157,7 @@
public void testDLQ() throws Exception
{
ManagementView mgtView = getManagementView();
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- ManagedComponent queue = mgtView.getComponent("/queue/DLQ", type);
+ ManagedComponent queue = mgtView.getComponent("/queue/DLQ", QueueType);
assertNotNull(queue);
assertEquals("/queue/DLQ", queue.getName());
// Validate some of the expected properties
@@ -162,9 +173,8 @@
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);
+ createComponentTest("QueueTemplate", propValues, getName(), QueueType, jndiName);
+ ManagedComponent queue = activeView.getComponent("testCreateQueue", QueueType);
assertNotNull(queue);
assertEquals("testCreateQueue", queue.getName());
log.info(queue.getProperties().keySet());
@@ -174,8 +184,7 @@
public void testQueueMetrics() throws Exception
{
// Get the managed component
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- ManagedComponent component = getManagementView().getComponent("testCreateQueue", type);
+ ManagedComponent component = getManagementView().getComponent("testCreateQueue", QueueType);
// The message count property
ManagedProperty property = component.getProperty("messageCount");
@@ -212,8 +221,7 @@
public void testQueueOperations() throws Exception
{
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- ManagedComponent component = getManagementView().getComponent("testCreateQueue", type);
+ ManagedComponent component = getManagementView().getComponent("testCreateQueue", QueueType);
ManagedOperation o = getOperation(component, "listMessageCounterAsHTML", new String[0]);
MetaValue v = o.invoke(new MetaValue[0]);
assertNotNull("null operation return value", v);
@@ -230,7 +238,6 @@
String templateName = "QueueTemplate";
MetaValue jndiName1MV = SimpleValueSupport.wrap(jndiName);
propValues.put("JNDIName", jndiName1MV);
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
DeploymentTemplateInfo queue1Info = managementView.getTemplate(templateName);
Map<String, ManagedProperty> testCreateQueue1Props = queue1Info.getProperties();
log.debug("QueueTemplate#1: "+testCreateQueue1Props);
@@ -270,11 +277,11 @@
// Validate the components
// managementView.reload();
- ManagedComponent queue1 = managementView.getComponent("testCreateQueue1", type);
+ ManagedComponent queue1 = managementView.getComponent("testCreateQueue1", QueueType);
assertNotNull(queue1);
assertEquals("testCreateQueue1", queue1.getName());
- ManagedComponent queue2 = managementView.getComponent("testCreateQueue2", type);
+ ManagedComponent queue2 = managementView.getComponent("testCreateQueue2", QueueType);
assertNotNull(queue2);
assertEquals("testCreateQueue2", queue2.getName());
@@ -283,8 +290,7 @@
public void testRemoveQueue() throws Exception
{
removeDeployment("testCreateQueue-service.xml");
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- ManagedComponent queue = getManagementView().getComponent("testCreateQueue", type);
+ ManagedComponent queue = getManagementView().getComponent("testCreateQueue", QueueType);
assertNull("queue should be removed" + queue, queue);
}
@@ -293,17 +299,61 @@
Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
String jndiName = getName();
propValues.put("JNDIName", SimpleValueSupport.wrap(jndiName));
- ComponentType type = KnownComponentTypes.JMSDestination.Topic.getType();
- createComponentTest("TopicTemplate", propValues, getName(), type, jndiName);
- ManagedComponent topic = activeView.getComponent("testCreateTopic", type);
+ createComponentTest("TopicTemplate", propValues, getName(), TopicType, jndiName);
+ ManagedComponent topic = activeView.getComponent("testCreateTopic", TopicType);
assertNotNull(topic);
assertEquals("testCreateTopic", topic.getName());
}
+
+ public void testTopicMetrics() throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ ManagedComponent component = mgtView.getComponent("testCreateTopic", TopicType);
+ assertNotNull(component);
+
+ Topic topic = (Topic) getInitialContext().lookup("testCreateTopic");
+ TopicConnectionFactory cf = (TopicConnectionFactory) getInitialContext().lookup("ConnectionFactory");
+
+ TopicConnection connection = cf.createTopicConnection();
+ TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ session.createSubscriber(topic);
+
+ TopicPublisher pub = session.createPublisher(topic);
+ try
+ {
+ for(int i = 0; i < 10; i++)
+ pub.send(session.createTextMessage("Message nr " + i));
+
+ SimpleValue nondurable = (SimpleValue)component.getProperty("nonDurableSubscriptionsCount").getValue();
+ SimpleValue durable = (SimpleValue)component.getProperty("durableSubscriptionsCount").getValue();
+ SimpleValue all = (SimpleValue)component.getProperty("allSubscriptionsCount").getValue();
+ SimpleValue allMessageCount = (SimpleValue)component.getProperty("allMessageCount").getValue();
+
+ CollectionValue messageCounters = (CollectionValue) component.getProperty("messageCounters").getValue();
+ assertNotNull(messageCounters);
+
+ assertEquals(1, nondurable.getValue());
+ assertEquals(0, durable.getValue());
+ assertEquals(1, all.getValue());
+ assertEquals(10, allMessageCount.getValue());
+
+ CompositeValue messageCounter = (CompositeValue) messageCounters.iterator().next();
+ assertNotNull(messageCounter);
+
+ SimpleValue count = (SimpleValue) messageCounter.get("messageCount");
+ assertEquals(count, allMessageCount);
+ }
+ finally
+ {
+ pub.close();
+ session.close();
+ }
+ }
+
public void testTopicOperations() throws Exception
{
- ComponentType type = KnownComponentTypes.JMSDestination.Topic.getType();
- ManagedComponent component = getManagementView().getComponent("testCreateTopic", type);
+ ManagedComponent component = getManagementView().getComponent("testCreateTopic", TopicType);
ManagedOperation o = getOperation(component, "listAllSubscriptionsAsHTML", new String[0]);
MetaValue v = o.invoke(new MetaValue[0]);
assertNotNull("null operation return value", v);
@@ -313,8 +363,7 @@
public void testRemoveTopic() throws Exception
{
removeDeployment("testCreateTopic-service.xml");
- ComponentType type = KnownComponentTypes.JMSDestination.Topic.getType();
- ManagedComponent topic = getManagementView().getComponent("testCreateTopic", type);
+ ManagedComponent topic = getManagementView().getComponent("testCreateTopic", TopicType);
assertNull("topic should be removed " + topic, topic);
}
@@ -332,9 +381,8 @@
CompositeValue map = new MapCompositeValueSupport(values, securityConfType);
propValues.put("securityConfig", map);
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
- ManagedComponent queue = activeView.getComponent("testCreateSecureQueue", type);
+ createComponentTest("QueueTemplate", propValues, getName(), QueueType, jndiName);
+ ManagedComponent queue = activeView.getComponent("testCreateSecureQueue", QueueType);
assertNotNull(queue);
assertEquals("testCreateSecureQueue", queue.getName());
log.info(queue.getProperties().keySet());
@@ -345,8 +393,7 @@
public void testRemoveSecureQueue() throws Exception
{
removeDeployment("testCreateSecureQueue-service.xml");
- ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
- ManagedComponent queue = getManagementView().getComponent("testCreateSecureQueue", type);
+ ManagedComponent queue = getManagementView().getComponent("testCreateSecureQueue", QueueType);
assertNull("queue should be removed" + queue, queue);
}
More information about the jboss-cvs-commits
mailing list