[jboss-cvs] JBoss Messaging SVN: r4692 - in branches/Branch_JBMESSAGING-1303: src/main/org/jboss/messaging/core/management and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jul 18 09:20:57 EDT 2008


Author: jmesnil
Date: 2008-07-18 09:20:56 -0400 (Fri, 18 Jul 2008)
New Revision: 4692

Added:
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java
   branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java
   branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java
   branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java
Removed:
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/NotificationInfo.java
   branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingControlTest.java
Modified:
   branches/Branch_JBMESSAGING-1303/src/bin/run.sh
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/AddressControlMBean.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/ManagementRegistration.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/QueueControlMBean.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/RoleInfo.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/ManagementRegistrationImpl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementRegistration.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementRegistrationImpl.java
   branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
Log:
JBMESSAGING-1303: Revisit management interfaces
* added addRole/removeRole operations to AddressControlMBean
* added listMessages/deleteMessages to QueueControlMBean

Modified: branches/Branch_JBMESSAGING-1303/src/bin/run.sh
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/bin/run.sh	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/bin/run.sh	2008-07-18 13:20:56 UTC (rev 4692)
@@ -8,4 +8,4 @@
 echo ***********************************************************************************
 echo "java $JVM_ARGS -classpath $CLASSPATH org.jboss.jms.server.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml"
 echo ***********************************************************************************
-java $JVM_ARGS -classpath $CLASSPATH org.jboss.messaging.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml
\ No newline at end of file
+java $JVM_ARGS -classpath $CLASSPATH -Dcom.sun.management.jmxremote org.jboss.messaging.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml
\ No newline at end of file

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/AddressControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -34,7 +34,7 @@
 {
    // Attributes ----------------------------------------------------
 
-   String getName();
+   String getAddress();
 
    TabularData getRoles() throws Exception;
    
@@ -46,14 +46,14 @@
 
    @Operation(desc = "Add a Role to this address")
    void addRole(
-         @Parameter(name = "roleName", desc = "Name of the role to add") String roleName,
+         @Parameter(name = "name", desc = "Name of the role to add") String name,
          @Parameter(name = "create", desc = "Can the user create resource?") boolean create,
          @Parameter(name = "read", desc = "Can the user read from this address?") boolean read,
          @Parameter(name = "write", desc = "Can the user write from this address?") boolean write)
          throws Exception;
 
-   @Operation(desc = "Remove a Role to this address")
+   @Operation(desc = "Remove a Role from this address")
    void removeRole(
-         @Parameter(name = "roleName", desc = "Name of the role to remove") String roleName)
+         @Parameter(name = "name", desc = "Name of the role to remove") String name)
          throws Exception;
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/ManagementRegistration.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/ManagementRegistration.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/ManagementRegistration.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.management;
 
+import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.util.SimpleString;
 
@@ -42,7 +43,7 @@
 
    void unregisterAddress(String address) throws Exception;
 
-   void registerQueue(Queue queue, SimpleString address)
+   void registerQueue(Queue queue, SimpleString address, StorageManager storageManager)
          throws Exception;
 
    void unregisterQueue(SimpleString name, SimpleString address)

Added: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -0,0 +1,189 @@
+/*
+ * 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.core.management;
+
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.BYTE;
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessageInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final String MESSAGE_TYPE_NAME = "MessageInfo";
+   private static final String MESSAGE_TABULAR_TYPE_NAME = "MessageTabularInfo";
+   private static final TabularType TABULAR_TYPE;
+   private static final String[] ITEM_NAMES = new String[] { "id",
+         "destination", "durable", "timestamp", "type", "size", "priority",
+         "expired", "expiration" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "Message ID", "destination of the message", "Is the message durable?",
+         "Timestamp of the message", "Type of the message",
+         "Size of the encoded messag", "Priority of the message",
+         "Is the message expired?", "Expiration of the message" };
+   private static final OpenType[] ITEM_TYPES = new OpenType[] { LONG, STRING,
+         BOOLEAN, LONG, BYTE, INTEGER, BYTE, BOOLEAN, LONG };
+
+   static
+   {
+      try
+      {
+         TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+               "Information for a Message", ITEM_NAMES, ITEM_DESCRIPTIONS,
+               ITEM_TYPES);
+         TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+               "Table of MessageInfo", TYPE, new String[] { "id" });
+      } catch (OpenDataException e)
+      {
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final long id;
+   private final String destination;
+   private final boolean durable;
+   private final long timestamp;
+   private final byte type;
+   private final int size;
+   private final byte priority;
+   private final boolean expired;
+   private final long expiration;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(MessageInfo[] infos)
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (MessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   // Constructors --------------------------------------------------
+
+   public MessageInfo(long id, String destination, boolean durable,
+         long timestamp, byte type, int size, byte priority, boolean expired,
+         long expiration)
+   {
+      this.id = id;
+      this.destination = destination;
+      this.durable = durable;
+      this.timestamp = timestamp;
+      this.type = type;
+      this.size = size;
+      this.priority = priority;
+      this.expired = expired;
+      this.expiration = expiration;
+   }
+
+   // Public --------------------------------------------------------
+
+   public long getID()
+   {
+      return id;
+   }
+
+   public String getDestination()
+   {
+      return destination;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+
+   public long getTimestamp()
+   {
+      return timestamp;
+   }
+
+   public byte getType()
+   {
+      return type;
+   }
+
+   public int getSize()
+   {
+      return size;
+   }
+
+   public byte getPriority()
+   {
+      return priority;
+   }
+
+   public boolean isExpired()
+   {
+      return expired;
+   }
+
+   public long getExpiration()
+   {
+      return expiration;
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { id,
+               destination, durable, timestamp, type, size, priority, expired,
+               expiration });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -35,7 +35,6 @@
 /**
  * This interface describes the core management interface exposed by the server
  */
- at NotificationInfo(types = { "QUEUE_CREATED", "QUEUE_DESTROYED" }, desc = "Notifications emitted by a messaging server")
 public interface MessagingServerControlMBean
 {
    // Attributes ----------------------------------------------------

Deleted: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/NotificationInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/NotificationInfo.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/NotificationInfo.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -1,43 +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.core.management;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-
- at Retention(RetentionPolicy.RUNTIME)
- at Target(ElementType.TYPE)
-public @interface NotificationInfo
-{
-   String[] types();
-   String desc();
-}

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/QueueControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/QueueControlMBean.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/QueueControlMBean.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -18,29 +18,49 @@
  * 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.core.management;
 
+import static javax.management.MBeanOperationInfo.ACTION;
+import static javax.management.MBeanOperationInfo.INFO;
+
+import javax.management.openmbean.TabularData;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
+ * 
  * @version <tt>$Revision$</tt>
- *
+ * 
  */
 public interface QueueControlMBean
 {
+   // Attributes ----------------------------------------------------
+
    String getName();
-   
+
    boolean isClustered();
-   
+
    boolean isTemporary();
-   
+
    boolean isDurable();
-   
+
    String getFilter();
 
    int getMessageCount();
 
    int getMaxSizeBytes();
+
+   // Operations ----------------------------------------------------
+
+   @Operation(desc = "List all the messages in the queue", impact = INFO)
+   TabularData listAllMessages() throws Exception;
+
+   @Operation(desc = "List all the messages in the queue matching the given filter", impact = INFO)
+   TabularData listMessages(
+         @Parameter(name = "filter", desc = "A message filter") String filter)
+         throws Exception;
+   
+   @Operation(desc = "Remove all the messages from the queue", impact = ACTION)
+   void removeAllMessages() throws Exception;
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/RoleInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/RoleInfo.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/RoleInfo.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -25,8 +25,6 @@
 import static javax.management.openmbean.SimpleType.BOOLEAN;
 import static javax.management.openmbean.SimpleType.STRING;
 
-import java.util.Collection;
-
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeType;
@@ -46,10 +44,10 @@
 {
    // Constants -----------------------------------------------------
 
+   public static final CompositeType TYPE;
    private static final String ROLE_TYPE_NAME = "RoleInfo";
    private static final String ROLE_TABULAR_TYPE_NAME = "RoleTabularInfo";
-   private static final CompositeType ROLE_TYPE;
-   private static final TabularType ROLE_TABULAR_TYPE;
+   private static final TabularType TABULAR_TYPE;
    private static final String[] ITEM_NAMES = new String[] { "name", "create",
          "read", "write" };
    private static final String[] ITEM_DESCRIPTIONS = new String[] {
@@ -62,8 +60,10 @@
    {
       try
       {
-         ROLE_TYPE = getRoleInfoType();
-         ROLE_TABULAR_TYPE = createRoleInfoTabularType();
+         TYPE = new CompositeType(ROLE_TYPE_NAME, "Information for a Role",
+               ITEM_NAMES, ITEM_DESCRIPTIONS, ITEM_TYPES);
+         TABULAR_TYPE = new TabularType(ROLE_TABULAR_TYPE_NAME,
+               "Table of RoleInfo", TYPE, new String[] { "name" });
       } catch (OpenDataException e)
       {
          throw new IllegalStateException(e);
@@ -81,7 +81,7 @@
 
    public static TabularData toTabularData(RoleInfo[] infos)
    {
-      TabularData data = new TabularDataSupport(ROLE_TABULAR_TYPE);
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
       for (RoleInfo roleInfo : infos)
       {
          data.put(roleInfo.toCompositeData());
@@ -89,19 +89,6 @@
       return data;
    }
 
-   private static CompositeType getRoleInfoType() throws OpenDataException
-   {
-      return new CompositeType(ROLE_TYPE_NAME, "Information for a Role",
-            ITEM_NAMES, ITEM_DESCRIPTIONS, ITEM_TYPES);
-   }
-
-   private static TabularType createRoleInfoTabularType()
-         throws OpenDataException
-   {
-      return new TabularType(ROLE_TABULAR_TYPE_NAME, "Table of RoleInfo",
-            ROLE_TYPE, new String[] { "name" });
-   }
-
    // Constructors --------------------------------------------------
 
    public RoleInfo(String name, boolean create, boolean read, boolean write)
@@ -138,36 +125,14 @@
    {
       try
       {
-         return new CompositeDataSupport(ROLE_TYPE, ITEM_NAMES, new Object[] {
-               name, create, read, write });
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { name,
+               create, read, write });
       } catch (OpenDataException e)
       {
-         e.printStackTrace();
          return null;
       }
    }
 
-   public static RoleInfo[] fromTabularData(TabularData rolesTable)
-   {
-      if (!ROLE_TABULAR_TYPE.equals(rolesTable.getTabularType()))
-      {
-         return null;
-      }
-      
-      Collection<CompositeData> roles = rolesTable.values();
-      RoleInfo[] roleInfos = new RoleInfo[roles.size()];
-      int i = 0;
-      for (CompositeData role : roles)
-      {
-         String name = (String) role.get("name");
-         boolean create = (Boolean) role.get("create");
-         boolean read = (Boolean) role.get("read");
-         boolean write = (Boolean) role.get("write");
-         roleInfos[i] = new RoleInfo(name, create, read, write);
-      }
-      return roleInfos;
-   }
-
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.management.impl;
 
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -52,7 +53,7 @@
 
    // Attributes ----------------------------------------------------
 
-   private final String name;
+   private final String address;
    private MessagingServerManagement server;
 
    // Static --------------------------------------------------------
@@ -63,7 +64,7 @@
          throws NotCompliantMBeanException
    {
       super(AddressControlMBean.class);
-      this.name = address;
+      this.address = address;
       this.server = server;
    }
 
@@ -71,22 +72,24 @@
 
    // AddressControlMBean implementation ----------------------------
 
-   public String getName()
+   public String getAddress()
    {
-      return name;
+      return address;
    }
 
    public String[] getQueueNames() throws Exception
    {
-      try {
-      List<Queue> queues = server.getQueuesForAddress(new SimpleString(name));
-      String[] queueNames = new String[queues.size()];
-      for (int i = 0; i < queues.size(); i++)
+      try
       {
-         queueNames[i] = queues.get(i).getName().toString();
-      }
-      return queueNames;
-      } catch(Throwable t)
+         List<Queue> queues = server
+               .getQueuesForAddress(new SimpleString(address));
+         String[] queueNames = new String[queues.size()];
+         for (int i = 0; i < queues.size(); i++)
+         {
+            queueNames[i] = queues.get(i).getName().toString();
+         }
+         return queueNames;
+      } catch (Throwable t)
       {
          t.printStackTrace();
          return null;
@@ -100,7 +103,7 @@
 
    public RoleInfo[] getRoleInfos() throws Exception
    {
-      Set<Role> roles = server.getSecurityForAddress(name);
+      Set<Role> roles = server.getSecurityForAddress(address);
       RoleInfo[] roleInfos = new RoleInfo[roles.size()];
       int i = 0;
       for (Role role : roles)
@@ -113,13 +116,39 @@
       return roleInfos;
    }
 
-   public void addRole(String roleName, boolean create, boolean read,
+   public void addRole(String name, boolean create, boolean read,
          boolean write) throws Exception
    {
+      Set<Role> roles = server.getSecurityForAddress(address);
+      Role newRole = new Role(name, read, write, create);
+      boolean added = roles.add(newRole);
+      if (!added)
+      {
+         throw new IllegalArgumentException("Role " + name + " already exists");
+      }
+      server.setSecurityForAddress(name, roles);
    }
 
-   public void removeRole(String roleName) throws Exception
+   public void removeRole(String role) throws Exception
    {
+      Set<Role> roles = server.getSecurityForAddress(address);
+      Iterator<Role> it = roles.iterator();
+      boolean removed = false;
+      while (it.hasNext())
+      {
+         Role r = it.next();
+         if (r.getName().equals(role))
+         {
+            it.remove();
+            removed = true;
+            break;
+         }
+      }
+      if (!removed)
+      {
+         throw new IllegalArgumentException("Role " + role + " does not exist");
+      }
+      server.setSecurityForAddress(address, roles);
    }
 
    // StandardMBean overrides ---------------------------------------

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -27,11 +27,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.MBeanParameterInfo;
 
-import org.jboss.messaging.core.management.NotificationInfo;
 import org.jboss.messaging.core.management.Operation;
 import org.jboss.messaging.core.management.Parameter;
 
@@ -53,29 +51,6 @@
 
    // Public --------------------------------------------------------
 
-   public static MBeanNotificationInfo[] getMBeanNotificationsInfo(
-         Class mbeanInterface)
-   {
-      String[] types = new String[0];
-      String description = "";
-      String name = "foo";
-      Annotation anno = mbeanInterface.getAnnotation(NotificationInfo.class);
-      if (anno != null && NotificationInfo.class.isInstance(anno))
-      {
-         types = NotificationInfo.class.cast(anno).types();
-         description = NotificationInfo.class.cast(anno).desc();
-      }
-
-      if (types.length > 0)
-      {
-         return new MBeanNotificationInfo[] { new MBeanNotificationInfo(types,
-               name, description) };
-      } else
-      {
-         return new MBeanNotificationInfo[0];
-      }
-   }
-
    public static MBeanOperationInfo[] getMBeanOperationsInfo(
          Class mbeanInterface)
    {

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/ManagementRegistrationImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/ManagementRegistrationImpl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/ManagementRegistrationImpl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -30,6 +30,7 @@
 import org.jboss.messaging.core.management.ManagementRegistration;
 import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.util.SimpleString;
 
@@ -134,7 +135,7 @@
       mbeanServer.unregisterMBean(getAddressObjectName(address));
    }
 
-   public void registerQueue(Queue queue, SimpleString address)
+   public void registerQueue(Queue queue, SimpleString address, StorageManager storageManager)
          throws Exception
    {
       ObjectName objectName = getQueueObjectName(address, queue.getName());
@@ -144,7 +145,7 @@
                + " is already registered. Unregister it");
          mbeanServer.unregisterMBean(objectName);
       }
-      QueueControlMBean queueControl = new QueueControl(queue);
+      QueueControlMBean queueControl = new QueueControl(queue, storageManager);
       mbeanServer.registerMBean(queueControl, objectName);
       if (log.isDebugEnabled())
       {

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -40,7 +40,6 @@
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.management.MessagingServerControlMBean;
 import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.management.NotificationType;
 import org.jboss.messaging.core.management.RoleInfo;
 import org.jboss.messaging.core.security.CheckType;
 import org.jboss.messaging.core.security.Role;
@@ -83,13 +82,6 @@
 
    // Public --------------------------------------------------------
 
-   void sendNotification(NotificationType type, String message)
-   {
-      Notification notif = new Notification(type.toString(), this, notifSeq
-            .incrementAndGet(), message);
-      broadcaster.sendNotification(notif);
-   }
-
    // StandardMBean overrides ---------------------------------------
 
    /*
@@ -106,8 +98,7 @@
       return new MBeanInfo(info.getClassName(), info.getDescription(), info
             .getAttributes(), info.getConstructors(), MBeanInfoHelper
             .getMBeanOperationsInfo(MessagingServerControlMBean.class),
-            MBeanInfoHelper
-                  .getMBeanNotificationsInfo(MessagingServerControlMBean.class));
+            getNotificationInfo());
    }
 
    // ManagedMessagingServerMBean implementation --------------------
@@ -343,8 +334,14 @@
 
    public MBeanNotificationInfo[] getNotificationInfo()
    {
-      return MBeanInfoHelper
-            .getMBeanNotificationsInfo(MessagingServerControlMBean.class);
+      NotificationType[] values = NotificationType.values();
+      String[] names = new String[values.length];
+      for (int i = 0; i < values.length; i++)
+      {
+         names[i] = values[i].toString();
+      }
+      return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
+            this.getClass().getName(), "Notifications emitted by a Core Server") };
    }
 
    // Package protected ---------------------------------------------
@@ -353,5 +350,17 @@
 
    // Private -------------------------------------------------------
 
+   private void sendNotification(NotificationType type, String message)
+   {
+      Notification notif = new Notification(type.toString(), this, notifSeq
+            .incrementAndGet(), message);
+      broadcaster.sendNotification(notif);
+   }
+   
    // Inner classes -------------------------------------------------
+   
+   private enum NotificationType
+   {
+      QUEUE_CREATED, QUEUE_DESTROYED, ROLE_ADDED, ROLE_REMOVED, ADDRESS_ADDED, ADDRESS_REMOVED;
+   }
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/QueueControl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/QueueControl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -22,12 +22,23 @@
 
 package org.jboss.messaging.core.management.impl;
 
+import java.util.List;
+
+import javax.management.MBeanInfo;
 import javax.management.NotCompliantMBeanException;
 import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
 
+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.MessageInfo;
 import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.persistence.StorageManager;
+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.util.SimpleString;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -43,20 +54,23 @@
    // Attributes ----------------------------------------------------
 
    private final Queue queue;
+   private final StorageManager storageManager;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
-   public QueueControl(Queue queue) throws NotCompliantMBeanException
+   public QueueControl(Queue queue, StorageManager storageManager)
+         throws NotCompliantMBeanException
    {
       super(QueueControlMBean.class);
       this.queue = queue;
+      this.storageManager = storageManager;
    }
 
    // Public --------------------------------------------------------
 
-   // ManagedQueueMBean implementation ------------------------------
+   // QueueControlMBean implementation ------------------------------
 
    public String getName()
    {
@@ -83,17 +97,71 @@
    {
       return queue.isTemporary();
    }
-   
+
    public int getMessageCount()
    {
       return queue.getMessageCount();
    }
-   
+
    public int getMaxSizeBytes()
    {
       return queue.getMaxSizeBytes();
    }
 
+   public TabularData listAllMessages() throws Exception
+   {
+      return listMessages(null);
+   }
+
+   public TabularData listMessages(String filterStr) throws Exception
+   {
+      try
+      {
+         Filter filter = filterStr == null ? null : new FilterImpl(
+               new SimpleString(filterStr));
+         List<MessageReference> refs = queue.list(filter);
+         MessageInfo[] infos = new MessageInfo[refs.size()];
+         for (int i = 0; i < refs.size(); i++)
+         {
+            MessageReference ref = refs.get(i);
+            ServerMessage message = ref.getMessage();
+            MessageInfo info = new MessageInfo(message.getMessageID(), message
+                  .getDestination().toString(), message.isDurable(), message
+                  .getTimestamp(), message.getType(), message.getEncodeSize(),
+                  message.getPriority(), message.isExpired(), message
+                        .getExpiration());
+            infos[i] = info;
+         }
+         return MessageInfo.toTabularData(infos);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public void removeAllMessages() throws Exception
+   {
+      try
+      {
+         queue.deleteAllReferences(storageManager);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   // StandardMBean overrides ---------------------------------------
+
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(QueueControlMBean.class), info
+            .getNotifications());
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -529,7 +529,7 @@
 				
 				if (managementRegistration != null)
 				{
-				   managementRegistration.registerQueue(queue, address);
+				   managementRegistration.registerQueue(queue, address, this);
 				}
 
 				bindings.add(binding);      

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -295,7 +295,7 @@
       {
          try
          {
-            managementRegistration.registerQueue(queue, address);
+            managementRegistration.registerQueue(queue, address, storageManager);
          } catch (Exception e)
          {
             e.printStackTrace();

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -25,9 +25,7 @@
 import java.io.Serializable;
 import java.util.List;
 
-import org.jboss.messaging.core.management.MessagingServerManagement;
 
-
 /**
  * The JMS Management interface.
  *
@@ -398,9 +396,4 @@
 //    * @throws Exception if a problem occurred
 //    */
 //   List<MessageStatistics> getStatistics() throws Exception;
-
-   /**
-    * @return
-    */
-   MessagingServerManagement getMessagingServerManagement();
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -128,11 +128,6 @@
    }
 
    // management operations
-
-   public MessagingServerManagement getMessagingServerManagement()
-   {
-      return messagingServerManagement;
-   }
    
    public boolean isStarted()
    {
@@ -162,7 +157,7 @@
       {
          addToDestinationBindings(topicName, jndiBinding);
       }
-      managementRegistration.registerTopic(jBossTopic);
+      managementRegistration.registerTopic(jBossTopic, messagingServerManagement);
       return added;
    }
 

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementRegistration.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementRegistration.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementRegistration.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.jms.server.management;
 
+import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.jms.JBossQueue;
 import org.jboss.messaging.jms.JBossTopic;
@@ -43,7 +44,7 @@
 
    void unregisterQueue(String name) throws Exception;
 
-   void registerTopic(JBossTopic topic) throws Exception;
+   void registerTopic(JBossTopic topic, MessagingServerManagement serverManagement) throws Exception;
 
    void unregisterTopic(String name) throws Exception;
 }

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementRegistrationImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementRegistrationImpl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementRegistrationImpl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -25,6 +25,7 @@
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.management.impl.ManagementRegistrationImpl;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.jms.JBossQueue;
@@ -113,14 +114,15 @@
       mbeanServer.unregisterMBean(getJMSQueueObjectName(name));
    }
 
-   public void registerTopic(JBossTopic topic) throws Exception
+   public void registerTopic(JBossTopic topic,
+         MessagingServerManagement serverManagement) throws Exception
    {
       ObjectName objectName = getJMSTopicObjectName(topic.getTopicName());
       if (mbeanServer.isRegistered(objectName))
       {
          mbeanServer.unregisterMBean(objectName);
       }
-      mbeanServer.registerMBean(new TopicControl(topic, jmsServer.getMessagingServerManagement()), objectName);
+      mbeanServer.registerMBean(new TopicControl(topic, serverManagement), objectName);
    }
 
    public void unregisterTopic(String name) throws Exception

Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -205,7 +205,7 @@
 
    // Private -------------------------------------------------------
 
-   void sendNotification(NotificationType type, String message)
+   private void sendNotification(NotificationType type, String message)
    {
       Notification notif = new Notification(type.toString(), this, notifSeq
             .incrementAndGet(), message);

Added: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -0,0 +1,113 @@
+/*
+ * 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.core.management;
+
+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.randomString;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.MessageInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessageInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertEquals(MessageInfo expected, CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(MessageInfo.TYPE));
+
+      assertEquals(expected.getID(), actual.get("id"));
+      assertEquals(expected.getDestination(), actual.get("destination"));
+      assertEquals(expected.isDurable(), actual.get("durable"));
+      assertEquals(expected.getTimestamp(), actual.get("timestamp"));
+      assertEquals(expected.getType(), actual.get("type"));
+      assertEquals(expected.getSize(), actual.get("size"));
+      assertEquals(expected.getPriority(), actual.get("priority"));
+      assertEquals(expected.isExpired(), actual.get("expired"));
+      assertEquals(expected.getExpiration(), actual.get("expiration"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      MessageInfo info = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      CompositeData data = info.toCompositeData();
+
+      assertEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      MessageInfo info_1 = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      MessageInfo info_2 = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      MessageInfo[] messages = new MessageInfo[] { info_1, info_2 };
+
+      TabularData data = MessageInfo.toTabularData(messages);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data.get(new Object[] { info_1.getID() });
+      CompositeData data_2 = data.get(new Object[] { info_2.getID() });
+
+      assertEquals(info_1, data_1);
+      assertEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyMessages() throws Exception
+   {
+      TabularData data = MessageInfo.toTabularData(new MessageInfo[0]);
+      assertEquals(0, data.size());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -0,0 +1,106 @@
+/*
+ * 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.core.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.RoleInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class RoleInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertEquals(RoleInfo expected, CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(RoleInfo.TYPE));
+
+      assertEquals(expected.getName(), actual.get("name"));
+      assertEquals(expected.isCreate(), actual.get("create"));
+      assertEquals(expected.isRead(), actual.get("read"));
+      assertEquals(expected.isWrite(), actual.get("write"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      String name = randomString();
+      boolean create = randomBoolean();
+      boolean read = randomBoolean();
+      boolean write = randomBoolean();
+
+      RoleInfo info = new RoleInfo(name, create, read, write);
+      CompositeData data = info.toCompositeData();
+
+      assertEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      RoleInfo info_1 = new RoleInfo(randomString(), randomBoolean(),
+            randomBoolean(), randomBoolean());
+      RoleInfo info_2 = new RoleInfo(randomString(), randomBoolean(),
+            randomBoolean(), randomBoolean());
+      RoleInfo[] roles = new RoleInfo[] { info_1, info_2 };
+
+      TabularData data = RoleInfo.toTabularData(roles);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data.get(new String[] { info_1.getName() });
+      CompositeData data_2 = data.get(new String[] { info_2.getName() });
+
+      assertEquals(info_1, data_1);
+      assertEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyRoles() throws Exception
+   {
+      TabularData data = RoleInfo.toTabularData(new RoleInfo[0]);
+      assertEquals(0, data.size());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingControlTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingControlTest.java	2008-07-17 20:47:53 UTC (rev 4691)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingControlTest.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -1,96 +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.core.management.impl;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.management.impl.MessagingServerControl;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * t
- * 
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class MessagingControlTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testGetServerID() throws Exception
-   {
-      int serverID = randomInt();
-
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Configuration configuration = createMock(Configuration.class);
-      expect(configuration.getServerID()).andStubReturn(serverID);
-      replay(server, configuration);
-
-      MessagingServerControl control = new MessagingServerControl(server, configuration);
-      assertEquals(serverID, control.getServerID());
-
-      verify(server, configuration);
-   }
-
-   public void testCreateQueue() throws Exception
-   {
-      String address = randomString();
-      String name = randomString();
-
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Configuration configuration = createMock(Configuration.class);
-      server.createQueue(new SimpleString(address), new SimpleString(name));
-      replay(server, configuration);
-
-      MessagingServerControl control = new MessagingServerControl(server, configuration);
-      control.createQueue(address, name);
-
-      verify(server, configuration);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java (from rev 4686, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingControlTest.java)
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	2008-07-18 13:20:56 UTC (rev 4692)
@@ -0,0 +1,96 @@
+/*
+ * 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.core.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.impl.MessagingServerControl;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * t
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessagingServerControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetServerID() throws Exception
+   {
+      int serverID = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getServerID()).andStubReturn(serverID);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server, configuration);
+      assertEquals(serverID, control.getServerID());
+
+      verify(server, configuration);
+   }
+
+   public void testCreateQueue() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name));
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server, configuration);
+      control.createQueue(address, name);
+
+      verify(server, configuration);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}


Property changes on: branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java
___________________________________________________________________
Name: svn:mergeinfo
   + 




More information about the jboss-cvs-commits mailing list