[jboss-cvs] JBoss Messaging SVN: r4485 - in trunk: src/main/org/jboss/messaging/core/client/impl and 17 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 16 12:13:48 EDT 2008


Author: timfox
Date: 2008-06-16 12:13:47 -0400 (Mon, 16 Jun 2008)
New Revision: 4485

Added:
   trunk/src/main/org/jboss/messaging/util/ExecutorFactory.java
   trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
Removed:
   trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
Modified:
   trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
   trunk/src/main/org/jboss/messaging/core/deployers/DeploymentManager.java
   trunk/src/main/org/jboss/messaging/core/deployers/impl/FileDeploymentManager.java
   trunk/src/main/org/jboss/messaging/core/journal/EncodingSupport.java
   trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   trunk/src/main/org/jboss/messaging/core/message/Message.java
   trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
   trunk/src/main/org/jboss/messaging/core/security/JBMSecurityManager.java
   trunk/src/main/org/jboss/messaging/core/security/SecurityStore.java
   trunk/src/main/org/jboss/messaging/core/security/impl/JAASSecurityManager.java
   trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
   trunk/src/main/org/jboss/messaging/util/TypedProperties.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossConnectionMetaDataTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossSessionTest.java
Log:
More tweaks


Modified: trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/SimpleExample.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -21,7 +21,7 @@
    */
 package org.jboss.messaging.example;
 
-import java.util.HashSet;
+import java.util.Set;
 
 import org.jboss.messaging.core.client.ClientConnection;
 import org.jboss.messaging.core.client.ClientConnectionFactory;
@@ -75,7 +75,7 @@
                return true;
             }
 
-            public boolean validateUserAndRole(String user, String password, HashSet<Role> roles, CheckType checkType)
+            public boolean validateUserAndRole(String user, String password, Set<Role> roles, CheckType checkType)
             {
                return true;
             }

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -176,7 +176,7 @@
                
                session.delivered(m.getDeliveryID(), expired);
                
-               flowControl(m.encodeSize());
+               flowControl(m.getEncodeSize());
                                  
                if (expired)
                {
@@ -339,7 +339,7 @@
 
             session.delivered(message.getDeliveryID(), expired);
             
-            flowControl(message.encodeSize());
+            flowControl(message.getEncodeSize());
 
             if (!expired)
             {
@@ -495,7 +495,7 @@
    
             session.delivered(message.getDeliveryID(), expired);
             
-            flowControl(message.encodeSize());
+            flowControl(message.getEncodeSize());
    
             if (!expired)
             {

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -242,7 +242,7 @@
       {
          try
          {
-            availableCredits.acquire(message.getClientMessage().encodeSize());
+            availableCredits.acquire(message.getClientMessage().getEncodeSize());
          }
          catch (InterruptedException e)
          {           

Modified: trunk/src/main/org/jboss/messaging/core/deployers/DeploymentManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/DeploymentManager.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/deployers/DeploymentManager.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -21,7 +21,6 @@
    */
 package org.jboss.messaging.core.deployers;
 
-import org.jboss.messaging.core.server.MessagingComponent;
 
 /**
  * This class manages any configuration files available. It will notify any deployers registered with it on changes.

Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/FileDeploymentManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/FileDeploymentManager.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/FileDeploymentManager.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -53,13 +53,13 @@
    private static ArrayList<URL> toUndeploy = new ArrayList<URL>();
    //the list of URL's to redeploy if changed
    private static ArrayList<URL> toRedeploy = new ArrayList<URL>();
+   
    private static ScheduledExecutorService scheduler;
 
    int currentWeight = 0;
 
-   public void start(int weight) throws Exception
+   public void start(final int weight) throws Exception
    {
-
       Collection<ConfigurationURL> configurations = getUnstartedConfigurations(weight);
       for (ConfigurationURL configuration : configurations)
       {
@@ -94,7 +94,7 @@
     * @param Deployer The Deployer object
     * @throws Exception .
     */
-   public void registerDeployer(Deployer Deployer) throws Exception
+   public void registerDeployer(final Deployer Deployer) throws Exception
    {
       synchronized (this)
       {
@@ -124,7 +124,7 @@
       }
    }
 
-   public void unregisterDeployer(Deployer Deployer)
+   public void unregisterDeployer(final Deployer Deployer)
    {
       deployers.remove(Deployer);
       if (deployers.size() == 0)
@@ -161,7 +161,7 @@
     * @return a set of configurationUrls
     * @throws java.io.IOException .
     */
-   private Collection<ConfigurationURL> getUnstartedConfigurations(int weight) throws IOException
+   private Collection<ConfigurationURL> getUnstartedConfigurations(final int weight) throws IOException
    {
       HashMap<String, ConfigurationURL> configurations = new HashMap<String, ConfigurationURL>();
       for (Deployer deployer : deployers)
@@ -185,27 +185,27 @@
    }
 
    private Collection<ConfigurationURL> getStartedConfigurations() throws IOException
+   {
+      HashMap<String, ConfigurationURL> configurations = new HashMap<String, ConfigurationURL>();
+      for (Deployer deployer : deployers)
       {
-         HashMap<String, ConfigurationURL> configurations = new HashMap<String, ConfigurationURL>();
-         for (Deployer deployer : deployers)
+         if (deployer.getWeight() <= currentWeight)
          {
-            if (deployer.getWeight() <= currentWeight)
+            Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(deployer.getConfigFileName());
+
+            if (!configurations.keySet().contains(deployer.getConfigFileName()))
             {
-               Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(deployer.getConfigFileName());
-
-               if (!configurations.keySet().contains(deployer.getConfigFileName()))
-               {
-                  ConfigurationURL conf = new ConfigurationURL(urls, deployer.getConfigFileName());
-                  configurations.put(deployer.getConfigFileName(), conf);
-               }
-               else
-               {
-                  configurations.get(deployer.getConfigFileName()).add(urls);
-               }
+               ConfigurationURL conf = new ConfigurationURL(urls, deployer.getConfigFileName());
+               configurations.put(deployer.getConfigFileName(), conf);
             }
+            else
+            {
+               configurations.get(deployer.getConfigFileName()).add(urls);
+            }
          }
-         return configurations.values();
       }
+      return configurations.values();
+   }
 
 
    /**
@@ -265,7 +265,7 @@
     *
     * @param url the url to undeploy
     */
-   private void undeploy(URL url)
+   private void undeploy(final URL url)
    {
       deployed.remove(url);
 
@@ -288,7 +288,7 @@
     *
     * @param url the url to redeploy
     */
-   private void redeploy(URL url)
+   private void redeploy(final URL url)
    {
       deployed.put(url, new File(url.getFile()).lastModified());
       for (Deployer Deployer : deployers)
@@ -311,7 +311,7 @@
     * @param url the url to deploy
     * @throws Exception .
     */
-   private void deploy(URL url)
+   private void deploy(final URL url)
            throws Exception
    {
       deployed.put(url, new File(url.getFile()).lastModified());
@@ -334,7 +334,7 @@
       private ArrayList<URL> urls = new ArrayList<URL>();
       private String configFileName;
 
-      public ConfigurationURL(Enumeration<URL> urls, String configFileName)
+      public ConfigurationURL(final Enumeration<URL> urls, final String configFileName)
       {
          while (urls.hasMoreElements())
          {
@@ -354,7 +354,7 @@
          return configFileName;
       }
 
-      public void add(Enumeration<URL> urls)
+      public void add(final Enumeration<URL> urls)
       {
          while (urls.hasMoreElements())
          {

Modified: trunk/src/main/org/jboss/messaging/core/journal/EncodingSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/EncodingSupport.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/journal/EncodingSupport.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -34,7 +34,7 @@
  */
 public interface EncodingSupport
 {
-   int encodeSize();
+   int getEncodeSize();
    
    void encode(MessagingBuffer buffer);
    

Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -270,7 +270,7 @@
          throw new IllegalStateException("Journal must be loaded first");
       }
       
-      int recordLength = record.encodeSize();
+      int recordLength = record.getEncodeSize();
       
       int size = SIZE_ADD_RECORD + recordLength;
       
@@ -385,7 +385,7 @@
          throw new IllegalStateException("Journal must be loaded first");
       }
       
-      int recordLength = record.encodeSize();
+      int recordLength = record.getEncodeSize();
       
       int size = SIZE_ADD_RECORD_TX + recordLength;
       

Modified: trunk/src/main/org/jboss/messaging/core/message/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/Message.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/message/Message.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -65,7 +65,7 @@
    
    void setPriority(byte priority);
    
-   int encodeSize();
+   int getEncodeSize();
 
    void encode(MessagingBuffer buffer);
    

Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -126,7 +126,7 @@
       buff.putBytes(body.array(), 0, body.limit());   
    }
    
-   public int encodeSize()
+   public int getEncodeSize()
    {
       return /* Destination */ SimpleString.sizeofString(destination) + 
       /* Type */ SIZE_BYTE + 
@@ -134,7 +134,7 @@
       /* Expiration */ SIZE_LONG + 
       /* Timestamp */ SIZE_LONG + 
       /* Priority */ SIZE_BYTE + 
-      /* PropertySize and Properties */ properties.encodeSize() + 
+      /* PropertySize and Properties */ properties.getEncodeSize() + 
       /* BodySize and Body */ SIZE_INT + body.limit();      
    }
    

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -22,6 +22,7 @@
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.PacketHandlerRegistrationListener;
 import org.jboss.messaging.core.remoting.PacketReturner;
+import org.jboss.messaging.util.ExecutorFactory;
 import org.jboss.messaging.util.OrderedExecutorFactory;
 
 /**
@@ -46,7 +47,7 @@
 
    private final boolean closeSessionOnExceptionCaught;
 
-   private final OrderedExecutorFactory executorFactory;
+   private final ExecutorFactory executorFactory;
 
    // Note! must use ConcurrentMap here to avoid race condition
    private final ConcurrentMap<Long, Executor> executors = new ConcurrentHashMap<Long, Executor>();
@@ -127,7 +128,7 @@
          Executor executor = executors.get(executorID);
          if (executor == null)
          {
-            executor = executorFactory.getOrderedExecutor();
+            executor = executorFactory.getExecutor();
 
             Executor oldExecutor = executors.putIfAbsent(executorID, executor);
 

Modified: trunk/src/main/org/jboss/messaging/core/security/JBMSecurityManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/JBMSecurityManager.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/security/JBMSecurityManager.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -1,9 +1,7 @@
 package org.jboss.messaging.core.security;
 
-import org.jboss.messaging.core.exception.MessagingException;
+import java.util.Set;
 
-import java.util.HashSet;
-
 /**
  * USe to validate whether a user has is valid to connect to the server and perform certain functions
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
@@ -27,5 +25,5 @@
     * @param checkType the type of check to perform
     * @return true if the user is valid and they have the correct roles
     */
-   boolean validateUserAndRole(String user, String password,HashSet<Role> roles, CheckType checkType);
+   boolean validateUserAndRole(String user, String password, Set<Role> roles, CheckType checkType);
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/SecurityStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/SecurityStore.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/security/SecurityStore.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -41,4 +41,6 @@
    void check(SimpleString address, CheckType checkType, ServerConnection conn) throws Exception;
 
    void setSecurityRepository(HierarchicalRepository<HashSet<Role>> securityRepository);
+   
+   void setSecurityManager(JBMSecurityManager securityManager);
 }

Modified: trunk/src/main/org/jboss/messaging/core/security/impl/JAASSecurityManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/JAASSecurityManager.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/JAASSecurityManager.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -21,6 +21,12 @@
    */
 package org.jboss.messaging.core.security.impl;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.security.auth.Subject;
+
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.security.CheckType;
 import org.jboss.messaging.core.security.JBMSecurityManager;
@@ -29,11 +35,6 @@
 import org.jboss.security.RealmMapping;
 import org.jboss.security.SimplePrincipal;
 
-import javax.naming.InitialContext;
-import javax.security.auth.Subject;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * This implementation delegates to the a real JAAS Authentication Manager and will typically be used within an appserver
  * and it up via jndi.
@@ -53,19 +54,19 @@
    /**
     * the realmmapping
     */
-   RealmMapping realmMapping;
+   private RealmMapping realmMapping;
 
    /**
     * the JAAS Authentication Manager
     */
-   AuthenticationManager authenticationManager;
+   private AuthenticationManager authenticationManager;
 
    /**
     * The JNDI name of the AuthenticationManager(and RealmMapping since they are the same object).
     */
    private String securityDomainName = "java:/jaas/messaging";
 
-   public boolean validateUser(String user, String password)
+   public boolean validateUser(final String user, final String password)
    {
       SimplePrincipal principal = new SimplePrincipal(user);
 
@@ -81,7 +82,7 @@
       return authenticationManager.isValid(principal, passwordChars, subject);
    }
 
-   public boolean validateUserAndRole(String user, String password, HashSet<Role> roles, CheckType checkType)
+   public boolean validateUserAndRole(final String user, final String password, final Set<Role> roles, final CheckType checkType)
    {
       SimplePrincipal principal = user == null ? null : new SimplePrincipal(user);
 
@@ -102,7 +103,7 @@
       if (authenticated)
       {
          SecurityActions.pushSubjectContext(principal, passwordChars, subject);
-         Set rolePrincipals = getRolePrincipals(checkType, roles);
+         Set<SimplePrincipal> rolePrincipals = getRolePrincipals(checkType, roles);
 
          authenticated = realmMapping.doesUserHaveRole(principal, rolePrincipals);
 
@@ -115,7 +116,7 @@
       return authenticated;
    }
 
-   private Set getRolePrincipals(CheckType checkType, HashSet<Role> roles)
+   private Set<SimplePrincipal> getRolePrincipals(final CheckType checkType, final Set<Role> roles)
    {
       Set<SimplePrincipal> principals = new HashSet<SimplePrincipal>();
       for (Role role : roles)
@@ -130,12 +131,12 @@
       return principals;
    }
 
-   public void setRealmMapping(RealmMapping realmMapping)
+   public void setRealmMapping(final RealmMapping realmMapping)
    {
       this.realmMapping = realmMapping;
    }
 
-   public void setAuthenticationManager(AuthenticationManager authenticationManager)
+   public void setAuthenticationManager(final AuthenticationManager authenticationManager)
    {
       this.authenticationManager = authenticationManager;
    }

Modified: trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/JBMSecurityManagerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -21,16 +21,17 @@
    */
 package org.jboss.messaging.core.security.impl;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.security.CheckType;
 import org.jboss.messaging.core.security.JBMUpdateableSecurityManager;
 import org.jboss.messaging.core.security.Role;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
 /**
  * A basic implementation of the JBMUpdateableSecurityManager. This can be used within an appserver and be deployed by
  * SecurityManagerDeployer or used standalone or embedded.
@@ -45,19 +46,17 @@
 
    // Attributes ----------------------------------------------------
 
-   private boolean trace = log.isTraceEnabled();
-
    /**
     * the current valid users
     */
-   HashMap<String, User> users = new HashMap<String, User>();
+   private Map<String, User> users = new HashMap<String, User>();
 
    /**
     * the roles for the users
     */
-   HashMap<String, List<String>> roles = new HashMap<String, List<String>>();
+   private Map<String, List<String>> roles = new HashMap<String, List<String>>();
 
-   public JBMSecurityManagerImpl(boolean addGuestRole)
+   public JBMSecurityManagerImpl(final boolean addGuestRole)
    {
       if (addGuestRole)
       {
@@ -69,13 +68,13 @@
       }
    }
 
-   public boolean validateUser(String user, String password)
+   public boolean validateUser(final String user, final String password)
    {
       User theUser = users.get(user == null ? "guest" : user);
       return theUser != null && theUser.isValid(user == null ? "guest" : user, password == null ? "guest" : password);
    }
 
-   public boolean validateUserAndRole(String user, String password, HashSet<Role> roles, CheckType checkType)
+   public boolean validateUserAndRole(final String user, final String password, final Set<Role> roles, final CheckType checkType)
    {
       if (validateUser(user, password))
       {
@@ -97,7 +96,7 @@
       return false;
    }
 
-   public void addUser(String user, String password)
+   public void addUser(final String user, final String password)
    {
       if (user == null)
       {
@@ -110,13 +109,13 @@
       users.put(user, new User(user, password));
    }
 
-   public void removeUser(String user)
+   public void removeUser(final String user)
    {
       users.remove(user);
       roles.remove(user);
    }
 
-   public void addRole(String user, String role)
+   public void addRole(final String user, final String role)
    {
       if (roles.get(user) == null)
       {
@@ -125,7 +124,7 @@
       roles.get(user).add(role);
    }
 
-   public void removeRole(String user, String role)
+   public void removeRole(final String user, final String role)
    {
       if (roles.get(user) == null)
       {
@@ -134,12 +133,12 @@
       roles.get(user).remove(role);
    }
 
-   class User
+   static class User
    {
-      String user;
-      String password;
+      final String user;
+      final String password;
 
-      User(String user, String password)
+      User(final String user, final String password)
       {
          this.user = user;
          this.password = password;
@@ -162,7 +161,7 @@
          return user.hashCode();
       }
 
-      public boolean isValid(String user, String password)
+      public boolean isValid(final String user, final String password)
       {
          if (user == null)
          {

Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -37,7 +37,7 @@
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.core.version.Version;
-import org.jboss.messaging.util.OrderedExecutorFactory;
+import org.jboss.messaging.util.ExecutorFactory;
 
 /**
  * This interface defines the internal interface of the Messaging Server exposed
@@ -53,53 +53,47 @@
  */
 public interface MessagingServer extends MessagingComponent
 {  
-   /**
-    * @return The configuration for this server
-    */
-   Configuration getConfiguration(); 
+   void setRemotingService(RemotingService remotingService);
    
-   /**
-    * 
-    * @return The server version
-    */
-   Version getVersion();
+   RemotingService getRemotingService();
    
-   boolean isStarted();
+   void setStorageManager(StorageManager storageManager);
+      
+   StorageManager getStorageManager();
+
+   public JBMSecurityManager getSecurityManager();
+      
+   void setSecurityManager(JBMSecurityManager securityManager);
+
+   void setPostOffice(PostOffice postOffice);
+      
+   PostOffice getPostOffice();
    
    void setConfiguration(Configuration configuration);
+            
+   Configuration getConfiguration(); 
    
-   void setRemotingService(RemotingService remotingService);
+   Version getVersion();
    
-   RemotingService getRemotingService();
-  
+   boolean isStarted();
+       
    ConnectionManager getConnectionManager();
-
-   StorageManager getStorageManager();
-
-   void setStorageManager(StorageManager storageManager);
    
-   PostOffice getPostOffice();
-   
    HierarchicalRepository<HashSet<Role>> getSecurityRepository();
    
    SecurityStore getSecurityStore();
 
-   void setSecurityManager(JBMSecurityManager securityManager);
-
-   public JBMSecurityManager getSecurityManager();
-
    HierarchicalRepository<QueueSettings> getQueueSettingsRepository();
-
-   void setPostOffice(PostOffice postOffice);
    
+   DeploymentManager getDeploymentManager();
+   
+   ExecutorFactory getExecutorFactory();
+   
+   ResourceManager getResourceManager();
+  
    CreateConnectionResponse createConnection(String username, String password,
                                              long remotingClientSessionID, String clientAddress,
                                              int incrementVersion,
                                              PacketReturner sender) throws Exception;
-
-   DeploymentManager getDeploymentManager();
    
-   OrderedExecutorFactory getOrderedExecutorFactory();
-   
-   ResourceManager getResourceManager();
 }

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -28,6 +28,7 @@
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadFactory;
 
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.deployers.Deployer;
@@ -64,6 +65,7 @@
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.core.transaction.impl.ResourceManagerImpl;
 import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.util.ExecutorFactory;
 import org.jboss.messaging.util.OrderedExecutorFactory;
 import org.jboss.messaging.util.VersionLoader;
 
@@ -90,31 +92,22 @@
 
    // Attributes -----------------------------------------------------------------------------------
 
-   private Version version;
+   private final Version version;
 
    private volatile boolean started;
 
    // wired components
 
-   private SecurityStoreImpl securityStore;
-   private ConnectionManagerImpl connectionManager;
+   private SecurityStore securityStore;
+   private ConnectionManager connectionManager;
+   private RemotingSessionListener sessionListener;
    private MemoryManager memoryManager = new SimpleMemoryManager();
    private PostOffice postOffice;
    private Deployer securityDeployer;
-   private Deployer queueSettingsDeployer;
-   private JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
+   private Deployer queueSettingsDeployer;   
    private DeploymentManager deploymentManager = new FileDeploymentManager();
-   private OrderedExecutorFactory orderedExecutorFactory;
+   private ExecutorFactory executorFactory;
    private ExecutorService threadPool;
-
-   // plugins
-
-   private StorageManager storageManager = new NullStorageManager();
-
-   private RemotingService remotingService;
-   private boolean createTransport = false;
-
-   private Configuration configuration = new ConfigurationImpl();
    private HierarchicalRepository<HashSet<Role>> securityRepository = new HierarchicalObjectRepository<HashSet<Role>>();
    private HierarchicalRepository<QueueSettings> queueSettingsRepository = new HierarchicalObjectRepository<QueueSettings>();
    private QueueFactory queueFactory;
@@ -122,7 +115,17 @@
    private ScheduledExecutorService scheduledExecutor;
    private MessagingServerPacketHandler serverPacketHandler;
 
+   // plugins
+
+   private StorageManager storageManager = new NullStorageManager();
+   private RemotingService remotingService;
+   private JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);   
+   private boolean createTransport = false;
+   private Configuration configuration;
+   
+     
    // Constructors ---------------------------------------------------------------------------------
+   
    /**
     * typically called by the MC framework or embedded if the user want to create and start their own RemotingService
     */
@@ -131,8 +134,9 @@
       //We need to hard code the version information into a source file
 
       version = VersionLoader.load();
-
-      started = false;
+      
+      //Default config
+      configuration = new ConfigurationImpl();
    }
 
    /**
@@ -140,16 +144,17 @@
     *
     * @param configuration the configuration
     */
-   public MessagingServerImpl(Configuration configuration)
+   public MessagingServerImpl(final Configuration configuration)
    {
-      this();
+      version = VersionLoader.load();
+                  
       this.configuration = configuration;
       createTransport = true;
       remotingService = new RemotingServiceImpl(configuration);
    }
+   
    // lifecycle methods ----------------------------------------------------------------
 
-
    public synchronized void start() throws Exception
    {
       log.debug("starting MessagingServer");
@@ -171,12 +176,14 @@
       queueSettingsRepository.setDefault(new QueueSettings());
       scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new JBMThreadFactory("JBM-scheduled-threads"));
       queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
-      connectionManager = new ConnectionManagerImpl();
+      ConnectionManagerImpl cm = new ConnectionManagerImpl();
+      this.connectionManager = cm;
+      this.sessionListener = cm;
       memoryManager = new SimpleMemoryManager();
       postOffice = new PostOfficeImpl(storageManager, queueFactory, configuration.isRequireDestinations());
       queueSettingsDeployer = new QueueSettingsDeployer(queueSettingsRepository);
       threadPool = Executors.newFixedThreadPool(configuration.getThreadPoolMaxSize(), new JBMThreadFactory("JBM-session-threads"));
-      orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
+      executorFactory = new OrderedExecutorFactory(threadPool);
 
       if (createTransport)
       {
@@ -184,7 +191,7 @@
       }
       // Start the wired components
       securityDeployer.start();
-      remotingService.addRemotingSessionListener(connectionManager);
+      remotingService.addRemotingSessionListener(sessionListener);
       memoryManager.start();
       deploymentManager.start(1);
       deploymentManager.registerDeployer(securityDeployer);
@@ -198,7 +205,7 @@
       {
          try
          {
-            Class clazz = loader.loadClass(interceptorClass);
+            Class<?> clazz = loader.loadClass(interceptorClass);
             getRemotingService().addInterceptor((Interceptor) clazz.newInstance());
          }
          catch (Exception e)
@@ -225,7 +232,7 @@
       securityDeployer.stop();
       queueSettingsDeployer.stop();
       deploymentManager.stop();
-      remotingService.removeRemotingSessionListener(connectionManager);
+      remotingService.removeRemotingSessionListener(sessionListener);
       connectionManager = null;
       memoryManager.stop();
       memoryManager = null;
@@ -235,7 +242,7 @@
       scheduledExecutor = null;
       threadPool.shutdown();
       threadPool = null;
-      orderedExecutorFactory = null;
+      executorFactory = null;
       if (createTransport)
       {
          remotingService.stop();
@@ -359,9 +366,9 @@
       return new CreateConnectionResponse(connection.getID(), version);
    }
 
-   public OrderedExecutorFactory getOrderedExecutorFactory()
+   public ExecutorFactory getExecutorFactory()
    {
-      return orderedExecutorFactory;
+      return executorFactory;
    }
 
    public ResourceManager getResourceManager()

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -421,7 +421,7 @@
    {
       deliveringCount.decrementAndGet();
       
-      sizeBytes.addAndGet(-ref.getMessage().encodeSize());
+      sizeBytes.addAndGet(-ref.getMessage().getEncodeSize());
 
 //      if (flowController != null)
 //      {
@@ -539,7 +539,7 @@
 
    private synchronized HandleStatus add(final MessageReference ref, final boolean first)
    {
-      if (maxSizeBytes != -1 && sizeBytes.get() + ref.getMessage().encodeSize() >= maxSizeBytes)
+      if (maxSizeBytes != -1 && sizeBytes.get() + ref.getMessage().getEncodeSize() >= maxSizeBytes)
       {
          return HandleStatus.BUSY;              
       }
@@ -548,7 +548,7 @@
       {
          messagesAdded.incrementAndGet();
          
-         sizeBytes.addAndGet(ref.getMessage().encodeSize());
+         sizeBytes.addAndGet(ref.getMessage().getEncodeSize());
       }
       
       if (checkAndSchedule(ref))

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -199,7 +199,7 @@
                          
          if (availableCredits != null)
          {
-            availableCredits.addAndGet(-message.encodeSize());
+            availableCredits.addAndGet(-message.getEncodeSize());
          }
                    
          try

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerProducerImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -105,7 +105,7 @@
 		   
 			if (flowController != null)
 		   {
-			   int creds = creditsToSend.addAndGet(message.encodeSize());
+			   int creds = creditsToSend.addAndGet(message.getEncodeSize());
 			   
 			   if (creds >= windowSize)
 			   {

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -162,7 +162,7 @@
       this.securityStore = server.getSecurityStore();
       this.dispatcher = server.getRemotingService().getDispatcher();
       this.id = dispatcher.generateID();      
-      this.executor = server.getOrderedExecutorFactory().getOrderedExecutor();
+      this.executor = server.getExecutorFactory().getExecutor();
 
       if (!xa)
       {

Copied: trunk/src/main/org/jboss/messaging/util/ExecutorFactory.java (from rev 4474, trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/util/ExecutorFactory.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/ExecutorFactory.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.messaging.util;
+
+import java.util.concurrent.Executor;
+
+/**
+ * 
+ * A ExecutorFactory
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ExecutorFactory
+{
+   Executor getExecutor();
+}

Deleted: trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.util;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-/**
- * This factory creates a hierarchy of Executor which shares the threads of the
- * parent Executor (typically, the root parent is a Thread pool).
- * 
- * @author <a href="david.lloyd at jboss.com">David Lloyd</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public final class OrderedExecutorFactory
-{
-   private final Executor parent;
-   private final Set<ChildExecutor> runningChildren = Collections.synchronizedSet(new HashSet<ChildExecutor>());
-
-   public OrderedExecutorFactory(final Executor parent)
-   {
-      this.parent = parent;
-   }
-
-   public Executor getOrderedExecutor()
-   {
-      return new ChildExecutor();
-   }
-
-   private final class ChildExecutor implements Executor, Runnable
-   {
-      private final LinkedList<Runnable> tasks = new LinkedList<Runnable>();
-
-      public void execute(Runnable command)
-      {
-         synchronized (tasks)
-         {
-            tasks.add(command);
-            if (tasks.size() == 1 && runningChildren.add(this))
-            {
-               parent.execute(this);
-            }
-         }
-      }
-
-      public void run()
-      {
-         for (;;)
-         {
-            final Runnable task;
-            synchronized (tasks)
-            {
-               task = tasks.poll();
-               if (task == null)
-               {
-                  runningChildren.remove(this);
-                  return;
-               }
-            }
-            task.run();
-         }
-      }
-   }
-}

Added: trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/OrderedExecutorFactory.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.util;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.concurrent.Executor;
+
+/**
+ * This factory creates a hierarchy of Executor which shares the threads of the
+ * parent Executor (typically, the root parent is a Thread pool).
+ * 
+ * @author <a href="david.lloyd at jboss.com">David Lloyd</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public final class OrderedExecutorFactory implements ExecutorFactory
+{
+   private final Executor parent;
+   private final Set<ChildExecutor> runningChildren = Collections.synchronizedSet(new HashSet<ChildExecutor>());
+
+   public OrderedExecutorFactory(final Executor parent)
+   {
+      this.parent = parent;
+   }
+
+   public Executor getExecutor()
+   {
+      return new ChildExecutor();
+   }
+
+   private final class ChildExecutor implements Executor, Runnable
+   {
+      private final LinkedList<Runnable> tasks = new LinkedList<Runnable>();
+
+      public void execute(Runnable command)
+      {
+         synchronized (tasks)
+         {
+            tasks.add(command);
+            if (tasks.size() == 1 && runningChildren.add(this))
+            {
+               parent.execute(this);
+            }
+         }
+      }
+
+      public void run()
+      {
+         for (;;)
+         {
+            final Runnable task;
+            synchronized (tasks)
+            {
+               task = tasks.poll();
+               if (task == null)
+               {
+                  runningChildren.remove(this);
+                  return;
+               }
+            }
+            task.run();
+         }
+      }
+   }
+}

Modified: trunk/src/main/org/jboss/messaging/util/TypedProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/TypedProperties.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/src/main/org/jboss/messaging/util/TypedProperties.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -290,7 +290,7 @@
 		}
 	}
 	
-	public int encodeSize()
+	public int getEncodeSize()
 	{
 	   if (properties == null)
 	   {

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -23,7 +23,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 
 import org.easymock.EasyMock;
@@ -41,6 +40,12 @@
  * 
  * A ClientConsumerImplTest
  * 
+ * TODO - still need to test:
+ * priority
+ * flow control
+ * closing
+ * waiting for message listener to complete etc
+ * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  *
  */
@@ -56,22 +61,6 @@
       testConstructor(6565, 71627162, -1, true);
    }
    
-   /*
-    * Test handleMessage with:
-    * 
-    * handler
-    * nohandler
-    * handler direct
-    * add handler after
-    * 
-    * 
-    * priorities
-    * closed
-    * after recovery
-    * expired messages
-    * 
-    * flowcontrol
-    */
    
    public void testHandleMessageNoHandler() throws Exception
    {
@@ -194,7 +183,7 @@
          
          session.delivered((long)i, false);
          
-         EasyMock.expect(msg.encodeSize()).andReturn(1);
+         EasyMock.expect(msg.getEncodeSize()).andReturn(1);
          
          handler.onMessage(msg);
       }
@@ -217,42 +206,7 @@
       
       assertEquals(0, consumer.getBufferSize());         
    }
-   
-//   public void testSetGetHandler() throws Exception
-//   {
-//      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-//      ClientConnectionInternal connection = EasyMock.createStrictMock(ClientConnectionInternal.class);
-//      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
-//      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-//      
-//      EasyMock.expect(session.getExecutorService()).andReturn(executor);
-//      EasyMock.expect(session.getConnection()).andReturn(connection);
-//      EasyMock.expect(connection.getRemotingConnection()).andReturn(rc);
-//       
-//      EasyMock.replay(session, connection, rc, executor);
-//
-//      ClientConsumerInternal consumer =
-//         new ClientConsumerImpl(session, 54545, 54544, 545454, false);
-//      
-//      EasyMock.verify(session, connection, rc, executor);      
-//      
-//      MessageHandler handler = new MessageHandler()
-//      {
-//         public void onMessage(final ClientMessage msg)
-//         {            
-//         }
-//      };
-//      
-//      consumer.setMessageHandler(handler);
-//      
-//      assertTrue(handler == consumer.getMessageHandler());
-//      
-//      consumer.setMessageHandler(null);
-//      
-//      assertNull(consumer.getMessageHandler());
-//   }
-      
-      
+     
    public void testSetGetHandlerWithMessagesAlreadyInBuffer() throws Exception
    {
       ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
@@ -311,7 +265,223 @@
       EasyMock.verify(session, connection, rc, executor);
       EasyMock.verify(msgs.toArray());   
    }
-               
+   
+   public void testReceiveNoTimeout() throws Exception
+   {
+      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
+      ClientConnectionInternal connection = EasyMock.createStrictMock(ClientConnectionInternal.class);
+      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
+      
+      EasyMock.expect(session.getExecutorService()).andStubReturn(executor);
+      EasyMock.expect(session.getConnection()).andStubReturn(connection);
+      EasyMock.expect(connection.getRemotingConnection()).andStubReturn(rc);
+      
+      
+      final int numMessages = 10;
+      
+      List<ClientMessage> msgs = new ArrayList<ClientMessage>();
+      
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
+         
+         msgs.add(msg);
+         
+         EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
+         
+         EasyMock.expect(msg.isExpired()).andStubReturn(false);
+         
+         EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
+         
+         session.delivered((long)i, false);
+         
+         EasyMock.expect(msg.getEncodeSize()).andReturn(1);
+      }
+      
+      EasyMock.replay(session, connection, rc, executor);
+      EasyMock.replay(msgs.toArray());
+            
+      ClientConsumerInternal consumer =
+         new ClientConsumerImpl(session, 54545, 54544, 545454, false);
+      
+      for (ClientMessage msg: msgs)
+      {
+         consumer.handleMessage(msg);
+      }
+
+      assertEquals(numMessages, consumer.getBufferSize());         
+
+      for (int i = 0; i < numMessages; i++)
+      {      
+         ClientMessage msg = consumer.receive();
+   
+         assertTrue(msg == msgs.get(i));
+      }
+
+      assertNull(consumer.receiveImmediate());      
+   }
+   
+   public void testReceiveWithTimeout() throws Exception
+   {
+      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
+      ClientConnectionInternal connection = EasyMock.createStrictMock(ClientConnectionInternal.class);
+      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
+      
+      EasyMock.expect(session.getExecutorService()).andStubReturn(executor);
+      EasyMock.expect(session.getConnection()).andStubReturn(connection);
+      EasyMock.expect(connection.getRemotingConnection()).andStubReturn(rc);
+      
+      
+      final int numMessages = 10;
+      
+      List<ClientMessage> msgs = new ArrayList<ClientMessage>();
+      
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
+         
+         msgs.add(msg);
+         
+         EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
+         
+         EasyMock.expect(msg.isExpired()).andStubReturn(false);
+         
+         EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
+         
+         session.delivered((long)i, false);
+         
+         EasyMock.expect(msg.getEncodeSize()).andReturn(1);
+      }
+      
+      EasyMock.replay(session, connection, rc, executor);
+      EasyMock.replay(msgs.toArray());
+            
+      ClientConsumerInternal consumer =
+         new ClientConsumerImpl(session, 54545, 54544, 545454, false);
+      
+      for (ClientMessage msg: msgs)
+      {
+         consumer.handleMessage(msg);
+      }
+
+      assertEquals(numMessages, consumer.getBufferSize());         
+
+      for (int i = 0; i < numMessages; i++)
+      {      
+         ClientMessage msg = consumer.receive(1000);
+   
+         assertTrue(msg == msgs.get(i));
+      }
+
+      assertNull(consumer.receiveImmediate());           
+   }
+   
+   public void testReceiveImmediate() throws Exception
+   {
+      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
+      ClientConnectionInternal connection = EasyMock.createStrictMock(ClientConnectionInternal.class);
+      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
+      
+      EasyMock.expect(session.getExecutorService()).andStubReturn(executor);
+      EasyMock.expect(session.getConnection()).andStubReturn(connection);
+      EasyMock.expect(connection.getRemotingConnection()).andStubReturn(rc);
+      
+      
+      final int numMessages = 10;
+      
+      List<ClientMessage> msgs = new ArrayList<ClientMessage>();
+      
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
+         
+         msgs.add(msg);
+         
+         EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
+         
+         EasyMock.expect(msg.isExpired()).andStubReturn(false);
+         
+         EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
+         
+         session.delivered((long)i, false);
+         
+         EasyMock.expect(msg.getEncodeSize()).andReturn(1);
+      }
+      
+      EasyMock.replay(session, connection, rc, executor);
+      EasyMock.replay(msgs.toArray());
+            
+      ClientConsumerInternal consumer =
+         new ClientConsumerImpl(session, 54545, 54544, 545454, false);
+      
+      for (ClientMessage msg: msgs)
+      {
+         consumer.handleMessage(msg);
+      }
+
+      assertEquals(numMessages, consumer.getBufferSize());         
+
+      for (int i = 0; i < numMessages; i++)
+      {      
+         ClientMessage msg = consumer.receiveImmediate();
+   
+         assertTrue(msg == msgs.get(i));
+      }
+
+      assertNull(consumer.receiveImmediate());           
+   }
+   
+   public void testReceiveExpired() throws Exception
+   {
+      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
+      ClientConnectionInternal connection = EasyMock.createStrictMock(ClientConnectionInternal.class);
+      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
+      
+      EasyMock.expect(session.getExecutorService()).andStubReturn(executor);
+      EasyMock.expect(session.getConnection()).andStubReturn(connection);
+      EasyMock.expect(connection.getRemotingConnection()).andStubReturn(rc);
+            
+      final int numMessages = 10;
+      
+      List<ClientMessage> msgs = new ArrayList<ClientMessage>();
+      
+      for (int i = 0; i < numMessages; i++)
+      {
+         ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
+         
+         msgs.add(msg);
+         
+         EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
+         
+         EasyMock.expect(msg.isExpired()).andStubReturn(true);
+         
+         EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
+         
+         session.delivered((long)i, true);
+         
+         EasyMock.expect(msg.getEncodeSize()).andReturn(1);
+      }
+      
+      EasyMock.replay(session, connection, rc, executor);
+      EasyMock.replay(msgs.toArray());
+            
+      ClientConsumerInternal consumer =
+         new ClientConsumerImpl(session, 54545, 54544, 545454, false);
+      
+      for (ClientMessage msg: msgs)
+      {
+         consumer.handleMessage(msg);
+      }
+
+      assertEquals(numMessages, consumer.getBufferSize());         
+
+      assertNull(consumer.receiveImmediate());           
+   }
+   
    // Private -----------------------------------------------------------------------------------------------------------
 
    

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerImplTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientProducerImplTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -286,7 +286,7 @@
       
       if (sendAddress == null && windowSize != -1)
       {
-         EasyMock.expect(message.encodeSize()).andReturn(messageSize);
+         EasyMock.expect(message.getEncodeSize()).andReturn(messageSize);
       }
       
       EasyMock.replay(session, connection, rc, message);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientSessionImplTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -2500,9 +2500,7 @@
          new SessionCreateConsumerResponseMessage(656652, serverWindowSize);
       
       EasyMock.expect(rc.sendBlocking(sessionTargetID, sessionTargetID, request)).andReturn(resp);
-      
-      //EasyMock.expect(conn.getRemotingConnection()).andReturn(value)
-      
+          
       EasyMock.expect(rc.getPacketDispatcher()).andReturn(pd);
       
       pd.register(new ClientConsumerPacketHandler(null, clientTargetID));

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -308,20 +308,20 @@
       ByteBuffer bf = ByteBuffer.allocateDirect(1024);
       ByteBufferWrapper buffer = new ByteBufferWrapper(bf);
       obj.encode(buffer);
-      assertEquals (buffer.position(), obj.encodeSize());
+      assertEquals (buffer.position(), obj.getEncodeSize());
       int originalSize = buffer.position();
       
       bf.rewind();
       newObject.decode(buffer);
       
-      log.info("Obj.size = " + obj.encodeSize() + " newObject.size = " + newObject.encodeSize());
+      log.info("Obj.size = " + obj.getEncodeSize() + " newObject.size = " + newObject.getEncodeSize());
       
       bf = ByteBuffer.allocateDirect(1024 * 10);
       buffer = new ByteBufferWrapper(bf);
       
       newObject.encode(buffer);
       
-      assertEquals(newObject.encodeSize(), bf.position());
+      assertEquals(newObject.getEncodeSize(), bf.position());
       assertEquals(originalSize, bf.position());
       
       

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -833,12 +833,12 @@
       {
          MessageReference ref = generateReference(queue, i++);
                            
-         if (size + ref.getMessage().encodeSize() > maxSize)
+         if (size + ref.getMessage().getEncodeSize() > maxSize)
          {
             break;
          }
          
-         size += ref.getMessage().encodeSize();
+         size += ref.getMessage().getEncodeSize();
          
          refs.add(ref);
          

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TypedPropertiesTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -36,7 +36,7 @@
    {
       assertNotNull(expected);
       assertNotNull(actual);
-      assertEquals(expected.encodeSize(), actual.encodeSize());
+      assertEquals(expected.getEncodeSize(), actual.getEncodeSize());
       assertEquals(expected.getPropertyNames(), actual.getPropertyNames());
       Iterator<SimpleString> iterator = actual.getPropertyNames().iterator();
       while (iterator.hasNext())
@@ -70,7 +70,7 @@
 
       TypedProperties copy = new TypedProperties(props);
 
-      assertEquals(props.encodeSize(), copy.encodeSize());
+      assertEquals(props.getEncodeSize(), copy.getEncodeSize());
       assertEquals(props.getPropertyNames(), copy.getPropertyNames());
 
       assertTrue(copy.containsProperty(key));

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossConnectionMetaDataTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossConnectionMetaDataTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossConnectionMetaDataTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -11,8 +11,6 @@
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossSessionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossSessionTest.java	2008-06-16 15:22:53 UTC (rev 4484)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/client/JBossSessionTest.java	2008-06-16 16:13:47 UTC (rev 4485)
@@ -64,7 +64,6 @@
 import org.jboss.messaging.jms.JBossTopic;
 import org.jboss.messaging.jms.client.JBossConnection;
 import org.jboss.messaging.jms.client.JBossSession;
-import org.jboss.messaging.tests.util.RandomUtil;
 import org.jboss.messaging.util.SimpleString;
 
 /**




More information about the jboss-cvs-commits mailing list