[jboss-cvs] JBoss Messaging SVN: r4714 - in branches/Branch_JBMESSAGING-1303: src/main/org/jboss/messaging/jms/server/management and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 23 05:12:09 EDT 2008
Author: jmesnil
Date: 2008-07-23 05:12:08 -0400 (Wed, 23 Jul 2008)
New Revision: 4714
Added:
branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/
branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/
branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java
branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java
Removed:
branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java
Modified:
branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java
branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java
branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
JBMESSAGING-1303: Revisit management interfaces
* added unit tests for SubscriberInfo & JMSMessageInfo
Deleted: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.jms.server;
-
-import java.io.Serializable;
-
-/**
- * A SubscriptionInfo
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1935 $</tt>
- *
- * $Id: SubscriptionInfo.java 1935 2007-01-09 23:29:20Z clebert.suconic at jboss.com $
- *
- */
-public class SubscriptionInfo implements Serializable
-{
- private static final long serialVersionUID = -38689006079435295L;
-
- private final String id;
-
- private final boolean durable;
-
- private final String name;
-
- private final String clientID;
-
- private final String selector;
-
- private final int messageCount;
-
- private final int maxSize;
-
- public SubscriptionInfo(final String id, final boolean durable, final String name,
- final String clientID, final String selector, final int messageCount, final int maxSize)
- {
- this.id = id;
- this.durable = durable;
- this.name = name;
- this.clientID = clientID;
- this.selector = selector;
- this.messageCount = messageCount;
- this.maxSize = maxSize;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getClientID()
- {
- return clientID;
- }
-
- public boolean isDurable()
- {
- return durable;
- }
-
- public int getMaxSize()
- {
- return maxSize;
- }
-
- public int getMessageCount()
- {
- return messageCount;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getSelector()
- {
- return selector;
- }
-
-}
Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -173,7 +173,42 @@
{
return messageID;
}
+
+ public String getJMSCorrelationID()
+ {
+ return correlationID;
+ }
+ public String getJMSDeliveryMode()
+ {
+ return deliveryMode;
+ }
+
+ public int getJMSPriority()
+ {
+ return priority;
+ }
+
+ public String getJMSReplyTo()
+ {
+ return replyTo;
+ }
+
+ public long getJMSTimestamp()
+ {
+ return timestamp;
+ }
+
+ public long getExpiration()
+ {
+ return expiration;
+ }
+
+ public String getJMSType()
+ {
+ return jmsType;
+ }
+
public void putProperty(String key, String value)
{
properties.put(key, value);
Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -44,11 +44,11 @@
public class SubscriberInfo
{
// Constants -----------------------------------------------------
-
+
+ public static final CompositeType TYPE;
+ private static final TabularType TABULAR_TYPE;
private static final String SUBSCRIBER_TYPE_NAME = "SubscriberInfo";
private static final String SUBSCRIBER_TABULAR_TYPE_NAME = "SubscriberTabularInfo";
- private static final CompositeType SUBSCRIBER_TYPE;
- private static final TabularType SUBSCRIBER_TABULAR_TYPE;
private static final String[] ITEM_NAMES = new String[] { "id", "clientID",
"name", "durable", "selector", "messageCount", "maxSizeBytes" };
private static final String[] ITEM_DESCRIPTIONS = new String[] {
@@ -62,8 +62,8 @@
{
try
{
- SUBSCRIBER_TYPE = createSubscriberInfoType();
- SUBSCRIBER_TABULAR_TYPE = createSubscriberInfoTabularType();
+ TYPE = createSubscriberInfoType();
+ TABULAR_TYPE = createSubscriberInfoTabularType();
} catch (OpenDataException e)
{
throw new IllegalStateException(e);
@@ -84,7 +84,7 @@
public static TabularData toTabularData(SubscriberInfo[] infos)
{
- TabularData data = new TabularDataSupport(SUBSCRIBER_TABULAR_TYPE);
+ TabularData data = new TabularDataSupport(TABULAR_TYPE);
for (SubscriberInfo subscriberInfo : infos)
{
data.put(subscriberInfo.toCompositeData());
@@ -104,7 +104,7 @@
throws OpenDataException
{
return new TabularType(SUBSCRIBER_TABULAR_TYPE_NAME,
- "Table of SubscriberInfo", SUBSCRIBER_TYPE, new String[] { "id" });
+ "Table of SubscriberInfo", TYPE, new String[] { "id" });
}
// Constructors --------------------------------------------------
@@ -162,7 +162,7 @@
{
try
{
- return new CompositeDataSupport(SUBSCRIBER_TYPE, ITEM_NAMES,
+ return new CompositeDataSupport(TYPE, ITEM_NAMES,
new Object[] { id, clientID, name, durable, selector,
messageCount, maxSizeBytes });
} catch (OpenDataException e)
Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -43,6 +43,7 @@
import org.jboss.messaging.jms.JBossTopic;
import org.jboss.messaging.jms.client.JBossConnectionFactory;
import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.container.DatabaseClearer;
import org.jboss.test.messaging.tools.container.Server;
@@ -797,9 +798,9 @@
servers.get(server).undeployConnectionFactory(objectName);
}
- protected List listAllSubscriptionsForTopic(String s) throws Exception
+ protected List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
{
- return servers.get(0).listAllSubscriptionsForTopic(s);
+ return servers.get(0).listAllSubscribersForTopic(s);
}
protected Integer getMessageCountForQueue(String s) throws Exception
Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -36,7 +36,7 @@
import javax.jms.Topic;
import javax.jms.TopicSubscriber;
-import org.jboss.messaging.jms.server.SubscriptionInfo;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
/**
@@ -81,13 +81,13 @@
s.createDurableSubscriber(topic1, "monicabelucci");
- List subs = listAllSubscriptionsForTopic("Topic1");
+ List<SubscriberInfo> subs = listAllSubscribersForTopic("Topic1");
assertNotNull(subs);
assertEquals(1, subs.size());
- SubscriptionInfo info = (SubscriptionInfo)subs.get(0);
+ SubscriberInfo info = subs.get(0);
assertEquals("monicabelucci", info.getName());
@@ -95,11 +95,11 @@
conn.close();
- subs = listAllSubscriptionsForTopic("Topic1");
+ subs = listAllSubscribersForTopic("Topic1");
assertEquals(1, subs.size());
- info = (SubscriptionInfo)subs.get(0);
+ info = subs.get(0);
assertEquals("monicabelucci", info.getName());
Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -49,6 +49,7 @@
import org.jboss.messaging.jms.JBossDestination;
import org.jboss.messaging.jms.server.JMSServerManager;
import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
import org.jboss.messaging.jms.server.management.TopicControlMBean;
import org.jboss.messaging.jms.server.management.impl.JMSManagementRegistrationImpl;
import org.jboss.messaging.microcontainer.JBMBootstrapServer;
@@ -647,7 +648,7 @@
getJMSServerManager().removeAllMessages(destination);
}
- public List listAllSubscriptionsForTopic(String s) throws Exception
+ public List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
{
ObjectName objectName = JMSManagementRegistrationImpl.getJMSTopicObjectName(s);
TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -46,6 +46,7 @@
import org.jboss.messaging.jms.JBossDestination;
import org.jboss.messaging.jms.server.JMSServerManager;
import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
import org.jboss.messaging.jms.server.management.TopicControlMBean;
import org.jboss.messaging.jms.server.management.impl.JMSManagementRegistrationImpl;
@@ -471,7 +472,7 @@
}
- public List listAllSubscriptionsForTopic(String s) throws Exception
+ public List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
{
ObjectName objectName = JMSManagementRegistrationImpl.getJMSTopicObjectName(s);
TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
Modified: branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-07-23 00:17:58 UTC (rev 4713)
+++ branches/Branch_JBMESSAGING-1303/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -36,6 +36,7 @@
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.jms.JBossDestination;
import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
/**
* The remote interface exposed by TestServer.
@@ -259,7 +260,7 @@
Integer getMessageCountForQueue(String queueName) throws Exception;
- List listAllSubscriptionsForTopic(String s) throws Exception;
+ List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception;
Set<Role> getSecurityConfig() throws Exception;
Added: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java (rev 0)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.unit.jms.server.management;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.management.MessageInfo;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.jms.server.management.JMSMessageInfo;
+import org.jboss.messaging.tests.util.RandomUtil;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class JMSMessageInfoTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ private static void assertEquals(JMSMessageInfo expected,
+ CompositeData actual)
+ {
+ assertTrue(actual.getCompositeType().equals(JMSMessageInfo.TYPE));
+
+ assertEquals(expected.getJMSMessageID(), actual.get("JMSMessageID"));
+ assertEquals(expected.getJMSCorrelationID(), actual
+ .get("JMSCorrelationID"));
+ assertEquals(expected.getJMSDeliveryMode(), actual.get("JMSDeliveryMode"));
+ assertEquals(expected.getJMSPriority(), actual.get("JMSPriority"));
+ assertEquals(expected.getJMSReplyTo(), actual.get("JMSReplyTo"));
+ assertEquals(expected.getJMSTimestamp(), actual.get("JMSTimestamp"));
+ assertEquals(expected.getJMSType(), actual.get("JMSType"));
+ assertEquals(expected.getExpiration(), actual.get("expiration"));
+
+ TabularData propsDatas = (TabularData) actual.get("properties");
+ Collection<CompositeData> props = propsDatas.values();
+ assertEquals(expected.getProperties().size(), props.size());
+ for (CompositeData prop : props)
+ {
+ String actualKey = (String) prop.get("key");
+ String actualValue = (String) prop.get("value");
+
+ assertTrue(expected.getProperties().containsKey(actualKey));
+ assertEquals(expected.getProperties().get(actualKey), actualValue);
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testToCompositeData() throws Exception
+ {
+ JMSMessageInfo info = new JMSMessageInfo(randomString(), randomString(),
+ randomString(), randomInt(), randomString(), randomLong(),
+ randomLong(), randomString());
+ info.putProperty(randomString(), randomString());
+ CompositeData data = info.toCompositeData();
+
+ assertEquals(info, data);
+ }
+
+ public void testToTabularData() throws Exception
+ {
+ JMSMessageInfo info_1 = new JMSMessageInfo(randomString(),
+ randomString(), randomString(), randomInt(), randomString(),
+ randomLong(), randomLong(), randomString());
+ info_1.putProperty(randomString(), randomString());
+ info_1.putProperty(randomString(), randomString());
+ JMSMessageInfo info_2 = new JMSMessageInfo(randomString(),
+ randomString(), randomString(), randomInt(), randomString(),
+ randomLong(), randomLong(), randomString());
+ info_2.putProperty(randomString(), randomString());
+ JMSMessageInfo[] messages = new JMSMessageInfo[] { info_1, info_2 };
+
+ TabularData data = JMSMessageInfo.toTabularData(messages);
+ assertEquals(2, data.size());
+ CompositeData data_1 = data
+ .get(new Object[] { info_1.getJMSMessageID() });
+ CompositeData data_2 = data
+ .get(new Object[] { info_2.getJMSMessageID() });
+
+ assertEquals(info_1, data_1);
+ assertEquals(info_2, data_2);
+ }
+
+ public void testToTabularDataWithEmptyMessages() throws Exception
+ {
+ TabularData data = JMSMessageInfo.toTabularData(new JMSMessageInfo[0]);
+ assertEquals(0, data.size());
+ }
+
+ public void testFromServerMessage() throws Exception
+ {
+ ServerMessage message = createMock(ServerMessage.class);
+ expect(message.getProperty(new SimpleString("JMSMessageID"))).andStubReturn(randomSimpleString());
+ expect(message.getProperty(new SimpleString("JMSCorrelationID"))).andStubReturn(randomSimpleString());
+ expect(message.getProperty(new SimpleString("JMSType"))).andStubReturn(randomSimpleString());
+ expect(message.isDurable()).andStubReturn(randomBoolean());
+ expect(message.getPriority()).andStubReturn(randomByte());
+ expect(message.getProperty(new SimpleString("JMSReplyTo"))).andStubReturn(randomSimpleString());
+ expect(message.getTimestamp()).andStubReturn(randomLong());
+ expect(message.getExpiration()).andStubReturn(randomLong());
+ Set<SimpleString> propNames = new HashSet<SimpleString>();
+ propNames.add(new SimpleString("foo"));
+ expect(message.getPropertyNames()).andStubReturn(propNames);
+ expect(message.getProperty(new SimpleString("foo"))).andStubReturn(randomSimpleString());
+
+ replay(message);
+ JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message );
+
+ verify(message);
+
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java (rev 0)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java 2008-07-23 09:12:08 UTC (rev 4714)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.unit.jms.server.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class SubscriberInfoTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ private static void assertEquals(SubscriberInfo expected,
+ CompositeData actual)
+ {
+ assertTrue(actual.getCompositeType().equals(SubscriberInfo.TYPE));
+
+ assertEquals(expected.getID(), actual.get("id"));
+ assertEquals(expected.getClientID(), actual.get("clientID"));
+ assertEquals(expected.getName(), actual.get("name"));
+ assertEquals(expected.isDurable(), actual.get("durable"));
+ assertEquals(expected.getSelector(), actual.get("selector"));
+ assertEquals(expected.getMessageCount(), actual.get("messageCount"));
+ assertEquals(expected.getMaxSizeBytes(), actual.get("maxSizeBytes"));
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testToCompositeData() throws Exception
+ {
+ SubscriberInfo info = new SubscriberInfo(randomString(), randomString(),
+ randomString(), randomBoolean(), randomString(), randomInt(),
+ randomInt());
+ CompositeData data = info.toCompositeData();
+
+ assertEquals(info, data);
+ }
+
+ public void testToTabularData() throws Exception
+ {
+ SubscriberInfo info_1 = new SubscriberInfo(randomString(), randomString(),
+ randomString(), randomBoolean(), randomString(), randomInt(),
+ randomInt());
+ SubscriberInfo info_2 = new SubscriberInfo(randomString(), randomString(),
+ randomString(), randomBoolean(), randomString(), randomInt(),
+ randomInt());
+ SubscriberInfo[] infos = new SubscriberInfo[] { info_1, info_2 };
+
+ TabularData data = SubscriberInfo.toTabularData(infos);
+ assertEquals(2, data.size());
+ CompositeData data_1 = data.get(new Object[] { info_1.getID() });
+ CompositeData data_2 = data.get(new Object[] { info_2.getID() });
+
+ assertEquals(info_1, data_1);
+ assertEquals(info_2, data_2);
+ }
+
+ public void testToTabularDataWithEmptyMessages() throws Exception
+ {
+ TabularData data = SubscriberInfo.toTabularData(new SubscriberInfo[0]);
+ assertEquals(0, data.size());
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
More information about the jboss-cvs-commits
mailing list