[jboss-cvs] JBoss Messaging SVN: r6106 - in trunk: src/config and 22 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 18 11:22:19 EDT 2009
Author: jmesnil
Date: 2009-03-18 11:22:19 -0400 (Wed, 18 Mar 2009)
New Revision: 6106
Added:
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSMessagingProxy.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlUsingJMSTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlUsingJMSTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlUsingJMSTest.java
Removed:
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java
Modified:
trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java
trunk/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java
trunk/src/config/logging.properties
trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
trunk/src/main/org/jboss/messaging/core/management/impl/ReplicationOperationInvokerImpl.java
trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/jms/JBossQueue.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareTopicControlWrapper.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverManagementTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreAddressControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreMessagingProxy.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java
Log:
management integration tests
* added integration tests for JMS resources using either JMX or JMS messages
* refactored management messages so that they can work with both core messages and management messages
- any returned result (attribute value or operation result) is returned as a serialized java object in the message body
- it will be received as a JMS ObjectMessage by the client
- or a core message where the object must be deserialized (using ManagementHelper.getResult(Message) for that)
Modified: trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -113,19 +113,17 @@
}
}
- // create a message to retrieve one or many attributes
+ // create a message to retrieve an attribute
mngmntMessage = clientSession.createClientMessage(false);
- ManagementHelper.putAttributes(mngmntMessage,
+ ManagementHelper.putAttribute(mngmntMessage,
ObjectNames.getQueueObjectName(queue, queue),
- "MessageCount",
- "Durable");
+ "MessageCount");
reply = requestor.request(mngmntMessage);
System.out.println("sent management message to retrieve attributes");
if (reply != null)
{
System.out.println("\tattributes:");
- System.out.println("\t- MessageCount=" + reply.getProperty(new SimpleString("MessageCount")));
- System.out.println("\t- Durable=" + reply.getProperty(new SimpleString("Durable")));
+ System.out.println("\t- MessageCount=" + ManagementHelper.getResult(reply));
}
// create a message to invoke the operation sendMessageToDeadLetterAddress(long) on the
@@ -133,10 +131,10 @@
mngmntMessage = clientSession.createClientMessage(false);
ManagementHelper.putOperationInvocation(mngmntMessage,
ObjectNames.getQueueObjectName(queue, queue),
- "sendMessageToDLQ",
+ "sendMessageToDeadLetterAddress",
(long)6161);
reply = requestor.request(mngmntMessage);
- System.out.println("sent management message to retrieve attributes");
+ System.out.println("sent management message to invoke operation");
if (reply != null)
{
if (ManagementHelper.isOperationResult(reply))
@@ -144,7 +142,7 @@
System.out.println("\toperation succeeded:" + ManagementHelper.hasOperationSucceeded(reply));
if (ManagementHelper.hasOperationSucceeded(reply))
{
- System.out.println("\t- result=" + reply.getProperty(new SimpleString("sendMessageToDLQ")));
+ System.out.println("\t- result=" + ManagementHelper.getResult(reply));
}
else
{
Modified: trunk/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -30,7 +30,6 @@
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.utils.SimpleString;
-import org.jboss.messaging.jms.client.JBossTextMessage;
/**
* Uses the core messaging API to send and receive a message to a queue.
@@ -49,7 +48,7 @@
clientSession = sessionFactory.createSession(false, true, true);
SimpleString queue = new SimpleString("queuejms.testQueue");
ClientProducer clientProducer = clientSession.createProducer(queue);
- ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE, false);
+ ClientMessage message = clientSession.createClientMessage(false);
message.getBody().writeString("Hello!");
clientProducer.send(message);
ClientConsumer clientConsumer = clientSession.createConsumer(queue);
Modified: trunk/src/config/logging.properties
===================================================================
--- trunk/src/config/logging.properties 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/config/logging.properties 2009-03-18 15:22:19 UTC (rev 6106)
@@ -23,7 +23,7 @@
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
-.level= INFO
+.level= WARN
############################################################
# Handler specific properties.
Modified: trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -50,9 +50,9 @@
public static final SimpleString HDR_JMX_OBJECTNAME = new SimpleString("_JBM_JMX_ObjectName");
- public static final SimpleString HDR_JMX_ATTRIBUTE_PREFIX = new SimpleString("_JBM_JMXAttribute.");
+ public static final SimpleString HDR_JMX_ATTRIBUTE = new SimpleString("_JBM_JMXAttribute");
- public static final SimpleString HDR_JMX_OPERATION_PREFIX = new SimpleString("_JBM_JMXOperation.");
+ public static final SimpleString HDR_JMX_OPERATION_PREFIX = new SimpleString("_JBM_JMXOperation$");
public static final SimpleString HDR_JMX_OPERATION_NAME = new SimpleString(HDR_JMX_OPERATION_PREFIX + "name");
@@ -63,35 +63,29 @@
public static final SimpleString HDR_NOTIFICATION_TYPE = new SimpleString("_JBM_NotifType");
public static final SimpleString HDR_NOTIFICATION_TIMESTAMP = new SimpleString("_JBM_NotifTimestamp");
-
+
public static final SimpleString HDR_ROUTING_NAME = new SimpleString("_JBM_RoutingName");
-
+
public static final SimpleString HDR_CLUSTER_NAME = new SimpleString("_JBM_ClusterName");
-
+
public static final SimpleString HDR_ADDRESS = new SimpleString("_JBM_Address");
-
+
public static final SimpleString HDR_BINDING_ID = new SimpleString("_JBM_Binding_ID");
-
+
public static final SimpleString HDR_BINDING_TYPE = new SimpleString("_JBM_Binding_Type");
-
+
public static final SimpleString HDR_FILTERSTRING = new SimpleString("_JBM_FilterString");
-
+
public static final SimpleString HDR_DISTANCE = new SimpleString("_JBM_Distance");
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
- public static void putAttributes(final Message message,
- final ObjectName objectName,
- final String... attributes)
+ public static void putAttribute(final Message message, final ObjectName objectName, final String attribute)
{
message.putStringProperty(HDR_JMX_OBJECTNAME, new SimpleString(objectName.toString()));
- for (int i = 0; i < attributes.length; i++)
- {
- message.putStringProperty(new SimpleString(HDR_JMX_ATTRIBUTE_PREFIX + Integer.toString(i)),
- new SimpleString(attributes[i]));
- }
+ message.putStringProperty(HDR_JMX_ATTRIBUTE, new SimpleString(attribute));
}
public static void putOperationInvocation(final Message message,
@@ -127,7 +121,7 @@
{
String s = propertyName.toString();
// split by the dot
- String[] ss = s.split("\\.");
+ String[] ss = s.split("\\$");
try
{
int index = Integer.parseInt(ss[ss.length - 1]);
@@ -150,7 +144,7 @@
}
return params;
}
-
+
public static boolean isOperationResult(final Message message)
{
return message.containsProperty(HDR_JMX_OPERATION_SUCCEEDED);
@@ -161,34 +155,29 @@
return !(isOperationResult(message));
}
- public static TabularData getTabularDataProperty(final Message message, final String key)
+ public static void storeResult(final Message message, final Object result)
{
- Object object = message.getProperty(new SimpleString(key));
- if (object instanceof byte[])
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try
{
- return (TabularData)from((byte[])object);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(result);
}
- throw new IllegalArgumentException(key + " property is not a valid TabularData");
- }
-
- public static Object[] getArrayProperty(final Message message, final String key)
- {
- Object object = message.getProperty(new SimpleString(key));
- if (object instanceof byte[])
+ catch (IOException e)
{
- return (Object[])from((byte[])object);
+ throw new IllegalStateException(result + " can not be written to a byte array");
}
- throw new IllegalArgumentException(key + " property is not a valid array");
+ byte[] data = baos.toByteArray();
+ message.getBody().writeInt(data.length);
+ message.getBody().writeBytes(data);
}
-
- public static CompositeData getCompositeDataProperty(final Message message, final String key)
+
+ public static Object getResult(final Message message)
{
- Object object = message.getProperty(new SimpleString(key));
- if (object instanceof byte[])
- {
- return (CompositeData)from((byte[])object);
- }
- throw new IllegalArgumentException(key + " property is not a valid CompositeData");
+ int len = message.getBody().readInt();
+ byte[] data = new byte[len];
+ message.getBody().readBytes(data);
+ return from(data);
}
public static boolean hasOperationSucceeded(final Message message)
@@ -215,6 +204,13 @@
public static void storeTypedProperty(final Message message, final SimpleString key, final Object typedProperty)
{
+ if (typedProperty == null)
+ {
+ return;
+ }
+
+ checkSimpleType(typedProperty);
+
if (typedProperty instanceof Void)
{
// do not put the returned value if the operation was a procedure
@@ -251,14 +247,6 @@
{
message.putStringProperty(key, new SimpleString((String)typedProperty));
}
- else if (typedProperty instanceof TabularData || typedProperty instanceof CompositeData)
- {
- storePropertyAsBytes(message, key, typedProperty);
- }
- else if (typedProperty != null && typedProperty.getClass().isArray())
- {
- storePropertyAsBytes(message, key, typedProperty);
- }
// serialize as a SimpleString
else
{
@@ -266,6 +254,21 @@
}
}
+ private static void checkSimpleType(Object o)
+ {
+ if (!((o instanceof Void) || (o instanceof Boolean) ||
+ (o instanceof Byte) ||
+ (o instanceof Short) ||
+ (o instanceof Integer) ||
+ (o instanceof Long) ||
+ (o instanceof Float) ||
+ (o instanceof Double) ||
+ (o instanceof String) || (o instanceof SimpleString)))
+ {
+ throw new IllegalStateException("Can not store object as a message property: " + o);
+ }
+ }
+
public static Object from(final byte[] bytes)
{
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
@@ -291,19 +294,5 @@
// Private -------------------------------------------------------
- private static void storePropertyAsBytes(final Message message, final SimpleString key, final Object property)
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(property);
- }
- catch (IOException e)
- {
- throw new IllegalStateException(property + " can not be written to a byte array");
- }
- message.putBytesProperty(key, baos.toByteArray());
- }
// Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -135,7 +135,7 @@
Object getResource(ObjectName objectName);
- void handleMessage(ServerMessage message);
+ ServerMessage handleMessage(ServerMessage message);
// Notfication
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -57,12 +57,12 @@
import org.jboss.messaging.core.management.MessagingServerControlMBean;
import org.jboss.messaging.core.management.Notification;
import org.jboss.messaging.core.management.NotificationListener;
-import org.jboss.messaging.core.management.NotificationType;
import org.jboss.messaging.core.management.ObjectNames;
import org.jboss.messaging.core.management.ReplicationOperationInvoker;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareAddressControlWrapper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareMessagingServerControlWrapper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareQueueControlWrapper;
+import org.jboss.messaging.core.message.impl.MessageImpl;
import org.jboss.messaging.core.messagecounter.MessageCounter;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.messagecounter.impl.MessageCounterManagerImpl;
@@ -298,8 +298,14 @@
unregisterResource(objectName);
}
- public void handleMessage(final ServerMessage message)
+ public ServerMessage handleMessage(final ServerMessage message)
{
+ // a reply message is sent with the result stored in the message body.
+ // we set its type to MessageImpl.OBJECT_TYPE so that I can be received
+ // as an ObjectMessage when using JMS to send management message
+ ServerMessageImpl reply = new ServerMessageImpl(message);
+ reply.setType(MessageImpl.OBJECT_TYPE);
+
SimpleString objectName = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OBJECTNAME);
if (log.isDebugEnabled())
{
@@ -322,13 +328,14 @@
try
{
Object result = invokeOperation(objectName.toString(), operation.toString(), operationParameters);
- message.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, true);
- ManagementHelper.storeTypedProperty(message, operation, result);
+ reply.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, true);
+ ManagementHelper.storeResult(reply, result);
}
catch (Exception e)
{
+ e.printStackTrace(System.err);
log.warn("exception while invoking " + operation + " on " + objectName, e);
- message.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, false);
+ reply.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, false);
String exceptionMessage = e.getMessage();
if (e instanceof InvocationTargetException)
{
@@ -336,7 +343,7 @@
}
if (e != null)
{
- message.putStringProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION,
+ reply.putStringProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION,
new SimpleString(exceptionMessage));
}
}
@@ -346,14 +353,16 @@
{
for (SimpleString propertyName : propNames)
{
- if (propertyName.startsWith(ManagementHelper.HDR_JMX_ATTRIBUTE_PREFIX))
+ if (propertyName.equals(ManagementHelper.HDR_JMX_ATTRIBUTE))
{
SimpleString attribute = (SimpleString)message.getProperty(propertyName);
Object result = getAttribute(objectName.toString(), attribute.toString());
- ManagementHelper.storeTypedProperty(message, attribute, result);
+ ManagementHelper.storeResult(reply, result);
}
}
}
+
+ return reply;
}
public void registerResource(final ObjectName objectName, final Object resource) throws Exception
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -22,8 +22,6 @@
package org.jboss.messaging.core.management.impl;
-import java.text.DateFormat;
-import java.util.GregorianCalendar;
import java.util.List;
import javax.management.openmbean.CompositeData;
@@ -32,12 +30,10 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.filter.impl.FilterImpl;
-import org.jboss.messaging.core.management.DayCounterInfo;
import org.jboss.messaging.core.management.MessageCounterInfo;
import org.jboss.messaging.core.management.MessageInfo;
import org.jboss.messaging.core.management.QueueControlMBean;
import org.jboss.messaging.core.messagecounter.MessageCounter;
-import org.jboss.messaging.core.messagecounter.MessageCounter.DayCounter;
import org.jboss.messaging.core.messagecounter.impl.MessageCounterHelper;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
@@ -386,27 +382,7 @@
public TabularData listMessageCounterHistory() throws Exception
{
- try
- {
- List<DayCounter> history = counter.getHistory();
- DayCounterInfo[] infos = new DayCounterInfo[history.size()];
- for (int i = 0; i < infos.length; i++)
- {
- DayCounter dayCounter = history.get(i);
- int[] counters = dayCounter.getCounters();
- GregorianCalendar date = dayCounter.getDate();
-
- DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
- String strData = dateFormat.format(date.getTime());
- infos[i] = new DayCounterInfo(strData, counters);
- }
- return DayCounterInfo.toTabularData(infos);
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- return null;
- }
+ return MessageCounterHelper.listMessageCounterHistory(counter);
}
public String listMessageCounterHistoryAsHTML()
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ReplicationOperationInvokerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ReplicationOperationInvokerImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ReplicationOperationInvokerImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -103,7 +103,7 @@
}
if (ManagementHelper.hasOperationSucceeded(reply))
{
- return reply.getProperty(new SimpleString(operationName));
+ return ManagementHelper.getResult(reply);
}
else
{
Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -73,6 +73,8 @@
public static final SimpleString HDR_FROM_CLUSTER = new SimpleString("_JBM_FROM_CLUSTER");
public static final SimpleString HDR_SOLE_MESSAGE = new SimpleString("_JBM_SOLO_MESSAGE");
+
+ public static final byte OBJECT_TYPE = 2;
// Attributes ----------------------------------------------------
@@ -80,7 +82,7 @@
private SimpleString destination;
- private byte type;
+ protected byte type;
protected boolean durable;
@@ -144,6 +146,23 @@
this.body = other.body;
}
+ /*
+ * Copy constructor
+ */
+ protected MessageImpl(final Message other)
+ {
+ this();
+ this.messageID = other.getMessageID();
+ this.destination = other.getDestination();
+ this.type = other.getType();
+ this.durable = other.isDurable();
+ this.expiration = other.getExpiration();
+ this.timestamp = other.getTimestamp();
+ this.priority = other.getPriority();
+ this.properties = new TypedProperties(other.getProperties());
+ this.body = other.getBody();
+ }
+
protected MessageImpl(final long messageID)
{
Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -24,9 +24,15 @@
import java.text.DateFormat;
import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
import java.util.StringTokenizer;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.management.DayCounterInfo;
import org.jboss.messaging.core.messagecounter.MessageCounter;
+import org.jboss.messaging.core.messagecounter.MessageCounter.DayCounter;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -44,6 +50,23 @@
// Static --------------------------------------------------------
+ public static TabularData listMessageCounterHistory(final MessageCounter counter) throws Exception
+ {
+ List<DayCounter> history = counter.getHistory();
+ DayCounterInfo[] infos = new DayCounterInfo[history.size()];
+ for (int i = 0; i < infos.length; i++)
+ {
+ DayCounter dayCounter = history.get(i);
+ int[] counters = dayCounter.getCounters();
+ GregorianCalendar date = dayCounter.getDate();
+
+ DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
+ String strData = dateFormat.format(date.getTime());
+ infos[i] = new DayCounterInfo(strData, counters);
+ }
+ return DayCounterInfo.toTabularData(infos);
+ }
+
public static String listMessageCounterAsHTML(MessageCounter[] counters)
{
if (counters == null)
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -74,6 +74,11 @@
super(other);
}
+ public ServerMessageImpl(final ServerMessage other)
+ {
+ super(other);
+ }
+
/**
* Only used in testing
*/
@@ -91,7 +96,12 @@
{
messageID = id;
}
-
+
+ public void setType(byte type)
+ {
+ this.type = type;
+ }
+
public MessageReference createReference(final Queue queue)
{
MessageReference ref = new MessageReferenceImpl(this, queue);
@@ -178,4 +188,5 @@
getDestination() +
"]";
}
+
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -11,6 +11,20 @@
package org.jboss.messaging.core.server.impl;
+import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
import org.jboss.messaging.core.buffers.ChannelBuffers;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
@@ -20,7 +34,7 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.management.Notification;
-import static org.jboss.messaging.core.management.NotificationType.CONSUMER_CREATED;
+import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.BindingType;
@@ -32,6 +46,7 @@
import org.jboss.messaging.core.remoting.FailureListener;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
@@ -43,7 +58,6 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerCloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionExpiredMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
@@ -83,17 +97,6 @@
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.TypedProperties;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executor;
-
/*
* Session implementation
*
@@ -2408,15 +2411,15 @@
{
doSecurity(message);
- managementService.handleMessage(message);
+ ServerMessage reply = managementService.handleMessage(message);
SimpleString replyTo = (SimpleString)message.getProperty(ClientMessageImpl.REPLYTO_HEADER_NAME);
if (replyTo != null)
{
- message.setDestination(replyTo);
+ reply.setDestination(replyTo);
- send(message);
+ send(reply);
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/JBossQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/JBossQueue.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/JBossQueue.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -58,7 +58,7 @@
super(JMS_QUEUE_ADDRESS_PREFIX + name, name);
}
- protected JBossQueue(final String address, final String name)
+ public JBossQueue(final String address, final String name)
{
super(address, name);
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -361,6 +361,42 @@
this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
}
+
+ public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean preAcknowledge)
+ {
+ this.discoveryGroupAddress = null;
+ this.discoveryGroupPort = -1;
+ this.discoveryRefreshTimeout = -1;
+ this.discoveryInitialWaitTimeout = -1;
+ this.connectorConfigs = connectorConfigs;
+ this.connectionLoadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+ this.clientID = null;
+ this.dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+ this.transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+ this.pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
+ this.connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+ this.callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
+ this.consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+ this.consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+ this.producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+ this.sendWindowSize = ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
+ this.blockOnAcknowledge = blockOnAcknowledge;
+ this.minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+ this.blockOnNonPersistentSend = blockOnNonPersistentSend;
+ this.blockOnPersistentSend = blockOnPersistentSend;
+ this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+ this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+ this.preAcknowledge = preAcknowledge;
+ this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
+ this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+ this.maxRetriesBeforeFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER;
+ this.maxRetriesAfterFailover = ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER;
+ }
+
public JBossConnectionFactory(final TransportConfiguration connectorConfig)
{
this.discoveryGroupAddress = null;
@@ -499,6 +535,16 @@
{
return dupsOKBatchSize;
}
+
+ public int getTransactionBatchSize()
+ {
+ return transactionBatchSize;
+ }
+
+ public long getConnectionTTL()
+ {
+ return connectionTTL;
+ }
public int getConsumerWindowSize()
{
@@ -520,6 +566,26 @@
return producerMaxRate;
}
+ public int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
+ }
+
+ public int getMaxConnections()
+ {
+ return maxConnections;
+ }
+
+ public int getMaxRetriesBeforeFailover()
+ {
+ return maxRetriesBeforeFailover;
+ }
+
+ public int getMaxRetriesAfterFailover()
+ {
+ return maxRetriesAfterFailover;
+ }
+
public boolean isBlockOnAcknowledge()
{
return blockOnAcknowledge;
@@ -535,11 +601,26 @@
return blockOnPersistentSend;
}
+ public boolean isPreAcknowledge()
+ {
+ return preAcknowledge;
+ }
+
public boolean isAutoGroup()
{
return autoGroup;
}
+ public long getRetryInterval()
+ {
+ return retryInterval;
+ }
+
+ public double getRetryIntervalMultiplier()
+ {
+ return retryIntervalMultiplier;
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossObjectMessage.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -33,6 +33,7 @@
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.message.impl.MessageImpl;
/**
* This class implements javax.jms.ObjectMessage
@@ -53,7 +54,7 @@
{
// Constants -----------------------------------------------------
- public static final byte TYPE = 2;
+ public static final byte TYPE = MessageImpl.OBJECT_TYPE;
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -109,6 +109,18 @@
boolean createConnectionFactory(String name,
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception;
+
+ boolean createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ boolean blockOnAcknowledge,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend,
+ boolean preAcknowledge,
+ List<String> bindings) throws Exception;
+
+ boolean createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
String connectionLoadBalancingPolicyClassName,
long pingPeriod,
long connectionTTL,
@@ -181,4 +193,5 @@
String[] listSessions(String connectionID);
+
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -274,6 +274,40 @@
}
public synchronized boolean createConnectionFactory(final String name,
+ final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ final List<String> jndiBindings) throws Exception
+ {
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(connectorConfigs);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
+
+ return true;
+ }
+
+ public synchronized boolean createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ boolean blockOnAcknowledge,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend,
+ boolean preAcknowledge,
+ List<String> jndiBindings) throws Exception
+ {
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(connectorConfigs, blockOnAcknowledge, blockOnNonPersistentSend, blockOnPersistentSend, preAcknowledge);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
+
+ return true;
+ }
+
+ public synchronized boolean createConnectionFactory(final String name,
final DiscoveryGroupConfiguration discoveryGroupConfig,
final long discoveryInitialWait,
final String connectionLoadBalancingPolicyClassName,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -45,18 +45,38 @@
int getDupsOKBatchSize();
- int getDefaultConsumerMaxRate();
+ int getConsumerMaxRate();
- int getDefaultConsumerWindowSize();
+ int getConsumerWindowSize();
- int getDefaultProducerMaxRate();
+ int getProducerMaxRate();
- int getDefaultProducerWindowSize();
+ int getProducerWindowSize();
- boolean isDefaultBlockOnAcknowledge();
+ boolean isBlockOnAcknowledge();
- boolean isDefaultBlockOnPersistentSend();
+ boolean isBlockOnPersistentSend();
- boolean isDefaultBlockOnNonPersistentSend();
+ boolean isBlockOnNonPersistentSend();
+ boolean isPreAcknowledge();
+
+ long getConnectionTTL();
+
+ long getTransactionBatchSize();
+
+ long getMinLargeMessageSize();
+
+ boolean isAutoGroup();
+
+ int getMaxConnections();
+
+ long getRetryInterval();
+
+ double getRetryIntervalMultiplier();
+
+ int getMaxRetriesBeforeFailover();
+
+ int getMaxRetriesAfterFailover();
+
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -128,13 +128,13 @@
@Parameter(name = "otherQueueName", desc = "The name of the queue to move the messages to") String otherQueueName)
throws Exception;
- CompositeData listMessageCounter();
+ CompositeData listMessageCounter() throws Exception;
- String listMessageCounterAsHTML();
+ String listMessageCounterAsHTML() throws Exception;
TabularData listMessageCounterHistory() throws Exception;
- String listMessageCounterHistoryAsHTML();
+ String listMessageCounterHistoryAsHTML() throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -67,6 +67,44 @@
@Operation(desc = "Destroy a JMS Topic", impact = ACTION)
boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy") String name) throws Exception;
+ void createConnectionFactory(String name,
+ String connectorFactoryClassName,
+ String jndiBinding) throws Exception;
+
+ void createConnectionFactory(String name,
+ String connectorFactoryClassName,
+ boolean blockOnAcknowledge,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend,
+ boolean preAcknowledge,
+ String jndiBinding) throws Exception;
+
+ void createSimpleConnectionFactory(String name,
+ String connectorFactoryClassName,
+ String connectionLoadBalancingPolicyClassName,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ String clientID,
+ int dupsOKBatchSize,
+ int transactionBatchSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ int minLargeMessageSize,
+ boolean blockOnAcknowledge,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend,
+ boolean autoGroup,
+ int maxConnections,
+ boolean preAcknowledge,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int maxRetriesBeforeFailover,
+ int maxRetriesAfterFailover,
+ String jndiBinding) throws Exception;
+
@Operation(desc = "Create a JMS ConnectionFactory with a static list of servers", impact = ACTION)
void createConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
String name,
@@ -119,6 +157,7 @@
String jndiBinding)
throws Exception;
+
@Operation(desc = "Create a JMS ConnectionFactory specifying a discovery group to obtain list of servers from", impact = ACTION)
void createConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
String name,
@@ -184,44 +223,17 @@
void destroyConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create") String name) throws Exception;
@Operation(desc = "List the client addresses", impact = INFO)
- String[] listRemoteAddresses();
+ String[] listRemoteAddresses() throws Exception;
@Operation(desc = "List the client addresses which match the given IP Address", impact = INFO)
- String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress);
+ String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
@Operation(desc = "Closes all the connections for the given IP Address", impact = INFO)
boolean closeConnectionsForAddress(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
@Operation(desc = "List all the connection IDs", impact = INFO)
- String[] listConnectionIDs();
+ String[] listConnectionIDs() throws Exception;
@Operation(desc = "List the sessions for the given connectionID", impact = INFO)
- String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID);
-
- void createSimpleConnectionFactory(String name,
- String connectorFactoryClassName,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int producerWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
- long retryInterval,
- double retryIntervalMultiplier,
- int maxRetriesBeforeFailover,
- int maxRetriesAfterFailover,
- String jndiBinding) throws Exception;
-
+ String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -51,16 +51,14 @@
// Operations ----------------------------------------------------
- // Open Type API
-
@Operation(desc = "List all subscriptions")
- TabularData listAllSubscriptions();
+ TabularData listAllSubscriptions() throws Exception;
@Operation(desc = "List only the durable subscriptions")
- TabularData listDurableSubscriptions();
+ TabularData listDurableSubscriptions() throws Exception;
@Operation(desc = "List only the non durable subscriptions")
- TabularData listNonDurableSubscriptions();
+ TabularData listNonDurableSubscriptions() throws Exception;
@Operation(desc = "List all the message for the given subscription")
public TabularData listMessagesForSubscription(
@@ -74,17 +72,6 @@
@Parameter(name = "filter", desc = "a JMS filter") String filter)
throws Exception;
- // Specific API
-
- @Operation(desc = "List all subscriptions")
- SubscriptionInfo[] listAllSubscriptionInfos();
-
- @Operation(desc = "List only the durable subscriptions")
- SubscriptionInfo[] listDurableSubscriptionInfos();
-
- @Operation(desc = "List only the non durable subscriptions")
- SubscriptionInfo[] listNonDurableSubscriptionInfos();
-
@Operation(desc = "Drop a durable subscription", impact = ACTION)
void dropDurableSubscription(
@Parameter(name = "clientID", desc = "the client ID") String clientID,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -85,22 +85,22 @@
return cf.getCallTimeout();
}
- public int getDefaultConsumerMaxRate()
+ public int getConsumerMaxRate()
{
return cf.getConsumerMaxRate();
}
- public int getDefaultConsumerWindowSize()
+ public int getConsumerWindowSize()
{
return cf.getConsumerWindowSize();
}
- public int getDefaultProducerMaxRate()
+ public int getProducerMaxRate()
{
return cf.getProducerMaxRate();
}
- public int getDefaultProducerWindowSize()
+ public int getProducerWindowSize()
{
return cf.getProducerWindowSize();
}
@@ -110,26 +110,78 @@
return cf.getDupsOKBatchSize();
}
- public boolean isDefaultBlockOnAcknowledge()
+ public boolean isBlockOnAcknowledge()
{
return cf.isBlockOnAcknowledge();
}
- public boolean isDefaultBlockOnNonPersistentSend()
+ public boolean isBlockOnNonPersistentSend()
{
return cf.isBlockOnNonPersistentSend();
}
- public boolean isDefaultBlockOnPersistentSend()
+ public boolean isBlockOnPersistentSend()
{
return cf.isBlockOnPersistentSend();
}
+
+ public boolean isPreAcknowledge()
+ {
+ return cf.isPreAcknowledge();
+ }
public String getName()
{
return name;
}
+ public long getConnectionTTL()
+ {
+ return cf.getConnectionTTL();
+ }
+
+ public int getMaxConnections()
+ {
+ return cf.getMaxConnections();
+ }
+
+ public int getMaxRetriesAfterFailover()
+ {
+ return cf.getMaxRetriesAfterFailover();
+ }
+
+ public int getMaxRetriesBeforeFailover()
+ {
+ return cf.getMaxRetriesBeforeFailover();
+ }
+
+ public long getMinLargeMessageSize()
+ {
+ return cf.getMinLargeMessageSize();
+ }
+
+ public long getRetryInterval()
+ {
+ return cf.getRetryInterval();
+ }
+
+ public double getRetryIntervalMultiplier()
+ {
+ return cf.getRetryIntervalMultiplier();
+ }
+
+ public long getTransactionBatchSize()
+ {
+ return cf.getTransactionBatchSize();
+ }
+
+ public boolean isAutoGroup()
+ {
+ return cf.isAutoGroup();
+ }
+
+
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Added: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,237 @@
+/*
+ * 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.jms.server.management.impl;
+
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_ATTRIBUTE;
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_OBJECTNAME;
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_OPERATION_EXCEPTION;
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_OPERATION_NAME;
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_OPERATION_PREFIX;
+import static org.jboss.messaging.core.client.management.impl.ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+/*
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class JMSManagementHelper
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ public static void putAttribute(final Message message, final ObjectName objectName, final String attribute) throws JMSException
+ {
+ message.setStringProperty(HDR_JMX_OBJECTNAME.toString(), objectName.toString());
+ message.setStringProperty(HDR_JMX_ATTRIBUTE.toString(), attribute);
+ }
+
+ public static void putOperationInvocation(final Message message,
+ final ObjectName objectName,
+ final String operationName,
+ final Object... parameters) throws JMSException
+ {
+ // store the name of the operation...
+ message.setStringProperty(HDR_JMX_OBJECTNAME.toString(), objectName.toString());
+ message.setStringProperty(HDR_JMX_OPERATION_NAME.toString(), operationName);
+ // ... and all the parameters (preserving their types)
+ for (int i = 0; i < parameters.length; i++)
+ {
+ Object parameter = parameters[i];
+ // use a zero-filled 2-padded index:
+ // if there is more than 10 parameters, order is preserved (e.g. 02 will be before 10)
+ String key = String.format("%s%02d", HDR_JMX_OPERATION_PREFIX, i);
+ storeTypedProperty(message, key, parameter);
+ }
+ }
+
+ public static boolean isOperationResult(final Message message) throws JMSException
+ {
+ return message.propertyExists(HDR_JMX_OPERATION_SUCCEEDED.toString());
+ }
+
+ public static boolean isAttributesResult(final Message message) throws JMSException
+ {
+ return !(isOperationResult(message));
+ }
+
+ public static TabularData getTabularDataProperty(final Message message, final String key) throws JMSException
+ {
+ Object object = message.getObjectProperty(key);
+ if (object instanceof byte[])
+ {
+ return (TabularData)from((byte[])object);
+ }
+ throw new IllegalArgumentException(key + " property is not a valid TabularData");
+ }
+
+ public static Object[] getArrayProperty(final Message message, final String key) throws JMSException
+ {
+ Object object = message.getObjectProperty(key);
+ if (object instanceof byte[])
+ {
+ return (Object[])from((byte[])object);
+ }
+ throw new IllegalArgumentException(key + " property is not a valid array");
+ }
+
+ public static CompositeData getCompositeDataProperty(final Message message, final String key) throws JMSException
+ {
+ Object object = message.getObjectProperty(key);
+ if (object instanceof byte[])
+ {
+ return (CompositeData)from((byte[])object);
+ }
+ throw new IllegalArgumentException(key + " property is not a valid CompositeData");
+ }
+
+ public static boolean hasOperationSucceeded(final Message message) throws JMSException
+ {
+ if (!isOperationResult(message))
+ {
+ return false;
+ }
+ if (message.propertyExists(HDR_JMX_OPERATION_SUCCEEDED.toString()))
+ {
+ return message.getBooleanProperty(HDR_JMX_OPERATION_SUCCEEDED.toString());
+ }
+ return false;
+ }
+
+ public static String getOperationExceptionMessage(final Message message) throws JMSException
+ {
+ if (message.propertyExists(HDR_JMX_OPERATION_EXCEPTION.toString()))
+ {
+ return message.getStringProperty(HDR_JMX_OPERATION_EXCEPTION.toString());
+ }
+ return null;
+ }
+
+ public static void storeTypedProperty(final Message message, final String key, final Object typedProperty) throws JMSException
+ {
+ if (typedProperty instanceof Void)
+ {
+ // do not put the returned value if the operation was a procedure
+ }
+ else if (typedProperty instanceof Boolean)
+ {
+ message.setBooleanProperty(key, (Boolean)typedProperty);
+ }
+ else if (typedProperty instanceof Byte)
+ {
+ message.setByteProperty(key, (Byte)typedProperty);
+ }
+ else if (typedProperty instanceof Short)
+ {
+ message.setShortProperty(key, (Short)typedProperty);
+ }
+ else if (typedProperty instanceof Integer)
+ {
+ message.setIntProperty(key, (Integer)typedProperty);
+ }
+ else if (typedProperty instanceof Long)
+ {
+ message.setLongProperty(key, (Long)typedProperty);
+ }
+ else if (typedProperty instanceof Float)
+ {
+ message.setFloatProperty(key, (Float)typedProperty);
+ }
+ else if (typedProperty instanceof Double)
+ {
+ message.setDoubleProperty(key, (Double)typedProperty);
+ }
+ else if (typedProperty instanceof String)
+ {
+ message.setStringProperty(key, (String)typedProperty);
+ }
+ else if (typedProperty instanceof TabularData || typedProperty instanceof CompositeData)
+ {
+ storePropertyAsBytes(message, key, typedProperty);
+ }
+ else if (typedProperty != null && typedProperty.getClass().isArray())
+ {
+ storePropertyAsBytes(message, key, typedProperty);
+ }
+ // serialize as a SimpleString
+ else
+ {
+ message.setStringProperty(key, typedProperty.toString());
+ }
+ }
+
+ public static Object from(final byte[] bytes)
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois;
+ try
+ {
+ ois = new ObjectInputStream(bais);
+ return ois.readObject();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private static void storePropertyAsBytes(final Message message, final String key, final Object property)
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(property);
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException(property + " can not be written to a byte array");
+ }
+ //message.setBytesProperty(key, baos.toByteArray());
+ }
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -22,9 +22,7 @@
package org.jboss.messaging.jms.server.management.impl;
-import java.text.DateFormat;
import java.util.ArrayList;
-import java.util.GregorianCalendar;
import java.util.List;
import javax.management.openmbean.CompositeData;
@@ -34,10 +32,8 @@
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.filter.impl.FilterImpl;
import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.management.DayCounterInfo;
import org.jboss.messaging.core.management.MessageCounterInfo;
import org.jboss.messaging.core.messagecounter.MessageCounter;
-import org.jboss.messaging.core.messagecounter.MessageCounter.DayCounter;
import org.jboss.messaging.core.messagecounter.impl.MessageCounterHelper;
import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
@@ -325,7 +321,8 @@
public boolean moveMessage(String messageID, String otherQueueName) throws Exception
{
- Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
+ JBossQueue otherQueue = new JBossQueue(otherQueueName);
+ Binding binding = postOffice.getBinding(otherQueue.getSimpleAddress());
if (binding == null)
{
throw new IllegalArgumentException("No queue found for " + otherQueueName);
@@ -342,7 +339,8 @@
public int moveMatchingMessages(String filterStr, String otherQueueName) throws Exception
{
- Binding otherBinding = postOffice.getBinding(new SimpleString(otherQueueName));
+ JBossQueue otherQueue = new JBossQueue(otherQueueName);
+ Binding otherBinding = postOffice.getBinding(otherQueue.getSimpleAddress());
if (otherBinding == null)
{
throw new IllegalArgumentException("No queue found for " + otherQueueName);
@@ -369,19 +367,7 @@
public TabularData listMessageCounterHistory() throws Exception
{
- List<DayCounter> history = counter.getHistory();
- DayCounterInfo[] infos = new DayCounterInfo[history.size()];
- for (int i = 0; i < infos.length; i++)
- {
- DayCounter dayCounter = history.get(i);
- int[] counters = dayCounter.getCounters();
- GregorianCalendar date = dayCounter.getDate();
-
- DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
- String strData = dateFormat.format(date.getTime());
- infos[i] = new DayCounterInfo(strData, counters);
- }
- return DayCounterInfo.toTabularData(infos);
+ return MessageCounterHelper.listMessageCounterHistory(counter);
}
public String listMessageCounterHistoryAsHTML()
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -142,6 +142,52 @@
}
public void createConnectionFactory(String name,
+ String connectorFactoryClassName,
+ String jndiBinding) throws Exception
+ {
+ List<String> bindings = new ArrayList<String>();
+ bindings.add(jndiBinding);
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
+
+ boolean created = server.createConnectionFactory(name,
+ connectorConfigs,
+ bindings);
+ if (created)
+ {
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+ }
+
+ public void createConnectionFactory(String name,
+ String connectorFactoryClassName,
+ boolean blockOnAcknowledge,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend,
+ boolean preAcknowledge,
+ String jndiBinding) throws Exception
+ {
+ List<String> bindings = new ArrayList<String>();
+ bindings.add(jndiBinding);
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
+
+ boolean created = server.createConnectionFactory(name,
+ connectorConfigs,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ preAcknowledge,
+ bindings);
+ if (created)
+ {
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+ }
+
+ public void createConnectionFactory(String name,
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
String connectionLoadBalancingPolicyClassName,
long pingPeriod,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -132,34 +132,19 @@
public TabularData listAllSubscriptions()
{
- return SubscriptionInfo.toTabularData(listAllSubscriptionInfos());
+ return SubscriptionInfo.toTabularData(listSubscribersInfos(DurabilityType.ALL));
}
public TabularData listDurableSubscriptions()
{
- return SubscriptionInfo.toTabularData(listDurableSubscriptionInfos());
+ return SubscriptionInfo.toTabularData(listSubscribersInfos(DurabilityType.DURABLE));
}
public TabularData listNonDurableSubscriptions()
{
- return SubscriptionInfo.toTabularData(listNonDurableSubscriptionInfos());
+ return SubscriptionInfo.toTabularData(listSubscribersInfos(DurabilityType.NON_DURABLE));
}
- public SubscriptionInfo[] listAllSubscriptionInfos()
- {
- return listSubscribersInfos(DurabilityType.ALL);
- }
-
- public SubscriptionInfo[] listDurableSubscriptionInfos()
- {
- return listSubscribersInfos(DurabilityType.DURABLE);
- }
-
- public SubscriptionInfo[] listNonDurableSubscriptionInfos()
- {
- return listSubscribersInfos(DurabilityType.NON_DURABLE);
- }
-
public TabularData listMessagesForSubscription(final String queueName) throws Exception
{
SimpleString sAddress = new SimpleString(queueName);
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -82,24 +82,24 @@
return localControl.getClientID();
}
- public int getDefaultConsumerMaxRate()
+ public int getConsumerMaxRate()
{
- return localControl.getDefaultConsumerMaxRate();
+ return localControl.getConsumerMaxRate();
}
- public int getDefaultConsumerWindowSize()
+ public int getConsumerWindowSize()
{
- return localControl.getDefaultConsumerWindowSize();
+ return localControl.getConsumerWindowSize();
}
- public int getDefaultProducerMaxRate()
+ public int getProducerMaxRate()
{
- return localControl.getDefaultProducerMaxRate();
+ return localControl.getProducerMaxRate();
}
- public int getDefaultProducerWindowSize()
+ public int getProducerWindowSize()
{
- return localControl.getDefaultProducerWindowSize();
+ return localControl.getProducerWindowSize();
}
public int getDupsOKBatchSize()
@@ -112,21 +112,72 @@
return localControl.getPingPeriod();
}
- public boolean isDefaultBlockOnAcknowledge()
+ public boolean isBlockOnAcknowledge()
{
- return localControl.isDefaultBlockOnAcknowledge();
+ return localControl.isBlockOnAcknowledge();
}
- public boolean isDefaultBlockOnNonPersistentSend()
+ public boolean isBlockOnNonPersistentSend()
{
- return localControl.isDefaultBlockOnNonPersistentSend();
+ return localControl.isBlockOnNonPersistentSend();
}
- public boolean isDefaultBlockOnPersistentSend()
+ public boolean isBlockOnPersistentSend()
{
- return localControl.isDefaultBlockOnPersistentSend();
+ return localControl.isBlockOnPersistentSend();
}
+
+ public boolean isPreAcknowledge()
+ {
+ return localControl.isPreAcknowledge();
+ }
+ public long getConnectionTTL()
+ {
+ return localControl.getConnectionTTL();
+ }
+
+ public int getMaxConnections()
+ {
+ return localControl.getMaxConnections();
+ }
+
+ public int getMaxRetriesAfterFailover()
+ {
+ return localControl.getMaxRetriesAfterFailover();
+ }
+
+ public int getMaxRetriesBeforeFailover()
+ {
+ return localControl.getMaxRetriesBeforeFailover();
+ }
+
+ public long getMinLargeMessageSize()
+ {
+ return localControl.getMinLargeMessageSize();
+ }
+
+ public long getRetryInterval()
+ {
+ return localControl.getRetryInterval();
+ }
+
+ public double getRetryIntervalMultiplier()
+ {
+ return localControl.getRetryIntervalMultiplier();
+ }
+
+ public long getTransactionBatchSize()
+ {
+ return localControl.getTransactionBatchSize();
+ }
+
+ public boolean isAutoGroup()
+ {
+ return localControl.isAutoGroup();
+ }
+
+
// StandardMBean overrides ---------------------------------------
@Override
@@ -141,6 +192,7 @@
info.getNotifications());
}
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -69,32 +69,57 @@
return localControl.closeConnectionsForAddress(ipAddress);
}
- public void createSimpleConnectionFactory(String name,
- String connectorFactoryClassName,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int producerWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
- long retryInterval,
- double retryIntervalMultiplier,
- int maxRetriesBeforeFailover,
- int maxRetriesAfterFailover,
- String jndiBinding) throws Exception
+ public void createConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final String jndiBinding) throws Exception
{
+ replicationAwareInvoke("createConnectionFactory", name, connectorFactoryClassName, jndiBinding);
+ }
+
+ public void createConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean preAcknowledge,
+ final String jndiBinding) throws Exception
+ {
+ replicationAwareInvoke("createConnectionFactory",
+ name,
+ connectorFactoryClassName,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ preAcknowledge,
+ jndiBinding);
+ }
+
+ public void createSimpleConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final String connectionLoadBalancingPolicyClassName,
+ final long pingPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final int minLargeMessageSize,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean autoGroup,
+ final int maxConnections,
+ final boolean preAcknowledge,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final int maxRetriesBeforeFailover,
+ final int maxRetriesAfterFailover,
+ final String jndiBinding) throws Exception
+ {
replicationAwareInvoke("createSimpleConnectionFactory",
name,
connectorFactoryClassName,
@@ -122,7 +147,7 @@
maxRetriesAfterFailover,
jndiBinding);
}
-
+
public void createConnectionFactory(final String name,
final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
final String connectionLoadBalancingPolicyClassName,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareTopicControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareTopicControlWrapper.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareTopicControlWrapper.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -29,7 +29,6 @@
import org.jboss.messaging.core.management.ReplicationOperationInvoker;
import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareStandardMBeanWrapper;
-import org.jboss.messaging.jms.server.management.SubscriptionInfo;
import org.jboss.messaging.jms.server.management.TopicControlMBean;
import org.jboss.messaging.jms.server.management.impl.TopicControl;
@@ -98,21 +97,11 @@
return localControl.getSubcriptionsCount();
}
- public SubscriptionInfo[] listAllSubscriptionInfos()
- {
- return localControl.listAllSubscriptionInfos();
- }
-
public TabularData listAllSubscriptions()
{
return localControl.listAllSubscriptions();
}
- public SubscriptionInfo[] listDurableSubscriptionInfos()
- {
- return localControl.listDurableSubscriptionInfos();
- }
-
public TabularData listDurableSubscriptions()
{
return localControl.listDurableSubscriptions();
@@ -128,11 +117,6 @@
return localControl.countMessagesForSubscription(clientID, subscriptionName, filterStr);
}
- public SubscriptionInfo[] listNonDurableSubscriptionInfos()
- {
- return localControl.listNonDurableSubscriptionInfos();
- }
-
public TabularData listNonDurableSubscriptions()
{
return localControl.listNonDurableSubscriptions();
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -38,6 +38,8 @@
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
import javax.naming.InitialContext;
import org.jboss.kernel.plugins.config.property.PropertyKernelConfig;
@@ -55,7 +57,6 @@
import org.jboss.messaging.jms.JBossTopic;
import org.jboss.messaging.jms.server.JMSServerManager;
import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
-import org.jboss.messaging.jms.server.management.SubscriptionInfo;
import org.jboss.messaging.jms.server.management.TopicControlMBean;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
@@ -440,11 +441,12 @@
objectName,
TopicControlMBean.class,
false);
- SubscriptionInfo[] subInfos = topic.listAllSubscriptionInfos();
+ TabularData subInfos = topic.listAllSubscriptions();
List<String> subs = new ArrayList<String>();
- for (SubscriptionInfo info : subInfos)
+ for (Object o: subInfos.values())
{
- subs.add(info.getName());
+ CompositeData data = (CompositeData)o;
+ subs.add((String)data.get("name"));
}
return subs;
}
Modified: trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java
===================================================================
--- trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/joram-tests/src/org/jboss/test/jms/JBossMessagingAdmin.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -42,9 +42,7 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.InputStreamReader;
-import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Hashtable;
@@ -65,8 +63,8 @@
import org.jboss.messaging.core.management.ObjectNames;
import org.jboss.messaging.core.security.impl.SecurityStoreImpl;
import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.tests.integration.management.core.CoreMessagingProxy;
import org.jboss.messaging.tests.util.SpawnedVMSupport;
-import org.jboss.messaging.utils.SimpleString;
import org.objectweb.jtests.jms.admin.Admin;
/**
@@ -126,31 +124,13 @@
try
{
invokeSyncOperation(ObjectNames.getJMSServerObjectName(),
- "createSimpleConnectionFactory",
+ "createConnectionFactory",
name,
NettyConnectorFactory.class.getName(),
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_SEND_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
true,
true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ true,
+ false,
name);
}
catch (Exception e)
@@ -351,14 +331,14 @@
}
if (!ManagementHelper.hasOperationSucceeded(reply))
{
- throw new IllegalStateException("opertation failed when invoking " + operationName +
+ throw new IllegalStateException("operation failed when invoking " + operationName +
" on " +
objectName +
": " +
ManagementHelper.getOperationExceptionMessage(reply));
}
- return reply.getProperty(new SimpleString(operationName));
+ return ManagementHelper.getResult(reply);
}
// Inner classes -------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverManagementTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailoverManagementTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -113,7 +113,7 @@
{
ClientMessage managementMessage = session1.createClientMessage(false);
- ManagementHelper.putAttributes(managementMessage,
+ ManagementHelper.putAttribute(managementMessage,
ObjectNames.getQueueObjectName(ADDRESS, ADDRESS),
"MessageCount");
managementMessage.putStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME, replyTo);
@@ -132,7 +132,7 @@
{
ClientMessage managementMessage = session1.createClientMessage(false);
- ManagementHelper.putAttributes(managementMessage,
+ ManagementHelper.putAttribute(managementMessage,
ObjectNames.getQueueObjectName(ADDRESS, ADDRESS),
"MessageCount");
managementMessage.putStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME, replyTo);
@@ -202,7 +202,7 @@
{
ClientMessage managementMessage = session1.createClientMessage(false);
- ManagementHelper.putAttributes(managementMessage,
+ ManagementHelper.putAttribute(managementMessage,
ObjectNames.getQueueObjectName(ADDRESS, ADDRESS),
"MessageCount");
managementMessage.putStringProperty(ClientMessageImpl.REPLYTO_HEADER_NAME, replyTo);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -143,7 +143,7 @@
assertEquals(0, backupOtherQueueControl.getMessageCount());
// moved all messages to otherQueue
- int movedMessagesCount = liveQueueControl.moveAllMessages(otherQueue.getAddress());
+ int movedMessagesCount = liveQueueControl.moveAllMessages(otherQueue.getName());
assertEquals(1, movedMessagesCount);
assertEquals(0, liveQueueControl.getMessageCount());
@@ -168,7 +168,7 @@
assertEquals(0, backupOtherQueueControl.getMessageCount());
// moved matching messages to otherQueue
- int movedMatchedMessagesCount = liveQueueControl.moveMatchingMessages(key + " =" + matchingValue, otherQueue.getAddress());
+ int movedMatchedMessagesCount = liveQueueControl.moveMatchingMessages(key + " =" + matchingValue, otherQueue.getName());
assertEquals(1, movedMatchedMessagesCount);
assertEquals(1, liveQueueControl.getMessageCount());
@@ -190,7 +190,7 @@
assertEquals(0, liveOtherQueueControl.getMessageCount());
assertEquals(0, backupOtherQueueControl.getMessageCount());
- assertTrue(liveQueueControl.moveMessage(message.getJMSMessageID(), otherQueue.getAddress()));
+ assertTrue(liveQueueControl.moveMessage(message.getJMSMessageID(), otherQueue.getName()));
// check the message is no longer in the queue on both live & backup nodes
assertEquals(0, liveQueueControl.getMessageCount());
Added: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSMessagingProxy.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSMessagingProxy.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSMessagingProxy.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.integration.jms.management;
+
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueRequestor;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.management.ObjectName;
+
+import org.jboss.messaging.jms.server.management.impl.JMSManagementHelper;
+
+/**
+ * A MBeanUsingCoreMessage
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class JMSMessagingProxy
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final ObjectName on;
+
+ private Session session;
+
+ private QueueRequestor requestor;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public JMSMessagingProxy(QueueSession session, Queue managementQueue, ObjectName objectName) throws Exception
+ {
+ this.session = session;
+
+ this.on = objectName;
+
+ this.requestor = new QueueRequestor(session, managementQueue);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ public Object retriveAttributeValue(String attributeName)
+ {
+ try
+ {
+ Message m = session.createMessage();
+ JMSManagementHelper.putAttribute(m, on, attributeName);
+ ObjectMessage reply = (ObjectMessage)requestor.request(m);
+ return reply.getObject();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public Object invokOperation(String operationName, Object... args) throws Exception
+ {
+ Message m = session.createMessage();
+ JMSManagementHelper.putOperationInvocation(m, on, operationName, args);
+ ObjectMessage reply = (ObjectMessage)requestor.request(m);
+ if (JMSManagementHelper.hasOperationSucceeded(reply))
+ {
+ return reply.getObject();
+ }
+ else
+ {
+ throw new Exception(JMSManagementHelper.getOperationExceptionMessage(reply));
+ }
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -43,18 +43,20 @@
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE;
import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createJMSQueueControl;
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 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 javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
+import javax.naming.Context;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
@@ -63,11 +65,15 @@
import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.core.server.Messaging;
import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.settings.impl.AddressSettings;
import org.jboss.messaging.jms.JBossQueue;
import org.jboss.messaging.jms.client.JBossConnectionFactory;
import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.tests.integration.management.ManagementControlHelper;
+import org.jboss.messaging.tests.unit.util.InVMContext;
import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.utils.SimpleString;
/**
* A QueueControlTest
@@ -88,19 +94,30 @@
private JMSServerManagerImpl serverManager;
- private Queue queue;
+ protected JBossQueue queue;
private MBeanServer mbeanServer;
+ protected Context context;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
+ public void testGetAttributes() throws Exception
+ {
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertEquals(queue.getName(), queueControl.getName());
+ assertEquals(queue.getAddress(), queueControl.getAddress());
+ assertEquals(queue.isTemporary(), queueControl.isTemporary());
+ }
+
public void testGetXXXCount() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
assertEquals(0, queueControl.getMessageCount());
assertEquals(0, queueControl.getConsumerCount());
@@ -127,7 +144,7 @@
public void testRemoveMessage() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
assertEquals(0, queueControl.getMessageCount());
@@ -147,9 +164,27 @@
assertEquals(1, queueControl.getMessageCount());
}
+ public void testRemoveMessageWithUnknownMessage() throws Exception
+ {
+ String unknownMessageID = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertEquals(0, queueControl.getMessageCount());
+
+ try
+ {
+ queueControl.removeMessage(unknownMessageID);
+ fail("should throw an exception is the message ID is unknown");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
public void testRemoveAllMessages() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
assertEquals(0, queueControl.getMessageCount());
@@ -167,37 +202,11 @@
public void testRemoveMatchingMessages() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
assertEquals(0, queueControl.getMessageCount());
- JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_SEND_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
-
- Connection conn = cf.createConnection();
-
+ Connection conn = createConnection();
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = s.createProducer(queue);
@@ -224,7 +233,7 @@
public void testChangeMessagePriority() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
JMSUtil.sendMessages(queue, 1);
@@ -247,9 +256,82 @@
assertEquals(newPriority, message.getJMSPriority());
}
+ public void testChangeMessagePriorityWithInvalidPriority() throws Exception
+ {
+ byte invalidPriority = (byte)23;
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ String[] messageIDs = JMSUtil.sendMessages(queue, 1);
+
+ assertEquals(1, queueControl.getMessageCount());
+
+ try
+ {
+ queueControl.changeMessagePriority(messageIDs[0], invalidPriority);
+ fail("must throw an exception if the new priority is not a valid value");
+ }
+ catch (Exception e)
+ {
+ }
+
+ MessageConsumer consumer = JMSUtil.createConsumer(queue, true);
+ Message message = consumer.receive(500);
+ assertNotNull(message);
+ assertTrue(message.getJMSPriority() != invalidPriority);
+ }
+
+ public void testChangeMessagePriorityWithUnknownMessageID() throws Exception
+ {
+ String unkownMessageID = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ try
+ {
+ queueControl.changeMessagePriority(unkownMessageID, 7);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testGetExpiryAddress() throws Exception
+ {
+ final SimpleString expiryAddress = randomSimpleString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertNull(queueControl.getExpiryAddress());
+
+ service.getServer().getAddressSettingsRepository().addMatch(queue.getAddress(), new AddressSettings()
+ {
+ @Override
+ public SimpleString getExpiryAddress()
+ {
+ return expiryAddress;
+ }
+ });
+
+ assertEquals(expiryAddress.toString(), queueControl.getExpiryAddress());
+ }
+
+ public void testSetExpiryAddress() throws Exception
+ {
+ final String expiryAddress = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertNull(queueControl.getExpiryAddress());
+
+ queueControl.setExpiryAddress(expiryAddress);
+ assertEquals(expiryAddress, queueControl.getExpiryAddress());
+ }
+
public void testExpireMessage() throws Exception
{
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
String expiryQueueName = randomString();
JBossQueue expiryQueue = new JBossQueue(expiryQueueName);
serverManager.createQueue(expiryQueueName, expiryQueueName);
@@ -257,34 +339,72 @@
JMSQueueControlMBean expiryQueueControl = createJMSQueueControl(expiryQueue, mbeanServer);
- JMSUtil.sendMessages(queue, 1);
+ String[] messageIDs = JMSUtil.sendMessages(queue, 1);
assertEquals(1, queueControl.getMessageCount());
assertEquals(0, expiryQueueControl.getMessageCount());
- TabularData data = queueControl.listAllMessages();
- // retrieve the first message info
- CompositeData compositeData = (CompositeData)data.values().iterator().next();
- String messageID = (String)compositeData.get("JMSMessageID");
+ assertTrue(queueControl.expireMessage(messageIDs[0]));
- assertTrue(queueControl.expireMessage(messageID));
-
assertEquals(0, queueControl.getMessageCount());
assertEquals(1, expiryQueueControl.getMessageCount());
MessageConsumer consumer = JMSUtil.createConsumer(expiryQueue, true);
Message message = consumer.receive(500);
assertNotNull(message);
- assertEquals(messageID, message.getJMSMessageID());
+ assertEquals(messageIDs[0], message.getJMSMessageID());
}
+ public void testExpireMessageWithUnknownMessageID() throws Exception
+ {
+ String unknownMessageID = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ try
+ {
+ queueControl.expireMessage(unknownMessageID);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testExpireMessagesWithFilter() throws Exception
+ {
+ String key = new String("key");
+ long matchingValue = randomLong();
+ long unmatchingValue = matchingValue + 1;
+ String filter = key + " =" + matchingValue;
+
+ Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // send on queue
+ JMSUtil.sendMessageWithProperty(session, queue, key, matchingValue);
+ JMSUtil.sendMessageWithProperty(session, queue, key, unmatchingValue);
+
+ connection.close();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(2, queueControl.getMessageCount());
+
+ int expiredMessagesCount = queueControl.expireMessages(filter);
+ assertEquals(1, expiredMessagesCount);
+ assertEquals(1, queueControl.getMessageCount());
+
+ // consume the unmatched message from queue
+ JMSUtil.consumeMessages(1, queue);
+ }
+
public void testCountMessagesWithFilter() throws Exception
{
String key = "key";
long matchingValue = randomLong();
long unmatchingValue = matchingValue + 1;
- JMSQueueControlMBean queueControl = createJMSQueueControl(queue, mbeanServer);
+ JMSQueueControlMBean queueControl = createManagementControl();
Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -297,10 +417,245 @@
assertEquals(2, queueControl.countMessages(key + " =" + matchingValue));
assertEquals(1, queueControl.countMessages(key + " =" + unmatchingValue));
-
+
session.close();
}
+
+ public void testGetDeadLetterAddress() throws Exception
+ {
+ final SimpleString deadLetterAddress = randomSimpleString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertNull(queueControl.getDeadLetterAddress());
+
+ service.getServer().getAddressSettingsRepository().addMatch(queue.getAddress(), new AddressSettings()
+ {
+ @Override
+ public SimpleString getDeadLetterAddress()
+ {
+ return deadLetterAddress;
+ }
+ });
+
+ assertEquals(deadLetterAddress.toString(), queueControl.getDeadLetterAddress());
+ }
+
+ public void testSetDeadLetterAddress() throws Exception
+ {
+ final String deadLetterAddress = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ assertNull(queueControl.getDeadLetterAddress());
+
+ queueControl.setDeadLetterAddress(deadLetterAddress);
+ assertEquals(deadLetterAddress, queueControl.getDeadLetterAddress());
+ }
+
+ public void testSendMessageToDLQ() throws Exception
+ {
+ String deadLetterQueue = randomString();
+ serverManager.createQueue(deadLetterQueue, deadLetterQueue);
+ JBossQueue dlq = new JBossQueue(deadLetterQueue);
+
+ Connection conn = createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = sess.createProducer(queue);
+
+ // send 2 messages on queue
+ Message message = sess.createMessage();
+ producer.send(message);
+ producer.send(sess.createMessage());
+
+ conn.close();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ JMSQueueControlMBean dlqControl = ManagementControlHelper.createJMSQueueControl(dlq, mbeanServer);
+
+ assertEquals(2, queueControl.getMessageCount());
+ assertEquals(0, dlqControl.getMessageCount());
+
+ queueControl.setDeadLetterAddress(dlq.getAddress());
+
+ boolean movedToDeadLetterAddress = queueControl.sendMessageToDLQ(message.getJMSMessageID());
+ assertTrue(movedToDeadLetterAddress);
+ assertEquals(1, queueControl.getMessageCount());
+ assertEquals(1, dlqControl.getMessageCount());
+
+ // check there is a single message to consume from queue
+ JMSUtil.consumeMessages(1, queue);
+
+ // check there is a single message to consume from deadletter queue
+ JMSUtil.consumeMessages(1, dlq);
+
+ serverManager.destroyQueue(deadLetterQueue);
+ }
+
+ public void testSendMessageToDLQWithUnknownMessageID() throws Exception
+ {
+ String unknownMessageID = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ try
+ {
+ queueControl.sendMessageToDLQ(unknownMessageID);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+
+ }
+
+ public void testMoveAllMessages() throws Exception
+ {
+ String otherQueueName = randomString();
+
+ serverManager.createQueue(otherQueueName, otherQueueName);
+ JBossQueue otherQueue = new JBossQueue(otherQueueName);
+
+ // send on queue
+ JMSUtil.sendMessages(queue, 2);
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(2, queueControl.getMessageCount());
+
+ // moved all messages to otherQueue
+ int movedMessagesCount = queueControl.moveAllMessages(otherQueueName);
+ assertEquals(2, movedMessagesCount);
+ assertEquals(0, queueControl.getMessageCount());
+
+ // check there is no message to consume from queue
+ JMSUtil.consumeMessages(0, queue);
+
+ // consume the message from otherQueue
+ JMSUtil.consumeMessages(2, otherQueue);
+
+ serverManager.destroyQueue(otherQueueName);
+ }
+
+ public void testMoveAllMessagesToUknownQueue() throws Exception
+ {
+ String unknownQueue = randomString();
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+
+ try
+ {
+ queueControl.moveAllMessages(unknownQueue);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testMoveMatchingMessages() throws Exception
+ {
+ String key = "key";
+ long matchingValue = randomLong();
+ long unmatchingValue = matchingValue + 1;
+ String filter = "key = " + matchingValue;
+ String otherQueueName = randomString();
+
+ serverManager.createQueue(otherQueueName, otherQueueName);
+ JBossQueue otherQueue = new JBossQueue(otherQueueName);
+
+ Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ // send on queue
+ JMSUtil.sendMessageWithProperty(session, queue, key, matchingValue);
+ JMSUtil.sendMessageWithProperty(session, queue, key, unmatchingValue);
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(2, queueControl.getMessageCount());
+
+ // moved matching messages to otherQueue
+ int movedMessagesCount = queueControl.moveMatchingMessages(filter, otherQueueName);
+ assertEquals(1, movedMessagesCount);
+ assertEquals(1, queueControl.getMessageCount());
+
+ connection.start();
+ MessageConsumer consumer = session.createConsumer(queue);
+ Message message = consumer.receive(500);
+ assertNotNull(message);
+ assertEquals(unmatchingValue, message.getLongProperty(key));
+ assertNull(consumer.receive(500));
+
+ JMSUtil.consumeMessages(1, otherQueue);
+
+ serverManager.destroyQueue(otherQueueName);
+
+ connection.close();
+ }
+
+ public void testMoveMessage() throws Exception
+ {
+ String otherQueueName = randomString();
+
+ serverManager.createQueue(otherQueueName, otherQueueName);
+ JBossQueue otherQueue = new JBossQueue(otherQueueName);
+
+ String[] messageIDs = JMSUtil.sendMessages(queue, 1);
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(1, queueControl.getMessageCount());
+
+ boolean moved = queueControl.moveMessage(messageIDs[0], otherQueueName);
+ assertTrue(moved);
+ assertEquals(0, queueControl.getMessageCount());
+
+ JMSUtil.consumeMessages(0, queue);
+ JMSUtil.consumeMessages(1, otherQueue);
+
+ serverManager.destroyQueue(otherQueueName);
+ }
+ public void testMoveMessageWithUnknownMessageID() throws Exception
+ {
+ String unknownMessageID = randomString();
+ String otherQueueName = randomString();
+
+ serverManager.createQueue(otherQueueName, otherQueueName);
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(0, queueControl.getMessageCount());
+
+ try
+ {
+ queueControl.moveMessage(unknownMessageID, otherQueueName);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+
+ serverManager.destroyQueue(otherQueueName);
+ }
+
+ public void testMoveMessageToUnknownQueue() throws Exception
+ {
+ String unknwonQueue = randomString();
+
+ String[] messageIDs = JMSUtil.sendMessages(queue, 1);
+
+ JMSQueueControlMBean queueControl = createManagementControl();
+ assertEquals(1, queueControl.getMessageCount());
+
+ try
+ {
+ queueControl.moveMessage(messageIDs[0], unknwonQueue);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+
+ JMSUtil.consumeMessages(1, queue);
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -309,19 +664,19 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
mbeanServer = MBeanServerFactory.createMBeanServer();
Configuration conf = new ConfigurationImpl();
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
- conf.getAcceptorConfigurations()
- .add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
service = Messaging.newNullStorageMessagingService(conf, mbeanServer);
service.start();
serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
serverManager.start();
- serverManager.setContext(new NullInitialContext());
+ context = new InVMContext();
+ serverManager.setContext(context);
String queueName = randomString();
serverManager.createQueue(queueName, queueName);
@@ -336,8 +691,43 @@
super.tearDown();
}
+ protected JMSQueueControlMBean createManagementControl() throws Exception
+ {
+ return createJMSQueueControl(queue, mbeanServer);
+ }
+
// Private -------------------------------------------------------
+ private Connection createConnection() throws JMSException
+ {
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
+ null,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_PING_PERIOD,
+ DEFAULT_CONNECTION_TTL,
+ DEFAULT_CALL_TIMEOUT,
+ null,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_SEND_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+ DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+ true,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_RETRY_INTERVAL,
+ DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
+ DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
+
+ return cf.createConnection();
+ }
+
// Inner classes -------------------------------------------------
}
\ No newline at end of file
Added: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlUsingJMSTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSQueueControlUsingJMSTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,262 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.integration.jms.management;
+
+import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
+
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.management.ObjectNames;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+
+/**
+ * A JMSQueueControlUsingJMSTest
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private QueueConnection connection;
+
+ private QueueSession session;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // JMSServerControlTest overrides --------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+ connection = cf.createQueueConnection();
+ session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ connection.close();
+
+ super.tearDown();
+ }
+
+ @Override
+ protected JMSQueueControlMBean createManagementControl() throws Exception
+ {
+ JBossQueue managementQueue = new JBossQueue(DEFAULT_MANAGEMENT_ADDRESS.toString(),
+ DEFAULT_MANAGEMENT_ADDRESS.toString());
+ final JMSMessagingProxy proxy = new JMSMessagingProxy(session,
+ managementQueue,
+ ObjectNames.getJMSQueueObjectName(queue.getQueueName()));
+
+ return new JMSQueueControlMBean()
+ {
+
+ public boolean changeMessagePriority(String messageID, int newPriority) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("changeMessagePriority", messageID, newPriority);
+ }
+
+ public int countMessages(String filter) throws Exception
+ {
+ return (Integer)proxy.invokOperation("countMessages", filter);
+ }
+
+ public boolean expireMessage(String messageID) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("expireMessage", messageID);
+ }
+
+ public int expireMessages(String filter) throws Exception
+ {
+ return (Integer)proxy.invokOperation("expireMessages", filter);
+ }
+
+ public int getConsumerCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("ConsumerCount");
+ }
+
+ public String getDeadLetterAddress()
+ {
+ return (String)proxy.retriveAttributeValue("DeadLetterAddress");
+ }
+
+ public int getDeliveringCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("DeliveringCount");
+ }
+
+ public String getExpiryAddress()
+ {
+ return (String)proxy.retriveAttributeValue("ExpiryAddress");
+ }
+
+ public int getMessageCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("MessageCount");
+ }
+
+ public int getMessagesAdded()
+ {
+ return (Integer)proxy.retriveAttributeValue("MessagesAdded");
+ }
+
+ public String getName()
+ {
+ return (String)proxy.retriveAttributeValue("Name");
+ }
+
+ public long getScheduledCount()
+ {
+ return (Long)proxy.retriveAttributeValue("ScheduledCount");
+ }
+
+ public boolean isDurable()
+ {
+ return (Boolean)proxy.retriveAttributeValue("Durable");
+ }
+
+ public boolean isTemporary()
+ {
+ return (Boolean)proxy.retriveAttributeValue("Temporary");
+ }
+
+ public TabularData listAllMessages() throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listAllMessages");
+ }
+
+ public CompositeData listMessageCounter() throws Exception
+ {
+ return (CompositeData)proxy.invokOperation("listMessageCounter");
+ }
+
+ public String listMessageCounterAsHTML() throws Exception
+ {
+ return (String)proxy.invokOperation("listMessageCounterAsHTML");
+ }
+
+ public TabularData listMessageCounterHistory() throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listMessageCounterHistory");
+ }
+
+ public String listMessageCounterHistoryAsHTML() throws Exception
+ {
+ return (String)proxy.invokOperation("listMessageCounterHistoryAsHTML");
+ }
+
+ public TabularData listMessages(String filter) throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listMessages", filter);
+ }
+
+ public int moveAllMessages(String otherQueueName) throws Exception
+ {
+ return (Integer)proxy.invokOperation("moveAllMessages", otherQueueName);
+ }
+
+ public int moveMatchingMessages(String filter, String otherQueueName) throws Exception
+ {
+ return (Integer)proxy.invokOperation("moveMatchingMessages", filter, otherQueueName);
+ }
+
+ public boolean moveMessage(String messageID, String otherQueueName) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("moveMessage", messageID, otherQueueName);
+ }
+
+ public int removeMatchingMessages(String filter) throws Exception
+ {
+ return (Integer)proxy.invokOperation("removeMatchingMessages", filter);
+ }
+
+ public boolean removeMessage(String messageID) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("removeMessage", messageID);
+ }
+
+ public boolean sendMessageToDLQ(String messageID) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("sendMessageToDLQ", messageID);
+ }
+
+ public void setDeadLetterAddress(String deadLetterAddress) throws Exception
+ {
+ proxy.invokOperation("setDeadLetterAddress", deadLetterAddress);
+ }
+
+ public void setExpiryAddress(String expiryAddress) throws Exception
+ {
+ proxy.invokOperation("setExpiryAddress", expiryAddress);
+ }
+
+ public String getAddress()
+ {
+ return (String)proxy.retriveAttributeValue("Address");
+ }
+
+ public String getJNDIBinding()
+ {
+ return (String)proxy.retriveAttributeValue("JNDIBinding");
+ }
+
+ public int removeAllMessages() throws Exception
+ {
+ return (Integer)proxy.invokOperation("removeAllMessages");
+ }
+
+ };
+
+
+ }
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControl2Test.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,494 @@
+/*
+ * 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.tests.integration.jms.management;
+
+import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createJMSServerControl;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.server.Messaging;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
+import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
+import org.jboss.messaging.tests.integration.management.ManagementControlHelper;
+import org.jboss.messaging.tests.unit.util.InVMContext;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * A QueueControlTest
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * Created 14 nov. 2008 13:35:10
+ *
+ *
+ */
+public class JMSServerControl2Test extends UnitTestCase
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(JMSServerControl2Test.class);
+
+ // Attributes ----------------------------------------------------
+
+ private MBeanServer mbeanServer;
+
+ private InVMContext context;
+
+ // Static --------------------------------------------------------
+
+ private MessagingService startMessagingService(String acceptorFactory) throws Exception
+ {
+ mbeanServer = MBeanServerFactory.createMBeanServer();
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(acceptorFactory));
+ MessagingService service = Messaging.newNullStorageMessagingService(conf, mbeanServer);
+ service.start();
+
+ context = new InVMContext();
+ JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
+ serverManager.start();
+ serverManager.setContext(context);
+
+ return service;
+ }
+
+ private MessagingService startMessagingService(int discoveryPort) throws Exception
+ {
+ mbeanServer = MBeanServerFactory.createMBeanServer();
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getDiscoveryGroupConfigurations()
+ .put("discovery",
+ new DiscoveryGroupConfiguration("discovery",
+ "localhost",
+ discoveryPort,
+ ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT));
+ MessagingService service = Messaging.newNullStorageMessagingService(conf, mbeanServer);
+ service.start();
+
+ context = new InVMContext();
+ JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
+ serverManager.start();
+ serverManager.setContext(context);
+
+ return service;
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void _testCreateConnectionFactoryWithDiscoveryGroup() throws Exception
+ {
+ MessagingService service = null;
+ try
+ {
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
+
+ service = startMessagingService(8765);
+
+ checkNoBinding(cfJNDIBinding);
+
+ JMSServerControlMBean control = createManagementControl();
+ control.createConnectionFactory(cfName,
+ randomString(),
+ "localhost",
+ 8765,
+ ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
+ ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
+ null,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
+ ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ cfJNDIBinding);
+
+ Object o = checkBinding(cfJNDIBinding);
+ assertTrue(o instanceof ConnectionFactory);
+ ConnectionFactory cf = (ConnectionFactory)o;
+ Connection connection = cf.createConnection();
+ connection.close();
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
+ public void testListClientConnectionsForInVM() throws Exception
+ {
+ doListClientConnections(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ }
+
+ public void testListClientConnectionsForNetty() throws Exception
+ {
+ doListClientConnections(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
+ }
+
+ public void testCloseConnectionsForAddressForInVM() throws Exception
+ {
+ doCloseConnectionsForAddress(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ }
+
+ public void testCloseConnectionsForAddressForNetty() throws Exception
+ {
+ doCloseConnectionsForAddress(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
+ }
+
+ public void testCloseConnectionsForUnknownAddressForInVM() throws Exception
+ {
+ doCloseConnectionsForUnknownAddress(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ }
+
+ public void testCloseConnectionsForUnknownAddressForNetty() throws Exception
+ {
+ doCloseConnectionsForUnknownAddress(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
+ }
+
+ public void testListSessionsForInVM() throws Exception
+ {
+ doListSessions(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ }
+
+ public void testListSessionsForNetty() throws Exception
+ {
+ doListSessions(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
+ }
+
+ public void testListConnectionIDsForInVM() throws Exception
+ {
+ doListConnectionIDs(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ }
+
+ public void testListConnectionIDsForNetty() throws Exception
+ {
+ doListConnectionIDs(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected JMSServerControlMBean createManagementControl() throws Exception
+ {
+ return ManagementControlHelper.createJMSServerControl(mbeanServer);
+ }
+
+ // Private -------------------------------------------------------
+
+ private void doListConnectionIDs(String acceptorFactory, String connectorFactory) throws Exception
+ {
+ MessagingService service = null;
+ try
+ {
+ service = startMessagingService(acceptorFactory);
+
+ JMSServerControlMBean control = createManagementControl();
+
+ assertEquals(0, control.listConnectionIDs().length);
+
+ Connection connection = JMSUtil.createConnection(connectorFactory);
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ String[] connectionIDs = control.listConnectionIDs();
+ assertEquals(1, connectionIDs.length);
+
+ Connection connection2 = JMSUtil.createConnection(connectorFactory);
+ connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ assertEquals(2, control.listConnectionIDs().length);
+
+ connection.close();
+ Thread.sleep(500);
+
+ assertEquals(1, control.listConnectionIDs().length);
+
+ connection2.close();
+ Thread.sleep(500);
+
+ assertEquals(0, control.listConnectionIDs().length);
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
+ private void doListSessions(String acceptorFactory, String connectorFactory) throws Exception
+ {
+ MessagingService service = null;
+ try
+ {
+ service = startMessagingService(acceptorFactory);
+
+ JMSServerControlMBean control = createManagementControl();
+
+ assertEquals(0, control.listConnectionIDs().length);
+
+ Connection connection = JMSUtil.createConnection(connectorFactory);
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ String[] connectionIDs = control.listConnectionIDs();
+ assertEquals(1, connectionIDs.length);
+ String connectionID = connectionIDs[0];
+
+ String[] sessions = control.listSessions(connectionID);
+ assertEquals(1, sessions.length);
+
+ session.close();
+
+ sessions = control.listSessions(connectionID);
+ assertEquals(0, sessions.length);
+
+ connection.close();
+
+ Thread.sleep(500);
+
+ assertEquals(0, control.listConnectionIDs().length);
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
+ private void doListClientConnections(String acceptorFactory, String connectorFactory) throws Exception
+ {
+ MessagingService service = null;
+ try
+ {
+ service = startMessagingService(acceptorFactory);
+
+ JMSServerControlMBean control = createManagementControl();
+
+ assertEquals(0, control.listRemoteAddresses().length);
+
+ Connection connection = JMSUtil.createConnection(connectorFactory);
+ // the connection won't connect to the server until a session is created
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ String[] remoteAddresses = control.listRemoteAddresses();
+ assertEquals(1, remoteAddresses.length);
+
+ for (String remoteAddress : remoteAddresses)
+ {
+ System.out.println(remoteAddress);
+ }
+ connection.close();
+
+ // FIXME: with Netty, the server is not notified immediately that the connection is closed
+ Thread.sleep(500);
+
+ log.info("got here");
+
+ assertEquals(0, control.listRemoteAddresses().length);
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+
+ }
+
+ private void doCloseConnectionsForAddress(String acceptorFactory, String connectorFactory) throws Exception
+ {
+ MessagingService service = null;
+ try
+ {
+ service = startMessagingService(acceptorFactory);
+
+ JMSServerControlMBean control = createManagementControl();
+
+ assertEquals(0, service.getServer().getConnectionCount());
+ assertEquals(0, control.listRemoteAddresses().length);
+
+ Connection connection = JMSUtil.createConnection(connectorFactory);
+ // the connection won't connect to the server until a session is created
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ assertEquals(1, service.getServer().getConnectionCount());
+
+ String[] remoteAddresses = control.listRemoteAddresses();
+ assertEquals(1, remoteAddresses.length);
+ String remoteAddress = remoteAddresses[0];
+
+ final CountDownLatch exceptionLatch = new CountDownLatch(1);
+ connection.setExceptionListener(new ExceptionListener()
+ {
+ public void onException(JMSException e)
+ {
+ exceptionLatch.countDown();
+ }
+ });
+
+ assertTrue(control.closeConnectionsForAddress(remoteAddress));
+
+ boolean gotException = exceptionLatch.await(1, TimeUnit.SECONDS);
+ assertTrue("did not received the expected JMSException", gotException);
+ assertEquals(0, control.listRemoteAddresses().length);
+ assertEquals(0, service.getServer().getConnectionCount());
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
+ private void doCloseConnectionsForUnknownAddress(String acceptorFactory, String connectorFactory) throws Exception
+ {
+ String unknownAddress = randomString();
+
+ MessagingService service = null;
+
+ try
+ {
+ service = startMessagingService(acceptorFactory);
+
+ JMSServerControlMBean control = createManagementControl();
+
+ assertEquals(0, service.getServer().getConnectionCount());
+ assertEquals(0, control.listRemoteAddresses().length);
+
+ Connection connection = JMSUtil.createConnection(connectorFactory);
+ // the connection won't connect to the server until a session is created
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ assertEquals(1, service.getServer().getConnectionCount());
+ String[] remoteAddresses = control.listRemoteAddresses();
+ assertEquals(1, remoteAddresses.length);
+
+ final CountDownLatch exceptionLatch = new CountDownLatch(1);
+ connection.setExceptionListener(new ExceptionListener()
+ {
+ public void onException(JMSException e)
+ {
+ exceptionLatch.countDown();
+ }
+ });
+
+ assertFalse(control.closeConnectionsForAddress(unknownAddress));
+
+ boolean gotException = exceptionLatch.await(500, TimeUnit.MILLISECONDS);
+ assertFalse(gotException);
+
+ assertEquals(1, control.listRemoteAddresses().length);
+ assertEquals(1, service.getServer().getConnectionCount());
+
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
+ private void checkNoBinding(String binding)
+ {
+ try
+ {
+ context.lookup(binding);
+ fail("there must be no resource to look up for " + binding);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ private Object checkBinding(String binding) throws Exception
+ {
+ Object o = context.lookup(binding);
+ assertNotNull(o);
+ return o;
+ }
+
+ private void checkNoResource(ObjectName on)
+ {
+ assertFalse(mbeanServer.isRegistered(on));
+ }
+
+ private void checkResource(ObjectName on)
+ {
+ assertTrue(mbeanServer.isRegistered(on));
+ }
+ // Inner classes -------------------------------------------------
+
+}
\ No newline at end of file
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -22,34 +22,35 @@
package org.jboss.messaging.tests.integration.jms.management;
-import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createConnectionFactoryControl;
-import static org.jboss.messaging.tests.integration.management.ManagementControlHelper.createJMSServerControl;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomDouble;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import javax.jms.Connection;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Session;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Topic;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ObjectNames;
import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.core.server.Messaging;
-import org.jboss.messaging.core.server.MessagingService;
-import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
-import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
+import org.jboss.messaging.tests.integration.management.ManagementControlHelper;
+import org.jboss.messaging.tests.unit.util.InVMContext;
import org.jboss.messaging.tests.util.UnitTestCase;
/**
@@ -64,371 +65,344 @@
public class JMSServerControlTest extends UnitTestCase
{
// Constants -----------------------------------------------------
-
+
private static final Logger log = Logger.getLogger(JMSServerControlTest.class);
-
// Attributes ----------------------------------------------------
private MBeanServer mbeanServer;
- // Static --------------------------------------------------------
+ protected InVMContext context;
- private MessagingService startMessagingService(String acceptorFactory) throws Exception
- {
- mbeanServer = MBeanServerFactory.createMBeanServer();
- Configuration conf = new ConfigurationImpl();
- conf.setSecurityEnabled(false);
- conf.setJMXManagementEnabled(true);
- conf.getAcceptorConfigurations().add(new TransportConfiguration(acceptorFactory));
- MessagingService service = Messaging.newNullStorageMessagingService(conf, mbeanServer);
- service.start();
+ protected MessagingServiceImpl service;
- JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
- serverManager.start();
- serverManager.setContext(new NullInitialContext());
+ // Static --------------------------------------------------------
- return service;
- }
-
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
- public void testListClientConnectionsForInVM() throws Exception
+ public void testGetVersion() throws Exception
{
- doListClientConnections(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
+ JMSServerControlMBean control = createManagementControl();
+ String version = control.getVersion();
+ assertEquals(service.getServer().getVersion().getFullVersion(), version);
}
- public void testListClientConnectionsForNetty() throws Exception
+ public void testCreateQueue() throws Exception
{
- doListClientConnections(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
- }
+ String queueJNDIBinding = randomString();
+ String queueName = randomString();
- public void testCloseConnectionsForAddressForInVM() throws Exception
- {
- doCloseConnectionsForAddress(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
- }
+ checkNoBinding(queueJNDIBinding);
+ checkNoResource(ObjectNames.getJMSQueueObjectName(queueName));
- public void testCloseConnectionsForAddressForNetty() throws Exception
- {
- doCloseConnectionsForAddress(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
- }
+ JMSServerControlMBean control = createManagementControl();
+ control.createQueue(queueName, queueJNDIBinding);
- public void testCloseConnectionsForUnknownAddressForInVM() throws Exception
- {
- doCloseConnectionsForUnknownAddress(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
- }
+ Object o = checkBinding(queueJNDIBinding);
+ assertTrue(o instanceof Queue);
+ Queue queue = (Queue)o;
+ assertEquals(queueName, queue.getQueueName());
+ checkResource(ObjectNames.getJMSQueueObjectName(queueName));
- public void testCloseConnectionsForUnknownAddressForNetty() throws Exception
- {
- doCloseConnectionsForUnknownAddress(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
}
- public void testListSessionsForInVM() throws Exception
+ public void testDestroyQueue() throws Exception
{
- doListSessions(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
- }
+ String queueJNDIBinding = randomString();
+ String queueName = randomString();
- public void testListSessionsForNetty() throws Exception
- {
- doListSessions(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
- }
+ checkNoBinding(queueJNDIBinding);
+ checkNoResource(ObjectNames.getJMSQueueObjectName(queueName));
- public void testListConnectionIDsForInVM() throws Exception
- {
- doListConnectionIDs(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
- }
+ JMSServerControlMBean control = createManagementControl();
+ control.createQueue(queueName, queueJNDIBinding);
- public void testListConnectionIDsForNetty() throws Exception
- {
- doListConnectionIDs(NettyAcceptorFactory.class.getName(), NettyConnectorFactory.class.getName());
- }
+ checkBinding(queueJNDIBinding);
+ checkResource(ObjectNames.getJMSQueueObjectName(queueName));
- public void testCreateConnectionFactoryWithDiscoveryGroup() throws Exception
- {
- String cfJNDIBinding = randomString();
- String cfName = randomString();
- MessagingService service = null;
- try
- {
- service = startMessagingService(NettyAcceptorFactory.class.getName());
+ control.destroyQueue(queueName);
- try {
- ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName, mbeanServer);
- // invoke an operation on the proxy to check that there is no such mbean
- cfControl.getName();
- fail("no CF was created with name " + cfName);
- } catch (Exception e)
- {
- }
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
- control.createConnectionFactory(cfName,
- randomString(),
- "localhost",
- 8765,
- ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- null,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
- ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
- cfJNDIBinding);
-
- ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName, mbeanServer);
- assertEquals(cfName, cfControl.getName());
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
+ checkNoBinding(queueJNDIBinding);
+ checkNoResource(ObjectNames.getJMSQueueObjectName(queueName));
+
}
- // Package protected ---------------------------------------------
+ public void testCreateTopic() throws Exception
+ {
+ String topicJNDIBinding = randomString();
+ String topicName = randomString();
- // Protected -----------------------------------------------------
+ checkNoBinding(topicJNDIBinding);
+ checkNoResource(ObjectNames.getJMSTopicObjectName(topicName));
- // Private -------------------------------------------------------
+ JMSServerControlMBean control = createManagementControl();
+ control.createTopic(topicName, topicJNDIBinding);
- private void doListConnectionIDs(String acceptorFactory, String connectorFactory) throws Exception
+ Object o = checkBinding(topicJNDIBinding);
+ assertTrue(o instanceof Topic);
+ Topic topic = (Topic)o;
+ assertEquals(topicName, topic.getTopicName());
+ checkResource(ObjectNames.getJMSTopicObjectName(topicName));
+ }
+
+ public void testDestroyTopic() throws Exception
{
- MessagingService service = null;
- try
- {
- service = startMessagingService(acceptorFactory);
+ String topicJNDIBinding = randomString();
+ String topicName = randomString();
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
+ checkNoBinding(topicJNDIBinding);
+ checkNoResource(ObjectNames.getJMSTopicObjectName(topicName));
- assertEquals(0, control.listConnectionIDs().length);
+ JMSServerControlMBean control = createManagementControl();
+ control.createTopic(topicName, topicJNDIBinding);
- Connection connection = JMSUtil.createConnection(connectorFactory);
- connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ checkBinding(topicJNDIBinding);
+ checkResource(ObjectNames.getJMSTopicObjectName(topicName));
- String[] connectionIDs = control.listConnectionIDs();
- assertEquals(1, connectionIDs.length);
+ control.destroyTopic(topicName);
- Connection connection2 = JMSUtil.createConnection(connectorFactory);
- connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- assertEquals(2, control.listConnectionIDs().length);
+ checkNoBinding(topicJNDIBinding);
+ checkNoResource(ObjectNames.getJMSTopicObjectName(topicName));
+ }
- connection.close();
- Thread.sleep(500);
+ public void testCreateConnectionFactory() throws Exception
+ {
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
- assertEquals(1, control.listConnectionIDs().length);
+ checkNoBinding(cfJNDIBinding);
+ checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- connection2.close();
- Thread.sleep(500);
+ JMSServerControlMBean control = createManagementControl();
+ control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBinding);
- assertEquals(0, control.listConnectionIDs().length);
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
+ Object o = checkBinding(cfJNDIBinding);
+ assertTrue(o instanceof ConnectionFactory);
+ ConnectionFactory cf = (ConnectionFactory)o;
+ Connection connection = cf.createConnection();
+ connection.close();
+ checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
}
- private void doListSessions(String acceptorFactory, String connectorFactory) throws Exception
+ public void testCreateConnectionFactory_2() throws Exception
{
- MessagingService service = null;
- try
- {
- service = startMessagingService(acceptorFactory);
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
+ boolean preAcknowledge = randomBoolean();
+ boolean blockOnAcknowledge = randomBoolean();
+ boolean blockOnNonPersistentSend = randomBoolean();
+ boolean blockOnPersistentSend = randomBoolean();
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
+ checkNoBinding(cfJNDIBinding);
+ checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- assertEquals(0, control.listConnectionIDs().length);
+ JMSServerControlMBean control = createManagementControl();
+ control.createConnectionFactory(cfName,
+ InVMConnectorFactory.class.getName(),
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ preAcknowledge,
+ cfJNDIBinding);
- Connection connection = JMSUtil.createConnection(connectorFactory);
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Object o = checkBinding(cfJNDIBinding);
+ assertTrue(o instanceof ConnectionFactory);
+ ConnectionFactory cf = (ConnectionFactory)o;
+ Connection connection = cf.createConnection();
+ connection.close();
- String[] connectionIDs = control.listConnectionIDs();
- assertEquals(1, connectionIDs.length);
- String connectionID = connectionIDs[0];
+ checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+ ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
+ mbeanServer);
+ assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
+ assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
+ assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
+ assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
+ }
- String[] sessions = control.listSessions(connectionID);
- assertEquals(1, sessions.length);
+ public void testCreateConnectionFactory_3() throws Exception
+ {
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
+ long pingPeriod = randomPositiveLong();
+ long connectionTTL = randomPositiveLong();
+ long callTimeout = randomPositiveLong();
+ String clientID = randomString();
+ int dupsOKBatchSize = randomPositiveInt();
+ int transactionBatchSize = randomPositiveInt();
+ int consumerWindowSize = randomPositiveInt();
+ int consumerMaxRate = randomPositiveInt();
+ int producerWindowSize = randomPositiveInt();
+ int producerMaxRate = randomPositiveInt();
+ int minLargeMessageSize = randomPositiveInt();
+ boolean autoGroup = randomBoolean();
+ int maxConnections = randomPositiveInt();
+ long retryInterval = randomPositiveLong();
+ double retryIntervalMultiplier = randomDouble();
+ int maxRetriesBeforeFailover = randomPositiveInt();
+ int maxRetriesAfterFailover = randomPositiveInt();
+ boolean preAcknowledge = randomBoolean();
+ boolean blockOnAcknowledge = randomBoolean();
+ boolean blockOnNonPersistentSend = randomBoolean();
+ boolean blockOnPersistentSend = randomBoolean();
- session.close();
+ checkNoBinding(cfJNDIBinding);
+ checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- sessions = control.listSessions(connectionID);
- assertEquals(0, sessions.length);
+ JMSServerControlMBean control = createManagementControl();
- connection.close();
+ control.createSimpleConnectionFactory(cfName,
+ InVMConnectorFactory.class.getName(),
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ clientID,
+ dupsOKBatchSize,
+ transactionBatchSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroup,
+ maxConnections,
+ preAcknowledge,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ cfJNDIBinding);
- Thread.sleep(500);
+ Object o = checkBinding(cfJNDIBinding);
+ assertTrue(o instanceof ConnectionFactory);
+ ConnectionFactory cf = (ConnectionFactory)o;
+ Connection connection = cf.createConnection();
+ connection.close();
- assertEquals(0, control.listConnectionIDs().length);
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
+ checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+ ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
+ mbeanServer);
+ assertEquals(cfName, cfControl.getName());
+ assertEquals(pingPeriod, cfControl.getPingPeriod());
+ assertEquals(connectionTTL, cfControl.getConnectionTTL());
+ assertEquals(callTimeout, cfControl.getCallTimeout());
+ assertEquals(clientID, cfControl.getClientID());
+ assertEquals(dupsOKBatchSize, cfControl.getDupsOKBatchSize());
+ assertEquals(transactionBatchSize, cfControl.getTransactionBatchSize());
+ assertEquals(consumerWindowSize, cfControl.getConsumerWindowSize());
+ assertEquals(consumerMaxRate, cfControl.getConsumerMaxRate());
+ assertEquals(producerWindowSize, cfControl.getProducerWindowSize());
+ assertEquals(producerMaxRate, cfControl.getProducerMaxRate());
+ assertEquals(minLargeMessageSize, cfControl.getMinLargeMessageSize());
+ assertEquals(autoGroup, cfControl.isAutoGroup());
+ assertEquals(maxConnections, cfControl.getMaxConnections());
+ assertEquals(retryInterval, cfControl.getRetryInterval());
+ assertEquals(retryIntervalMultiplier, cfControl.getRetryIntervalMultiplier());
+ assertEquals(maxRetriesBeforeFailover, cfControl.getMaxRetriesBeforeFailover());
+ assertEquals(maxRetriesAfterFailover, cfControl.getMaxRetriesAfterFailover());
+ assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
+ assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
+ assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
+ assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
}
- private void doListClientConnections(String acceptorFactory, String connectorFactory) throws Exception
+ public void testDestroyConnectionFactory() throws Exception
{
- MessagingService service = null;
- try
- {
- service = startMessagingService(acceptorFactory);
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
+ checkNoBinding(cfJNDIBinding);
+ checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- assertEquals(0, control.listRemoteAddresses().length);
+ JMSServerControlMBean control = createManagementControl();
+ control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBinding);
- Connection connection = JMSUtil.createConnection(connectorFactory);
- // the connection won't connect to the server until a session is created
- connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Object o = checkBinding(cfJNDIBinding);
+ assertTrue(o instanceof ConnectionFactory);
+ ConnectionFactory cf = (ConnectionFactory)o;
+ Connection connection = cf.createConnection();
+ connection.close();
+ checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- String[] remoteAddresses = control.listRemoteAddresses();
- assertEquals(1, remoteAddresses.length);
+ control.destroyConnectionFactory(cfName);
- for (String remoteAddress : remoteAddresses)
- {
- System.out.println(remoteAddress);
- }
- connection.close();
+ checkNoBinding(cfJNDIBinding);
+ checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+ }
- // FIXME: with Netty, the server is not notified immediately that the connection is closed
- Thread.sleep(500);
-
- log.info("got here");
+ // Package protected ---------------------------------------------
- assertEquals(0, control.listRemoteAddresses().length);
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
+ // Protected -----------------------------------------------------
- }
-
- private void doCloseConnectionsForAddress(String acceptorFactory, String connectorFactory) throws Exception
+ @Override
+ protected void setUp() throws Exception
{
- MessagingService service = null;
- try
- {
- service = startMessagingService(acceptorFactory);
+ super.setUp();
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
+ mbeanServer = MBeanServerFactory.createMBeanServer();
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+ service = Messaging.newNullStorageMessagingService(conf, mbeanServer);
+ service.start();
- assertEquals(0, service.getServer().getConnectionCount());
- assertEquals(0, control.listRemoteAddresses().length);
+ context = new InVMContext();
+ JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
+ serverManager.start();
+ serverManager.setContext(context);
+ }
- Connection connection = JMSUtil.createConnection(connectorFactory);
- // the connection won't connect to the server until a session is created
- connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ @Override
+ protected void tearDown() throws Exception
+ {
+ service.stop();
- assertEquals(1, service.getServer().getConnectionCount());
+ super.tearDown();
+ }
- String[] remoteAddresses = control.listRemoteAddresses();
- assertEquals(1, remoteAddresses.length);
- String remoteAddress = remoteAddresses[0];
+ protected JMSServerControlMBean createManagementControl() throws Exception
+ {
+ return ManagementControlHelper.createJMSServerControl(mbeanServer);
+ }
- final CountDownLatch exceptionLatch = new CountDownLatch(1);
- connection.setExceptionListener(new ExceptionListener()
- {
- public void onException(JMSException e)
- {
- exceptionLatch.countDown();
- }
- });
+ // Private -------------------------------------------------------
- assertTrue(control.closeConnectionsForAddress(remoteAddress));
-
- boolean gotException = exceptionLatch.await(1, TimeUnit.SECONDS);
- assertTrue("did not received the expected JMSException", gotException);
- assertEquals(0, control.listRemoteAddresses().length);
- assertEquals(0, service.getServer().getConnectionCount());
+ private void checkNoBinding(String binding)
+ {
+ try
+ {
+ context.lookup(binding);
+ fail("there must be no resource to look up for " + binding);
}
- finally
+ catch (Exception e)
{
- if (service != null)
- {
- service.stop();
- }
}
}
- private void doCloseConnectionsForUnknownAddress(String acceptorFactory, String connectorFactory) throws Exception
+ private Object checkBinding(String binding) throws Exception
{
- String unknownAddress = randomString();
+ Object o = context.lookup(binding);
+ assertNotNull(o);
+ return o;
+ }
- MessagingService service = null;
+ private void checkNoResource(ObjectName on)
+ {
+ assertFalse(mbeanServer.isRegistered(on));
+ }
- try
- {
- service = startMessagingService(acceptorFactory);
-
- JMSServerControlMBean control = createJMSServerControl(mbeanServer);
-
- assertEquals(0, service.getServer().getConnectionCount());
- assertEquals(0, control.listRemoteAddresses().length);
-
- Connection connection = JMSUtil.createConnection(connectorFactory);
- // the connection won't connect to the server until a session is created
- connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- assertEquals(1, service.getServer().getConnectionCount());
- String[] remoteAddresses = control.listRemoteAddresses();
- assertEquals(1, remoteAddresses.length);
-
- final CountDownLatch exceptionLatch = new CountDownLatch(1);
- connection.setExceptionListener(new ExceptionListener()
- {
- public void onException(JMSException e)
- {
- exceptionLatch.countDown();
- }
- });
-
- assertFalse(control.closeConnectionsForAddress(unknownAddress));
-
- boolean gotException = exceptionLatch.await(500, TimeUnit.MILLISECONDS);
- assertFalse(gotException);
-
- assertEquals(1, control.listRemoteAddresses().length);
- assertEquals(1, service.getServer().getConnectionCount());
-
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
+ private void checkResource(ObjectName on)
+ {
+ assertTrue(mbeanServer.isRegistered(on));
}
+
// Inner classes -------------------------------------------------
}
\ No newline at end of file
Added: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlUsingJMSTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlUsingJMSTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,366 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.integration.jms.management;
+
+import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
+
+import java.util.List;
+
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.management.ObjectNames;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
+import org.jboss.messaging.utils.Pair;
+
+/**
+ * A JMSServerControlUsingCoreTest
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public class JMSServerControlUsingJMSTest extends JMSServerControlTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private QueueConnection connection;
+
+ private QueueSession session;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // JMSServerControlTest overrides --------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ JMSServerManagerImpl serverManager = JMSServerManagerImpl.newJMSServerManagerImpl(service.getServer());
+ serverManager.start();
+ serverManager.setContext(context);
+
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+ connection = cf.createQueueConnection();
+ session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ connection.close();
+
+ super.tearDown();
+ }
+
+ @Override
+ protected JMSServerControlMBean createManagementControl() throws Exception
+ {
+ JBossQueue managementQueue = new JBossQueue(DEFAULT_MANAGEMENT_ADDRESS.toString(),
+ DEFAULT_MANAGEMENT_ADDRESS.toString());
+ final JMSMessagingProxy proxy = new JMSMessagingProxy(session,
+ managementQueue,
+ ObjectNames.getJMSServerObjectName());
+
+ return new JMSServerControlMBean()
+ {
+
+ public boolean closeConnectionsForAddress(final String ipAddress) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("closeConnectionsForAddress", ipAddress);
+ }
+
+ public void createConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final String jndiBinding) throws Exception
+ {
+ proxy.invokOperation("createConnectionFactory", name, connectorFactoryClassName, jndiBinding);
+ }
+
+ public void createConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean preAcknowledge,
+ final String jndiBinding) throws Exception
+ {
+ proxy.invokOperation("createConnectionFactory",
+ name,
+ connectorFactoryClassName,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ preAcknowledge,
+ jndiBinding);
+ }
+
+ public void createSimpleConnectionFactory(final String name,
+ final String connectorFactoryClassName,
+ final String connectionLoadBalancingPolicyClassName,
+ final long pingPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final int minLargeMessageSize,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean autoGroup,
+ final int maxConnections,
+ final boolean preAcknowledge,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final int maxRetriesBeforeFailover,
+ final int maxRetriesAfterFailover,
+ final String jndiBinding) throws Exception
+ {
+ proxy.invokOperation("createSimpleConnectionFactory",
+ name,
+ connectorFactoryClassName,
+ connectionLoadBalancingPolicyClassName,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ clientID,
+ dupsOKBatchSize,
+ transactionBatchSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroup,
+ maxConnections,
+ preAcknowledge,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ jndiBinding);
+ }
+
+ public void createConnectionFactory(final String name,
+ final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ final String connectionLoadBalancingPolicyClassName,
+ final long pingPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final int minLargeMessageSize,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean autoGroup,
+ final int maxConnections,
+ final boolean preAcknowledge,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final int maxRetriesBeforeFailover,
+ final int maxRetriesAfterFailover,
+ final String jndiBinding) throws Exception
+ {
+ proxy.invokOperation("createConnectionFactory",
+ name,
+ connectorConfigs,
+ connectionLoadBalancingPolicyClassName,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ clientID,
+ dupsOKBatchSize,
+ transactionBatchSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroup,
+ maxConnections,
+ preAcknowledge,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ jndiBinding);
+ }
+
+ public void createConnectionFactory(final String name,
+ final String discoveryGroupName,
+ final String discoveryGroupAddress,
+ final int discoveryGroupPort,
+ final long discoveryGroupRefreshTimeout,
+ final long discoveryInitialWait,
+ final String connectionLoadBalancingPolicyClassName,
+ final long pingPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final int minLargeMessageSize,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean autoGroup,
+ final int maxConnections,
+ final boolean preAcknowledge,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final int maxRetriesBeforeFailover,
+ final int maxRetriesAfterFailover,
+ final String jndiBinding) throws Exception
+ {
+ proxy.invokOperation("createConnectionFactory",
+ name,
+ discoveryGroupName,
+ discoveryGroupAddress,
+ discoveryGroupPort,
+ discoveryGroupRefreshTimeout,
+ discoveryInitialWait,
+ connectionLoadBalancingPolicyClassName,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ clientID,
+ dupsOKBatchSize,
+ transactionBatchSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ minLargeMessageSize,
+ blockOnAcknowledge,
+ blockOnNonPersistentSend,
+ blockOnPersistentSend,
+ autoGroup,
+ maxConnections,
+ preAcknowledge,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ jndiBinding);
+ }
+
+ public boolean createQueue(final String name, final String jndiBinding) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("createQueue", name, jndiBinding);
+ }
+
+ public boolean createTopic(final String name, final String jndiBinding) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("createTopic", name, jndiBinding);
+ }
+
+ public void destroyConnectionFactory(final String name) throws Exception
+ {
+ proxy.invokOperation("destroyConnectionFactory", name);
+ }
+
+ public boolean destroyQueue(final String name) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("destroyQueue", name);
+ }
+
+ public boolean destroyTopic(final String name) throws Exception
+ {
+ return (Boolean)proxy.invokOperation("destroyTopic", name);
+ }
+
+ public String getVersion()
+ {
+ return (String)proxy.retriveAttributeValue("Version");
+ }
+
+ public boolean isStarted()
+ {
+ return (Boolean)proxy.retriveAttributeValue("Started");
+ }
+
+ public String[] listConnectionIDs() throws Exception
+ {
+ return (String[])proxy.invokOperation("listConnectionIDs");
+ }
+
+ public String[] listRemoteAddresses() throws Exception
+ {
+ return (String[])proxy.invokOperation("listRemoteAddresses");
+ }
+
+ public String[] listRemoteAddresses(final String ipAddress) throws Exception
+ {
+ return (String[])proxy.invokOperation("listRemoteAddresses", ipAddress);
+ }
+
+ public String[] listSessions(final String connectionID) throws Exception
+ {
+ return (String[])proxy.invokOperation("listSessions", connectionID);
+ }
+
+ };
+ }
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSUtil.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -54,6 +54,8 @@
import javax.jms.Topic;
import javax.jms.TopicSubscriber;
+import junit.framework.Assert;
+
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.jms.client.JBossConnectionFactory;
@@ -122,9 +124,9 @@
DEFAULT_SEND_WINDOW_SIZE,
DEFAULT_PRODUCER_MAX_RATE,
DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
true,
+ true,
+ true,
DEFAULT_AUTO_GROUP,
DEFAULT_MAX_CONNECTIONS,
DEFAULT_PRE_ACKNOWLEDGE,
@@ -149,12 +151,12 @@
{
return createConsumer(destination,
startConnection,
- "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory");
+ InVMConnectorFactory.class.getName());
}
static TopicSubscriber createDurableSubscriber(Topic topic, String clientID, String subscriptionName) throws JMSException
{
- JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
null,
DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
DEFAULT_PING_PERIOD,
@@ -187,24 +189,16 @@
return s.createDurableSubscriber(topic, subscriptionName);
}
- public static void sendMessages(Destination destination, int messagesToSend) throws Exception
+ public static String[] sendMessages(Destination destination, int messagesToSend) throws Exception
{
JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
- Connection conn = cf.createConnection();
-
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = s.createProducer(destination);
-
- for (int i = 0; i < messagesToSend; i++)
- {
- producer.send(s.createTextMessage(randomString()));
- }
-
- conn.close();
+ return sendMessages(cf, destination, messagesToSend);
}
- public static void sendMessages(ConnectionFactory cf, Destination destination, int messagesToSend) throws Exception
+ public static String[] sendMessages(ConnectionFactory cf, Destination destination, int messagesToSend) throws Exception
{
+ String[] messageIDs = new String[messagesToSend];
+
Connection conn = cf.createConnection();
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -212,10 +206,14 @@
for (int i = 0; i < messagesToSend; i++)
{
- producer.send(s.createTextMessage(randomString()));
+ Message m = s.createTextMessage(randomString());
+ producer.send(m);
+ messageIDs[i] = m.getJMSMessageID();
}
conn.close();
+
+ return messageIDs;
}
public static Message sendMessageWithProperty(Session session, Destination destination, String key, long value) throws JMSException
@@ -227,6 +225,33 @@
return message;
}
+ public static void consumeMessages(int expected, Destination dest) throws JMSException
+ {
+ Connection connection = createConnection(InVMConnectorFactory.class.getName());
+ try{
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer(dest);
+
+ connection.start();
+
+ Message m = null;
+ for (int i = 0; i < expected; i++)
+ {
+ m = consumer.receive(500);
+ Assert.assertNotNull("expected to received " + expected + " messages, got only " + (i + 1), m);
+ }
+ m = consumer.receive(500);
+ Assert.assertNull("received one more message than expected (" + expected + ")", m);
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -28,9 +28,9 @@
import javax.jms.Connection;
import javax.jms.Session;
-import javax.jms.Topic;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
+import javax.management.openmbean.TabularData;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
@@ -67,7 +67,7 @@
private String subscriptionName;
- private Topic topic;
+ protected JBossTopic topic;
private MBeanServer mbeanServer;
@@ -77,6 +77,16 @@
// Public --------------------------------------------------------
+ public void testGetAttributes() throws Exception
+ {
+ TopicControlMBean topicControl = createManagementControl();
+
+ assertEquals(topic.getTopicName(), topicControl.getName());
+ assertEquals(topic.getAddress(), topicControl.getAddress());
+ assertEquals(topic.isTemporary(), topicControl.isTemporary());
+ assertEquals(topic.getName(), topicControl.getJNDIBinding());
+ }
+
public void testGetXXXSubscriptionsCount() throws Exception
{
// 1 non-durable subscriber, 2 durable subscribers
@@ -84,7 +94,7 @@
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
+ TopicControlMBean topicControl = createManagementControl();
assertEquals(3, topicControl.getSubcriptionsCount());
assertEquals(1, topicControl.getNonDurableSubcriptionsCount());
assertEquals(2, topicControl.getDurableSubcriptionsCount());
@@ -97,7 +107,7 @@
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
+ TopicControlMBean topicControl = createManagementControl();
assertEquals(0, topicControl.getMessageCount());
assertEquals(0, topicControl.getNonDurableMessagesCount());
@@ -117,10 +127,10 @@
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
- assertEquals(3, topicControl.listAllSubscriptionInfos().length);
- assertEquals(1, topicControl.listNonDurableSubscriptionInfos().length);
- assertEquals(2, topicControl.listDurableSubscriptionInfos().length);
+ TopicControlMBean topicControl = createManagementControl();
+ assertEquals(3, topicControl.listAllSubscriptions().size());
+ assertEquals(1, topicControl.listNonDurableSubscriptions().size());
+ assertEquals(2, topicControl.listDurableSubscriptions().size());
}
public void testCountMessagesForSubscription() throws Exception
@@ -139,19 +149,51 @@
JMSUtil.sendMessageWithProperty(session, topic, key, unmatchingValue);
JMSUtil.sendMessageWithProperty(session, topic, key, matchingValue);
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
-
+ TopicControlMBean topicControl = createManagementControl();
+
assertEquals(3, topicControl.getMessageCount());
assertEquals(2, topicControl.countMessagesForSubscription(clientID, subscriptionName, key + " =" + matchingValue));
assertEquals(1, topicControl.countMessagesForSubscription(clientID, subscriptionName, key + " =" + unmatchingValue));
}
+
+ public void testCountMessagesForUnknownSubscription() throws Exception
+ {
+ String unknownSubscription = randomString();
+
+ TopicControlMBean topicControl = createManagementControl();
+
+ try
+ {
+ topicControl.countMessagesForSubscription(clientID, unknownSubscription, null);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ public void testCountMessagesForUnknownClientID() throws Exception
+ {
+ String unknownClientID = randomString();
+
+ TopicControlMBean topicControl = createManagementControl();
+
+ try
+ {
+ topicControl.countMessagesForSubscription(unknownClientID, subscriptionName, null);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
public void testDropDurableSubscriptionWithExistingSubscription() throws Exception
{
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
+ TopicControlMBean topicControl = createManagementControl();
assertEquals(1, topicControl.getDurableSubcriptionsCount());
topicControl.dropDurableSubscription(clientID, subscriptionName);
@@ -163,7 +205,7 @@
{
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
+ TopicControlMBean topicControl = createManagementControl();
assertEquals(1, topicControl.getDurableSubcriptionsCount());
try
@@ -185,14 +227,72 @@
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
- TopicControlMBean topicControl = createTopicControl(topic, mbeanServer);
+ TopicControlMBean topicControl = createManagementControl();
assertEquals(3, topicControl.getSubcriptionsCount());
topicControl.dropAllSubscriptions();
assertEquals(0, topicControl.getSubcriptionsCount());
}
+
+ public void testRemoveAllMessages() throws Exception
+ {
+ JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
+ JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName + "2");
+
+ JMSUtil.sendMessages(topic, 3);
+
+ TopicControlMBean topicControl = createManagementControl();
+ assertEquals(3 * 2, topicControl.getMessageCount());
+ int removedCount = topicControl.removeAllMessages();
+ assertEquals(3 * 2, removedCount);
+ assertEquals(0, topicControl.getMessageCount());
+ }
+
+ public void testListMessagesForSubscription() throws Exception
+ {
+ JMSUtil.createDurableSubscriber(topic, clientID, subscriptionName);
+
+ JMSUtil.sendMessages(topic, 3);
+
+ TopicControlMBean topicControl = createManagementControl();
+ TabularData tabularData = topicControl.listMessagesForSubscription(JBossTopic.createQueueNameForDurableSubscription(clientID, subscriptionName));
+ assertEquals(3, tabularData.size());
+ }
+
+ public void testListMessagesForSubscriptionWithUnknownClientID() throws Exception
+ {
+ String unknownClientID = randomString();
+
+ TopicControlMBean topicControl = createManagementControl();
+
+ try
+ {
+ topicControl.listMessagesForSubscription(JBossTopic.createQueueNameForDurableSubscription(unknownClientID, subscriptionName));
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testListMessagesForSubscriptionWithUnknownSubscription() throws Exception
+ {
+ String unknownSubscription = randomString();
+
+ TopicControlMBean topicControl = createManagementControl();
+
+ try
+ {
+ topicControl.listMessagesForSubscription(JBossTopic.createQueueNameForDurableSubscription(clientID, unknownSubscription));
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -230,7 +330,13 @@
super.tearDown();
}
+
+ protected TopicControlMBean createManagementControl() throws Exception
+ {
+ return createTopicControl(topic, mbeanServer);
+ }
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Added: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlUsingJMSTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/TopicControlUsingJMSTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.integration.jms.management;
+
+import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
+
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.management.ObjectNames;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+
+/**
+ * A JMSQueueControlUsingJMSTest
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public class TopicControlUsingJMSTest extends TopicControlTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private QueueConnection connection;
+
+ private QueueSession session;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // JMSServerControlTest overrides --------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+ connection = cf.createQueueConnection();
+ session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ connection.close();
+
+ super.tearDown();
+ }
+
+ @Override
+ protected TopicControlMBean createManagementControl() throws Exception
+ {
+ JBossQueue managementQueue = new JBossQueue(DEFAULT_MANAGEMENT_ADDRESS.toString(),
+ DEFAULT_MANAGEMENT_ADDRESS.toString());
+ final JMSMessagingProxy proxy = new JMSMessagingProxy(session,
+ managementQueue,
+ ObjectNames.getJMSTopicObjectName(topic.getTopicName()));
+
+ return new TopicControlMBean()
+ {
+ public int countMessagesForSubscription(String clientID, String subscriptionName, String filter) throws Exception
+ {
+ return (Integer)proxy.invokOperation("countMessagesForSubscription", clientID, subscriptionName, filter);
+ }
+
+ public void dropAllSubscriptions() throws Exception
+ {
+ proxy.invokOperation("dropAllSubscriptions");
+ }
+
+ public void dropDurableSubscription(String clientID, String subscriptionName) throws Exception
+ {
+ proxy.invokOperation("dropDurableSubscription", clientID, subscriptionName);
+ }
+
+ public int getDurableMessagesCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("DurableMessagesCount");
+ }
+
+ public int getDurableSubcriptionsCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("DurableSubcriptionsCount");
+ }
+
+ public int getNonDurableMessagesCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("NonDurableMessagesCount");
+ }
+
+ public int getNonDurableSubcriptionsCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("NonDurableSubcriptionsCount");
+ }
+
+ public int getSubcriptionsCount()
+ {
+ return (Integer)proxy.retriveAttributeValue("SubcriptionsCount");
+ }
+
+ public TabularData listAllSubscriptions() throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listAllSubscriptions");
+ }
+
+ public TabularData listDurableSubscriptions() throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listDurableSubscriptions");
+ }
+
+ public TabularData listMessagesForSubscription(String queueName) throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listMessagesForSubscription", queueName);
+ }
+
+ public TabularData listNonDurableSubscriptions() throws Exception
+ {
+ return (TabularData)proxy.invokOperation("listNonDurableSubscriptions");
+ }
+
+ public String getAddress()
+ {
+ return (String)proxy.retriveAttributeValue("Address");
+ }
+
+ public String getJNDIBinding()
+ {
+ return (String)proxy.retriveAttributeValue("JNDIBinding");
+ }
+
+ public int getMessageCount() throws Exception
+ {
+ return (Integer)proxy.retriveAttributeValue("MessageCount");
+ }
+
+ public String getName()
+ {
+ return (String)proxy.retriveAttributeValue("Name");
+ }
+
+ public boolean isTemporary()
+ {
+ return (Boolean)proxy.retriveAttributeValue("Temporary");
+ }
+
+ public int removeAllMessages() throws Exception
+ {
+ return (Integer)proxy.invokOperation("removeAllMessages");
+ }
+
+ };
+ }
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -104,9 +104,9 @@
role.isCheckType(READ),
role.isCheckType(WRITE));
- managementService.handleMessage(message);
+ ServerMessage reply = managementService.handleMessage(message);
- boolean success = (Boolean)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
+ boolean success = (Boolean)reply.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
assertTrue(success);
verify(resource);
@@ -145,11 +145,11 @@
role.isCheckType(READ),
role.isCheckType(WRITE));
- managementService.handleMessage(message);
+ ServerMessage reply = managementService.handleMessage(message);
- boolean success = (Boolean)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
+ boolean success = (Boolean)reply.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
assertFalse(success);
- SimpleString exceptionMsg = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION);
+ SimpleString exceptionMsg = (SimpleString)reply.getProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION);
assertNotNull(exceptionMsg);
assertEquals(exceptionMessage, exceptionMsg.toString());
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/QueueControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -70,7 +70,7 @@
// Attributes ----------------------------------------------------
- private MessagingService service;
+ protected MessagingService service;
protected MBeanServer mbeanServer;
@@ -290,7 +290,7 @@
session.deleteQueue(queue);
}
- public void testListScheduledCount() throws Exception
+ public void testListScheduledMessages() throws Exception
{
long delay = 2000;
SimpleString address = randomSimpleString();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementTestBase.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/SecurityManagementTestBase.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -99,12 +99,12 @@
ClientRequestor requestor = new ClientRequestor(session, DEFAULT_MANAGEMENT_ADDRESS);
ClientMessage mngmntMessage = session.createClientMessage(false);
- ManagementHelper.putAttributes(mngmntMessage, ObjectNames.getMessagingServerObjectName(), "Started");
+ ManagementHelper.putAttribute(mngmntMessage, ObjectNames.getMessagingServerObjectName(), "Started");
ClientMessage reply = requestor.request(mngmntMessage, 500);
if (expectSuccess)
{
- assertNotNull(reply);
- assertTrue((Boolean)reply.getProperty(new SimpleString("Started")));
+ assertNotNull(reply);
+ assertTrue((Boolean)ManagementHelper.getResult(reply));
}
else
{
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreAddressControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreAddressControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreAddressControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -22,8 +22,6 @@
package org.jboss.messaging.tests.integration.management.core;
-import static org.jboss.messaging.tests.integration.management.core.CoreMessagingProxy.fromNullableSimpleString;
-
import javax.management.openmbean.TabularData;
import org.jboss.messaging.core.management.AddressControlMBean;
@@ -66,17 +64,17 @@
public String getAddress()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("Address"));
+ return (String)proxy.retriveAttributeValue("Address");
}
public String[] getQueueNames() throws Exception
{
- return (String[])proxy.retrieveArrayAttribute("QueueNames");
+ return (String[])proxy.retriveAttributeValue("QueueNames");
}
public TabularData getRoles() throws Exception
{
- return proxy.retrieveTabularAttribute("Roles");
+ return (TabularData)proxy.retriveAttributeValue("Roles");
}
public void removeRole(String name) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreMessagingProxy.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreMessagingProxy.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreMessagingProxy.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -25,8 +25,6 @@
import static org.jboss.messaging.core.config.impl.ConfigurationImpl.DEFAULT_MANAGEMENT_ADDRESS;
import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientRequestor;
@@ -56,18 +54,6 @@
// Static --------------------------------------------------------
- protected static String fromNullableSimpleString(SimpleString sstring)
- {
- if (sstring == null)
- {
- return null;
- }
- else
- {
- return sstring.toString();
- }
- }
-
// Constructors --------------------------------------------------
public CoreMessagingProxy(ClientSession session, ObjectName objectName) throws Exception
@@ -86,20 +72,15 @@
// Protected -----------------------------------------------------
- protected Object retriveAttributeValue(String attributeName)
+ public Object retriveAttributeValue(String attributeName)
{
ClientMessage m = session.createClientMessage(false);
- ManagementHelper.putAttributes(m, on, attributeName);
+ ManagementHelper.putAttribute(m, on, attributeName);
ClientMessage reply;
try
{
reply = requestor.request(m);
- Object attributeValue = reply.getProperty(new SimpleString(attributeName));
- if (attributeValue.equals(new SimpleString("null")))
- {
- return null;
- }
- return attributeValue;
+ return ManagementHelper.getResult(reply);
}
catch (Exception e)
{
@@ -107,44 +88,14 @@
}
}
- public Object[] retrieveArrayAttribute(String attributeName)
+ public Object invokOperation(String operationName, Object... args) throws Exception
{
ClientMessage m = session.createClientMessage(false);
- ManagementHelper.putAttributes(m, on, attributeName);
- try
- {
- ClientMessage reply = requestor.request(m);
- return (Object[])ManagementHelper.getArrayProperty(reply, attributeName);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
-
- public TabularData retrieveTabularAttribute(String attributeName)
- {
- ClientMessage m = session.createClientMessage(false);
- ManagementHelper.putAttributes(m, on, attributeName);
- try
- {
- ClientMessage reply = requestor.request(m);
- return (TabularData)ManagementHelper.getTabularDataProperty(reply, attributeName);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
-
- protected Object invokOperation(String operationName, Object... args) throws Exception
- {
- ClientMessage m = session.createClientMessage(false);
ManagementHelper.putOperationInvocation(m, on, operationName, args);
ClientMessage reply = requestor.request(m);
if (ManagementHelper.hasOperationSucceeded(reply))
{
- return reply.getProperty(new SimpleString(operationName));
+ return ManagementHelper.getResult(reply);
}
else
{
@@ -152,36 +103,6 @@
}
}
- protected TabularData invokeTabularOperation(String operationName, Object... args) throws Exception
- {
- ClientMessage m = session.createClientMessage(false);
- ManagementHelper.putOperationInvocation(m, on, operationName, args);
- ClientMessage reply = requestor.request(m);
- if (ManagementHelper.hasOperationSucceeded(reply))
- {
- return ManagementHelper.getTabularDataProperty(reply, operationName);
- }
- else
- {
- throw new Exception(ManagementHelper.getOperationExceptionMessage(reply));
- }
- }
-
- protected CompositeData invokeCompositeOperation(String operationName, Object... args) throws Exception
- {
- ClientMessage m = session.createClientMessage(false);
- ManagementHelper.putOperationInvocation(m, on, operationName, args);
- ClientMessage reply = requestor.request(m);
- if (ManagementHelper.hasOperationSucceeded(reply))
- {
- return ManagementHelper.getCompositeDataProperty(reply, operationName);
- }
- else
- {
- throw new Exception(ManagementHelper.getOperationExceptionMessage(reply));
- }
- }
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreQueueControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/core/CoreQueueControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -22,8 +22,6 @@
package org.jboss.messaging.tests.integration.management.core;
-import static org.jboss.messaging.tests.integration.management.core.CoreMessagingProxy.fromNullableSimpleString;
-
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
@@ -84,7 +82,7 @@
public String getAddress()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("Address"));
+ return (String)proxy.retriveAttributeValue("Address");
}
public int getConsumerCount()
@@ -94,7 +92,7 @@
public String getDeadLetterAddress()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("DeadLetterAddress"));
+ return (String)proxy.retriveAttributeValue("DeadLetterAddress");
}
public int getDeliveringCount()
@@ -104,12 +102,12 @@
public String getExpiryAddress()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("ExpiryAddress"));
+ return (String)proxy.retriveAttributeValue("ExpiryAddress");
}
public String getFilter()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("Filter"));
+ return (String)proxy.retriveAttributeValue("Filter");
}
public int getMessageCount()
@@ -124,7 +122,7 @@
public String getName()
{
- return fromNullableSimpleString((SimpleString)proxy.retriveAttributeValue("Name"));
+ return (String)proxy.retriveAttributeValue("Name");
}
public long getPersistenceID()
@@ -154,37 +152,37 @@
public TabularData listAllMessages() throws Exception
{
- return proxy.invokeTabularOperation("listAllMessages");
+ return (TabularData)proxy.invokOperation("listAllMessages");
}
public CompositeData listMessageCounter() throws Exception
{
- return proxy.invokeCompositeOperation("listMessageCounter");
+ return (CompositeData)proxy.invokOperation("listMessageCounter");
}
public String listMessageCounterAsHTML() throws Exception
{
- return fromNullableSimpleString((SimpleString)proxy.invokOperation("listMessageCounterAsHTML"));
+ return (String)proxy.invokOperation("listMessageCounterAsHTML");
}
public TabularData listMessageCounterHistory() throws Exception
{
- return proxy.invokeTabularOperation("listMessageCounterHistory");
+ return (TabularData)proxy.invokOperation("listMessageCounterHistory");
}
public String listMessageCounterHistoryAsHTML() throws Exception
{
- return fromNullableSimpleString((SimpleString)proxy.invokOperation("listMessageCounterHistoryAsHTML"));
+ return (String)proxy.invokOperation("listMessageCounterHistoryAsHTML");
}
public TabularData listMessages(String filter) throws Exception
{
- return proxy.invokeTabularOperation("listMessages", filter);
+ return (TabularData)proxy.invokOperation("listMessages", filter);
}
public TabularData listScheduledMessages() throws Exception
{
- return proxy.invokeTabularOperation("listScheduledMessages");
+ return (TabularData)proxy.invokOperation("listScheduledMessages");
}
public int moveAllMessages(String otherQueueName) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -27,13 +27,14 @@
import static org.easymock.EasyMock.verify;
import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.management.openmbean.TabularData;
import org.jboss.messaging.core.client.impl.ClientMessageImpl;
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
-import org.jboss.messaging.core.management.RoleInfo;
import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.tests.util.UnitTestCase;
@@ -109,47 +110,25 @@
verify(msg);
}
- public void testGetTabularDataProperty() throws Exception
+ public void testStoreInvalidPropertyType() throws Exception
{
SimpleString key = randomSimpleString();
- RoleInfo[] roles = new RoleInfo[] { new RoleInfo(randomString(),
- randomBoolean(),
- randomBoolean(),
- randomBoolean()),
- new RoleInfo(randomString(), randomBoolean(), randomBoolean(), randomBoolean()) };
-
- TabularData tabularData = RoleInfo.toTabularData(roles);
-
+ Map invalidType = new HashMap();
+
Message msg = new ClientMessageImpl();
- ManagementHelper.storeTypedProperty(msg, key, tabularData);
-
- assertTrue(msg.containsProperty(key));
- TabularData data = ManagementHelper.getTabularDataProperty(msg, key.toString());
- assertNotNull(data);
- assertEquals(2, data.size());
- }
-
- public void testGetTabularDataPropertyOnAnotherPropertyType() throws Exception
- {
- SimpleString key = randomSimpleString();
- SimpleString value = randomSimpleString();
-
- Message msg = createMock(Message.class);
- expect(msg.getProperty(key)).andReturn(value);
- replay(msg);
-
try
{
- ManagementHelper.getTabularDataProperty(msg, key.toString());
- fail("IllegalArgumentException");
+ ManagementHelper.storeTypedProperty(msg, key, invalidType);
+ fail();
}
- catch (IllegalArgumentException e)
+ catch (Exception e)
{
}
- verify(msg);
+ assertFalse(msg.containsProperty(key));
}
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -1,273 +0,0 @@
-/*
- * 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.impl;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.easymock.classextension.EasyMock.replay;
-import static org.easymock.classextension.EasyMock.verify;
-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 java.util.ArrayList;
-import java.util.List;
-
-import org.easymock.classextension.EasyMock;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.management.impl.ConnectionFactoryControl;
-import org.jboss.messaging.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class ConnectionFactoryControlTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testGetName() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(name, control.getName());
-
- verify(cf);
- }
-
- public void testGetBindings() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(bindings, control.getBindings());
-
- verify(cf);
- }
-
- public void testGetClientID() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- String clientID = randomString();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- expect(cf.getClientID()).andReturn(clientID);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(clientID, control.getClientID());
-
- verify(cf);
- }
-
- public void testGetDefaultConsumerMaxRate() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- int rate = randomInt();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.getConsumerMaxRate()).andReturn(rate);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(rate, control.getDefaultConsumerMaxRate());
-
- verify(cf);
- }
-
- public void testGetDefaultConsumerWindowSize() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- int size = randomInt();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.getConsumerWindowSize()).andReturn(size);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(size, control.getDefaultConsumerWindowSize());
-
- verify(cf);
- }
-
- public void testGetDefaultProducerMaxRate() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- int rate = randomInt();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.getProducerMaxRate()).andReturn(rate);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(rate, control.getDefaultProducerMaxRate());
-
- verify(cf);
- }
-
- public void testGetDefaultProducerWindowSize() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- int size = randomInt();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.getProducerWindowSize()).andReturn(size);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(size, control.getDefaultProducerWindowSize());
-
- verify(cf);
- }
-
- public void testGetDupsOKBatchSize() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- int size = randomInt();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- expect(cf.getDupsOKBatchSize()).andReturn(size);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(size, control.getDupsOKBatchSize());
-
- verify(cf);
- }
-
- public void testIsDefaultBlockOnAcknowledge() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- boolean blockOnAcknowledge = randomBoolean();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.isBlockOnAcknowledge()).andReturn(blockOnAcknowledge);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(blockOnAcknowledge, control.isDefaultBlockOnAcknowledge());
-
- verify(cf);
- }
-
- public void testIsDefaultBlockOnNonPersistentSend() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- boolean blockOnNonPersistentSend = randomBoolean();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.isBlockOnNonPersistentSend()).andReturn(blockOnNonPersistentSend);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(blockOnNonPersistentSend, control
- .isDefaultBlockOnNonPersistentSend());
-
- verify(cf);
- }
-
- public void testIsDefaultBlockOnPersistentSend() throws Exception
- {
- String name = randomString();
- List<String> bindings = new ArrayList<String>();
- bindings.add(randomString());
- bindings.add(randomString());
- boolean blockOnPersistentSend = randomBoolean();
-
- JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
- EasyMock.expect(cf.isBlockOnPersistentSend()).andReturn(blockOnPersistentSend);
- replay(cf);
-
- ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
- name, bindings);
- assertEquals(blockOnPersistentSend, control
- .isDefaultBlockOnPersistentSend());
-
- verify(cf);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -1,583 +0,0 @@
-/*
- * 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.impl;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-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.randomPositiveInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import org.easymock.EasyMock;
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.messagecounter.MessageCounter;
-import org.jboss.messaging.core.persistence.StorageManager;
-import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.core.settings.impl.AddressSettings;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.server.management.impl.JMSQueueControl;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.utils.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class JMSQueueControlTest extends UnitTestCase
-{
- private String jndiBinding;
-
- private String name;
-
- private JBossQueue queue;
-
- private Queue coreQueue;
-
- private PostOffice postOffice;
-
- private StorageManager storageManager;
-
- private HierarchicalRepository<AddressSettings> addressSettingsRepository;
-
- private MessageCounter counter;
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testGetName() throws Exception
- {
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(name, control.getName());
-
- verifyMockedAttributes();
- }
-
- public void testGetAddress() throws Exception
- {
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(queue.getAddress(), control.getAddress());
-
- verifyMockedAttributes();
- }
-
- public void testGetJNDIBinding() throws Exception
- {
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(jndiBinding, control.getJNDIBinding());
-
- verifyMockedAttributes();
- }
-
- public void testIsTemporary() throws Exception
- {
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(queue.isTemporary(), control.isTemporary());
-
- verifyMockedAttributes();
- }
-
- public void testIsDurabled() throws Exception
- {
- boolean durable = randomBoolean();
-
- expect(coreQueue.isDurable()).andReturn(durable);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(durable, control.isDurable());
-
- verifyMockedAttributes();
- }
-
- public void testGetMessageCount() throws Exception
- {
- int count = randomInt();
-
- expect(coreQueue.getMessageCount()).andReturn(count);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(count, control.getMessageCount());
-
- verifyMockedAttributes();
- }
-
- public void testGetMessagesAdded() throws Exception
- {
- int count = randomInt();
-
- expect(coreQueue.getMessagesAdded()).andReturn(count);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(count, control.getMessagesAdded());
-
- verifyMockedAttributes();
- }
-
- public void testGetConsumerCount() throws Exception
- {
- int count = randomInt();
-
- expect(coreQueue.getConsumerCount()).andReturn(count);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(count, control.getConsumerCount());
-
- verifyMockedAttributes();
- }
-
- public void testGetDeliveringCount() throws Exception
- {
- int count = randomInt();
-
- expect(coreQueue.getDeliveringCount()).andReturn(count);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(count, control.getDeliveringCount());
-
- verifyMockedAttributes();
- }
-
- public void testGetScheduledCount() throws Exception
- {
- int count = randomInt();
-
- expect(coreQueue.getScheduledCount()).andReturn(count);
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(count, control.getScheduledCount());
-
- verifyMockedAttributes();
- }
-
- public void testGetDeadLetterAddress() throws Exception
- {
- final String deadLetterAddress = randomString();
-
- AddressSettings settings = new AddressSettings()
- {
- @Override
- public SimpleString getDeadLetterAddress()
- {
- return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + deadLetterAddress);
- }
- };
- expect(addressSettingsRepository.getMatch(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + name)).andReturn(settings);
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(settings.getDeadLetterAddress().toString(), control.getDeadLetterAddress());
-
- verifyMockedAttributes();
- }
-
- public void testGetExpiryAddress() throws Exception
- {
- final String expiryQueue = randomString();
-
- AddressSettings settings = new AddressSettings()
- {
- @Override
- public SimpleString getExpiryAddress()
- {
- return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + expiryQueue);
- }
- };
- expect(addressSettingsRepository.getMatch(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + name)).andReturn(settings);
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(settings.getExpiryAddress().toString(), control.getExpiryAddress());
-
- verifyMockedAttributes();
- }
-
- public void testRemoveMessage() throws Exception
- {
- String jmsMessageID = randomString();
- long messageID = randomLong();
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- ServerMessage message = createMock(ServerMessage.class);
- expect(message.getMessageID()).andReturn(messageID);
- expect(ref.getMessage()).andReturn(message);
- refs.add(ref);
- expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
- expect(coreQueue.deleteReference(messageID)).andReturn(true);
-
- replayMockedAttributes();
- replay(ref, message);
-
- JMSQueueControl control = createControl();
- assertTrue(control.removeMessage(jmsMessageID));
-
- verifyMockedAttributes();
- verify(ref, message);
- }
-
- public void testRemoveAllMessages() throws Exception
- {
- int removedMessagesCount = randomPositiveInt();
- expect(coreQueue.deleteAllReferences()).andReturn(removedMessagesCount);
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(removedMessagesCount, control.removeAllMessages());
-
- verifyMockedAttributes();
- }
-
- public void testListMessages() throws Exception
- {
- String filterStr = "color = 'green'";
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- 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());
- expect(message.getPropertyNames()).andStubReturn(new HashSet<SimpleString>());
- expect(ref.getMessage()).andReturn(message);
- refs.add(ref);
- expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
-
- replayMockedAttributes();
- replay(ref, message);
-
- JMSQueueControl control = createControl();
- TabularData data = control.listMessages(filterStr);
- assertEquals(1, data.size());
- CompositeData info = data.get(new Object[] { message.getProperty(new SimpleString("JMSMessageID")).toString() });
- assertNotNull(info);
-
- verifyMockedAttributes();
- verify(ref, message);
- }
-
- public void testListMessagesThrowsException() throws Exception
- {
- String invalidFilterStr = "this is not a valid filter";
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- try
- {
- control.listMessages(invalidFilterStr);
- fail("IllegalStateException");
- }
- catch (IllegalStateException e)
- {
-
- }
-
- verifyMockedAttributes();
- }
-
- public void testExpireMessage() throws Exception
- {
- String jmsMessageID = randomString();
- long messageID = randomLong();
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- ServerMessage serverMessage = createMock(ServerMessage.class);
- expect(serverMessage.getMessageID()).andReturn(messageID);
- expect(ref.getMessage()).andReturn(serverMessage);
- refs.add(ref);
- expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
- expect(coreQueue.expireMessage(messageID)).andReturn(true);
-
- replayMockedAttributes();
- replay(ref, serverMessage);
-
- JMSQueueControl control = createControl();
- assertTrue(control.expireMessage(jmsMessageID));
-
- verifyMockedAttributes();
- verify(ref, serverMessage);
- }
-
- public void testExpireMessageWithNoJMSMesageID() throws Exception
- {
- String jmsMessageID = randomString();
-
- expect(coreQueue.list(isA(Filter.class))).andReturn(new ArrayList<MessageReference>());
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- try
- {
- control.expireMessage(jmsMessageID);
- fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- verifyMockedAttributes();
- }
-
- public void testExpireMessages() throws Exception
- {
- int expiredMessages = randomInt();
-
- expect(coreQueue.expireMessages(isA(Filter.class))).andReturn(expiredMessages);
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- assertEquals(expiredMessages, control.expireMessages("color = 'green'"));
-
- verifyMockedAttributes();
- }
-
- public void testSendMessageToDLQ() throws Exception
- {
- String jmsMessageID = randomString();
- long messageID = randomLong();
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- ServerMessage serverMessage = createMock(ServerMessage.class);
- expect(serverMessage.getMessageID()).andReturn(messageID);
- expect(ref.getMessage()).andReturn(serverMessage);
- refs.add(ref);
- expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
- expect(coreQueue.sendMessageToDeadLetterAddress(messageID)).andReturn(true);
-
- replayMockedAttributes();
- replay(ref, serverMessage);
-
- JMSQueueControl control = createControl();
- assertTrue(control.sendMessageToDLQ(jmsMessageID));
-
- verifyMockedAttributes();
- verify(ref, serverMessage);
- }
-
- public void testSendMessageToDLQWithNoJMSMessageID() throws Exception
- {
- String jmsMessageID = randomString();
-
- expect(coreQueue.list(isA(Filter.class))).andReturn(new ArrayList<MessageReference>());
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- try
- {
- control.sendMessageToDLQ(jmsMessageID);
- fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- verifyMockedAttributes();
- }
-
- public void testChangeMessagePriority() throws Exception
- {
- byte newPriority = 5;
- String jmsMessageID = randomString();
- long messageID = randomLong();
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- ServerMessage serverMessage = createMock(ServerMessage.class);
- expect(serverMessage.getMessageID()).andReturn(messageID);
- expect(ref.getMessage()).andReturn(serverMessage);
- refs.add(ref);
- expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
- expect(coreQueue.changeMessagePriority(messageID,
- newPriority)).andReturn(true);
-
- replayMockedAttributes();
- replay(ref, serverMessage);
-
- JMSQueueControl control = createControl();
- assertTrue(control.changeMessagePriority(jmsMessageID, newPriority));
-
- verifyMockedAttributes();
- verify(ref, serverMessage);
- }
-
- public void testChangeMessagePriorityWithInvalidPriorityValues() throws Exception
- {
- String jmsMessageID = randomString();
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- try
- {
- control.changeMessagePriority(jmsMessageID, -1);
- fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- try
- {
- control.changeMessagePriority(jmsMessageID, 10);
- fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- verifyMockedAttributes();
- }
-
- public void testChangeMessagePriorityWithNoJMSMessageID() throws Exception
- {
- byte newPriority = 5;
- String jmsMessageID = randomString();
-
- expect(coreQueue.list(isA(Filter.class))).andReturn(new ArrayList<MessageReference>());
-
- replayMockedAttributes();
-
- JMSQueueControl control = createControl();
- try
- {
- control.changeMessagePriority(jmsMessageID, newPriority);
- fail("IllegalArgumentException");
- }
- catch (IllegalArgumentException e)
- {
- }
-
- verifyMockedAttributes();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- jndiBinding = randomString();
- name = randomString();
-
- queue = new JBossQueue(name);
- coreQueue = createMock(Queue.class);
- postOffice = createMock(PostOffice.class);
- storageManager = createMock(StorageManager.class);
- addressSettingsRepository = createMock(HierarchicalRepository.class);
- counter = new MessageCounter(name, null, coreQueue, false, true, 10);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- jndiBinding = null;
- name = null;
- queue = null;
- coreQueue = null;
- postOffice = null;
- storageManager = null;
- addressSettingsRepository = null;
- counter = null;
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- private JMSQueueControl createControl() throws NotCompliantMBeanException
- {
- return new JMSQueueControl(queue,
- coreQueue,
- jndiBinding,
- postOffice,
- addressSettingsRepository,
- counter);
- }
-
- private void replayMockedAttributes()
- {
- replay(coreQueue, postOffice, storageManager, addressSettingsRepository);
- }
-
- private void verifyMockedAttributes()
- {
- verify(coreQueue, postOffice, storageManager, addressSettingsRepository);
- }
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java 2009-03-18 14:39:07 UTC (rev 6105)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java 2009-03-18 15:22:19 UTC (rev 6106)
@@ -1,376 +0,0 @@
-/*
- * 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.impl;
-
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import org.jboss.messaging.core.persistence.StorageManager;
-import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.jms.JBossTopic;
-import org.jboss.messaging.jms.server.management.impl.TopicControl;
-import org.jboss.messaging.tests.util.UnitTestCase;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class TopicControlTest extends UnitTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testGetName() throws Exception
- {
- String jndiBinding = randomString();
- String name = randomString();
-
- JBossTopic topic = new JBossTopic(name);
- PostOffice postOffice = createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.class);
-
- replay(postOffice, storageManager);
-
- TopicControl control = new TopicControl(topic, jndiBinding, postOffice);
- assertEquals(name, control.getName());
-
- verify(postOffice, storageManager);
- }
-
- public void testGetAddress() throws Exception
- {
- String jndiBinding = randomString();
- String name = randomString();
-
- JBossTopic topic = new JBossTopic(name);
- PostOffice postOffice = createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.class);
-
- replay(postOffice, storageManager);
-
- TopicControl control = new TopicControl(topic, jndiBinding, postOffice);
- assertEquals(topic.getAddress(), control.getAddress());
-
- verify(postOffice, storageManager);
- }
-
- public void testGetJNDIBinding() throws Exception
- {
- String jndiBinding = randomString();
- String name = randomString();
-
- JBossTopic topic = new JBossTopic(name);
- PostOffice postOffice = createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.class);
-
- replay(postOffice, storageManager);
-
- TopicControl control = new TopicControl(topic, jndiBinding, postOffice);
- assertEquals(jndiBinding, control.getJNDIBinding());
-
- verify(postOffice, storageManager);
- }
-
- public void testIsTemporary() throws Exception
- {
- String jndiBinding = randomString();
- String name = randomString();
-
- JBossTopic topic = new JBossTopic(name);
- PostOffice postOffice = createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.class);
-
- replay(postOffice, storageManager);
-
- TopicControl control = new TopicControl(topic, jndiBinding, postOffice);
- assertEquals(topic.isTemporary(), control.isTemporary());
-
- verify(postOffice, storageManager);
- }
-
- // public void testGetMessageCount() throws Exception
- // {
- // String jndiBinding = randomString();
- // String name = randomString();
- //
- // int countForNonDurableQueue = randomInt();
- // int countForDurableQueue_1 = randomInt();
- // int countForDurableQueue_2 = randomInt();
- //
- // JBossTopic topic = new JBossTopic(name);
- // PostOffice postOffice = createMock(PostOffice.class);
- // StorageManager storageManager = createMock(StorageManager.class);
- //
- // Queue nonDurableQueue = createMock(Queue.class);
- // expect(nonDurableQueue.isDurable()).andStubReturn(false);
- // expect(nonDurableQueue.getMessageCount()).andStubReturn(
- // countForNonDurableQueue);
- // Binding bindingForNonDurableQueue = createMock(Binding.class);
- // expect(bindingForNonDurableQueue.getQueue()).andStubReturn(
- // nonDurableQueue);
- //
- // Queue durableQueue_1 = createMock(Queue.class);
- // expect(durableQueue_1.isDurable()).andStubReturn(true);
- // expect(durableQueue_1.getMessageCount()).andStubReturn(
- // countForDurableQueue_1);
- // Binding bindingForDurableQueue_1 = createMock(Binding.class);
- // expect(bindingForDurableQueue_1.getQueue()).andStubReturn(durableQueue_1);
- //
- // Queue durableQueue_2 = createMock(Queue.class);
- // expect(durableQueue_2.isDurable()).andStubReturn(true);
- // expect(durableQueue_2.getMessageCount()).andStubReturn(
- // countForDurableQueue_2);
- // Binding bindingForDurableQueue_2 = createMock(Binding.class);
- // expect(bindingForDurableQueue_2.getQueue()).andStubReturn(durableQueue_2);
- //
- // Bindings bindings = new BindingsImpl();
- // bindings.addBinding(bindingForNonDurableQueue);
- // bindings.addBinding(bindingForDurableQueue_1);
- // bindings.addBinding(bindingForDurableQueue_2);
- // expect(postOffice.getBindingsForAddress(topic.getSimpleAddress()))
- // .andStubReturn(bindings);
- // replay(postOffice, storageManager, bindingForNonDurableQueue,
- // nonDurableQueue, bindingForDurableQueue_1, durableQueue_1,
- // bindingForDurableQueue_2, durableQueue_2);
- //
- // TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- // storageManager);
- // assertEquals(countForNonDurableQueue + countForDurableQueue_1
- // + countForDurableQueue_2, control.getMessageCount());
- // assertEquals(countForDurableQueue_1 + countForDurableQueue_2, control
- // .getDurableMessagesCount());
- // assertEquals(countForNonDurableQueue, control.getNonDurableMessagesCount());
- //
- // verify(postOffice, storageManager, bindingForNonDurableQueue,
- // nonDurableQueue, bindingForDurableQueue_1, durableQueue_1,
- // bindingForDurableQueue_2, durableQueue_2);
- // }
- //
- // public void testGetSubcriptionsCount() throws Exception
- // {
- // String jndiBinding = randomString();
- // String name = randomString();
- //
- // JBossTopic topic = new JBossTopic(name);
- // PostOffice postOffice = createMock(PostOffice.class);
- // StorageManager storageManager = createMock(StorageManager.class);
- //
- // Queue nonDurableQueue = createMock(Queue.class);
- // expect(nonDurableQueue.isDurable()).andStubReturn(false);
- // Binding bindingForNonDurableQueue = createMock(Binding.class);
- // expect(bindingForNonDurableQueue.getQueue()).andStubReturn(
- // nonDurableQueue);
- //
- // Queue durableQueue_1 = createMock(Queue.class);
- // expect(durableQueue_1.isDurable()).andStubReturn(true);
- // Binding bindingForDurableQueue_1 = createMock(Binding.class);
- // expect(bindingForDurableQueue_1.getQueue()).andStubReturn(durableQueue_1);
- //
- // Queue durableQueue_2 = createMock(Queue.class);
- // expect(durableQueue_2.isDurable()).andStubReturn(true);
- // Binding bindingForDurableQueue_2 = createMock(Binding.class);
- // expect(bindingForDurableQueue_2.getQueue()).andStubReturn(durableQueue_2);
- //
- // List<Binding> bindings = new ArrayList<Binding>();
- // bindings.add(bindingForNonDurableQueue);
- // bindings.add(bindingForDurableQueue_1);
- // bindings.add(bindingForDurableQueue_2);
- // expect(postOffice.getBindingsForAddress(topic.getSimpleAddress()))
- // .andStubReturn(bindings);
- // replay(postOffice, storageManager, bindingForNonDurableQueue,
- // nonDurableQueue, bindingForDurableQueue_1, durableQueue_1,
- // bindingForDurableQueue_2, durableQueue_2);
- //
- // TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- // storageManager);
- // assertEquals(3, control.getSubcriptionsCount());
- // assertEquals(2, control.getDurableSubcriptionsCount());
- // assertEquals(1, control.getNonDurableSubcriptionsCount());
- //
- // verify(postOffice, storageManager, bindingForNonDurableQueue,
- // nonDurableQueue, bindingForDurableQueue_1, durableQueue_1,
- // bindingForDurableQueue_2, durableQueue_2);
- // }
- //
- // public void testRemoveAllMessages() throws Exception
- // {
- // String jndiBinding = randomString();
- // String name = randomString();
- // int removedMessagesFromQueue1 = randomPositiveInt();
- // int removedMessagesFromQueue2 = randomPositiveInt();
- //
- // JBossTopic topic = new JBossTopic(name);
- // PostOffice postOffice = createMock(PostOffice.class);
- // StorageManager storageManager = createMock(StorageManager.class);
- //
- // Queue queue_1 = createMock(Queue.class);
- // Binding bindingforQueue_1 = createMock(Binding.class);
- // expect(bindingforQueue_1.getQueue()).andStubReturn(queue_1);
- //
- // Queue queue_2 = createMock(Queue.class);
- // Binding bindingForQueue_2 = createMock(Binding.class);
- // expect(bindingForQueue_2.getQueue()).andStubReturn(queue_2);
- //
- // List<Binding> bindings = new ArrayList<Binding>();
- // bindings.add(bindingforQueue_1);
- // bindings.add(bindingForQueue_2);
- // expect(postOffice.getBindingsForAddress(topic.getSimpleAddress()))
- // .andStubReturn(bindings);
- // expect(queue_1.deleteAllReferences(storageManager)).andReturn(removedMessagesFromQueue1);
- // expect(queue_2.deleteAllReferences(storageManager)).andReturn(removedMessagesFromQueue2);
- //
- // replay(postOffice, storageManager, bindingforQueue_1, queue_1,
- // bindingForQueue_2, queue_2);
- //
- // TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- // storageManager);
- // assertEquals(removedMessagesFromQueue1 + removedMessagesFromQueue2, control.removeAllMessages());
- //
- // verify(postOffice, storageManager, bindingforQueue_1, queue_1,
- // bindingForQueue_2, queue_2);
- // }
- //
- // public void testListSubscriptionInfos() throws Exception
- // {
- // String jndiBinding = randomString();
- // String name = randomString();
- //
- // JBossTopic topic = new JBossTopic(name);
- // PostOffice postOffice = createMock(PostOffice.class);
- // StorageManager storageManager = createMock(StorageManager.class);
- //
- // Queue durableQueue = createMock(Queue.class);
- // expect(durableQueue.getName()).andStubReturn(
- // JBossTopic.createAddressFromName(randomString()));
- // expect(durableQueue.getFilter()).andStubReturn(null);
- // expect(durableQueue.isDurable()).andStubReturn(true);
- // expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
- // Binding bindingForDurableQueue = createMock(Binding.class);
- // expect(bindingForDurableQueue.getQueue()).andStubReturn(durableQueue);
- //
- // Queue nonDurableQueue = createMock(Queue.class);
- // expect(nonDurableQueue.getName()).andStubReturn(
- // JBossTopic.createAddressFromName(randomString()));
- // expect(nonDurableQueue.getFilter()).andStubReturn(null);
- // expect(nonDurableQueue.isDurable()).andStubReturn(false);
- // expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
- // Binding bindingForNonDurableQueue = createMock(Binding.class);
- // expect(bindingForNonDurableQueue.getQueue()).andStubReturn(nonDurableQueue);
- // List<Binding> bindings = new ArrayList<Binding>();
- // bindings.add(bindingForDurableQueue);
- // bindings.add(bindingForNonDurableQueue);
- // expect(postOffice.getBindingsForAddress(topic.getSimpleAddress()))
- // .andStubReturn(bindings);
- // replay(postOffice, storageManager, bindingForDurableQueue, durableQueue,
- // bindingForNonDurableQueue, nonDurableQueue);
- //
- // TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- // storageManager);
- // SubscriptionInfo[] infos = control.listAllSubscriptionInfos();
- // assertEquals(2, infos.length);
- // infos = control.listDurableSubscriptionInfos();
- // assertEquals(1, infos.length);
- // assertEquals(durableQueue.getName().toString(), infos[0].getQueueName());
- // infos = control.listNonDurableSubscriptionInfos();
- // assertEquals(1, infos.length);
- // assertEquals(nonDurableQueue.getName().toString(), infos[0].getQueueName());
- //
- // verify(postOffice, storageManager, bindingForDurableQueue, durableQueue,
- // bindingForNonDurableQueue, nonDurableQueue);
- // }
- //
- // public void testListSubscriptions() throws Exception
- // {
- // String jndiBinding = randomString();
- // String name = randomString();
- //
- //
- // QueueSettings settings = new QueueSettings();
- //
- // JBossTopic topic = new JBossTopic(name);
- // PostOffice postOffice = createMock(PostOffice.class);
- // StorageManager storageManager = createMock(StorageManager.class);
- //
- // Queue durableQueue = createMock(Queue.class);
- // expect(durableQueue.getName()).andStubReturn(
- // JBossTopic.createAddressFromName(randomString()));
- // expect(durableQueue.getFilter()).andStubReturn(null);
- // expect(durableQueue.isDurable()).andStubReturn(true);
- // expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
- // Binding bindingForDurableQueue = createMock(Binding.class);
- // expect(bindingForDurableQueue.getQueue()).andStubReturn(durableQueue);
- //
- // Queue nonDurableQueue = createMock(Queue.class);
- // expect(nonDurableQueue.getName()).andStubReturn(
- // JBossTopic.createAddressFromName(randomString()));
- // expect(nonDurableQueue.getFilter()).andStubReturn(null);
- // expect(nonDurableQueue.isDurable()).andStubReturn(false);
- // expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
- // Binding bindingForNonDurableQueue = createMock(Binding.class);
- // expect(bindingForNonDurableQueue.getQueue()).andStubReturn(nonDurableQueue);
- //
- // List<Binding> bindings = new ArrayList<Binding>();
- // bindings.add(bindingForDurableQueue);
- // bindings.add(bindingForNonDurableQueue);
- // expect(postOffice.getBindingsForAddress(topic.getSimpleAddress()))
- // .andStubReturn(bindings);
- // replay(postOffice, storageManager, bindingForDurableQueue, durableQueue,
- // bindingForNonDurableQueue, nonDurableQueue);
- //
- // TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- // storageManager);
- // TabularData data = control.listAllSubscriptions();
- // assertEquals(2, data.size());
- // data = control.listDurableSubscriptions();
- // assertEquals(1, data.size());
- // CompositeData info = data.get(new String[] { durableQueue.getName()
- // .toString() });
- // assertNotNull(info);
- // data = control.listNonDurableSubscriptions();
- // assertEquals(1, data.size());
- // info = data.get(new String[] { nonDurableQueue.getName().toString() });
- // assertNotNull(info);
- //
- // verify(postOffice, storageManager, bindingForDurableQueue, durableQueue,
- // bindingForNonDurableQueue, nonDurableQueue);
- // }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
More information about the jboss-cvs-commits
mailing list