[hornetq-commits] JBoss hornetq SVN: r8224 - in trunk: examples/core/embedded-remote/src/org/hornetq/core/example and 11 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 5 09:38:24 EST 2009


Author: jmesnil
Date: 2009-11-05 09:38:23 -0500 (Thu, 05 Nov 2009)
New Revision: 8224

Added:
   trunk/src/main/org/hornetq/core/message/PropertyConversionException.java
   trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java
Modified:
   trunk/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java
   trunk/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java
   trunk/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java
   trunk/src/main/org/hornetq/core/message/Message.java
   trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
   trunk/src/main/org/hornetq/jms/client/HornetQMessage.java
   trunk/tests/src/org/hornetq/tests/integration/InterceptorTest.java
   trunk/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
   trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
   trunk/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
   trunk/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
   trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
   trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-176: typed property getters on the core Message class

* moved type conversion for properties from HornetQMessage to MessageImpl
  Core message props conversion has the same semantics than JMS props

Modified: trunk/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java
===================================================================
--- trunk/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -94,7 +94,7 @@
    
             // Step 8. Receive the message. 
             ClientMessage messageReceived = messageConsumer.receive(1000);
-            System.out.println("Received TextMessage:" + messageReceived.getProperty(propName));
+            System.out.println("Received TextMessage:" + messageReceived.getObjectProperty(propName));
          }
          finally
          {

Modified: trunk/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java
===================================================================
--- trunk/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -86,7 +86,7 @@
    
             // Step 9. Receive the message. 
             ClientMessage messageReceived = messageConsumer.receive(1000);
-            System.out.println("Received TextMessage:" + messageReceived.getProperty(propName));
+            System.out.println("Received TextMessage:" + messageReceived.getObjectProperty(propName));
          }
          finally
          {

Modified: trunk/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java
===================================================================
--- trunk/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -87,7 +87,7 @@
             // Step 7. Receive the message. 
             ClientMessage messageReceived = messageConsumer.receive(1000);
             
-            System.out.println("Received TextMessage:" + messageReceived.getProperty(propName));
+            System.out.println("Received TextMessage:" + messageReceived.getObjectProperty(propName));
          }
          finally
          {

Modified: trunk/src/main/org/hornetq/core/message/Message.java
===================================================================
--- trunk/src/main/org/hornetq/core/message/Message.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/src/main/org/hornetq/core/message/Message.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -18,7 +18,6 @@
 import java.util.Set;
 
 import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.message.LargeMessageEncodingContext;
 import org.hornetq.utils.SimpleString;
 import org.hornetq.utils.TypedProperties;
 
@@ -35,132 +34,152 @@
  * $Id: Message.java 3341 2007-11-19 14:34:57Z timfox $
  */
 public interface Message
-{   
+{
    long getMessageID();
-   
+
    SimpleString getDestination();
-   
+
    void setDestination(SimpleString destination);
-   
-   byte getType();   
-      
+
+   byte getType();
+
    boolean isDurable();
-   
+
    void setDurable(boolean durable);
-   
+
    long getExpiration();
 
    boolean isExpired();
-   
+
    void setExpiration(long expiration);
-   
+
    long getTimestamp();
-   
+
    void setTimestamp(long timestamp);
-   
+
    byte getPriority();
-   
+
    void setPriority(byte priority);
-   
+
    int getEncodeSize();
 
    void encode(HornetQBuffer buffer);
-   
+
    void decode(HornetQBuffer buffer);
-   
-   
+
    int getHeadersAndPropertiesEncodeSize();
-   
+
    void encodeHeadersAndProperties(HornetQBuffer buffer);
-   
+
    void decodeHeadersAndProperties(HornetQBuffer buffer);
-      
+
    int getBodySize();
 
    boolean isLargeMessage();
-   
+
    long getLargeBodySize();
-         
+
    // Used on Message chunk
    void encodeBody(final HornetQBuffer bufferOut, LargeMessageEncodingContext context, int size);
-   
+
    /** Set the InputStream used on a message that will be sent over a producer */
    void setBodyInputStream(InputStream stream);
-   
+
    /** Get the InputStream used on a message that will be sent over a producer */
    InputStream getBodyInputStream();
-   
-   
+
    void encodeBody(HornetQBuffer buffer);
-   
+
    void decodeBody(HornetQBuffer buffer);
-      
+
    // Properties
    // ------------------------------------------------------------------
-   
+
    TypedProperties getProperties();
-   
+
    void putBooleanProperty(SimpleString key, boolean value);
-   
+
    void putByteProperty(SimpleString key, byte value);
-   
+
    void putBytesProperty(SimpleString key, byte[] value);
-   
+
    void putShortProperty(SimpleString key, short value);
-   
+
    void putIntProperty(SimpleString key, int value);
-   
+
    void putLongProperty(SimpleString key, long value);
-   
+
    void putFloatProperty(SimpleString key, float value);
-   
+
    void putDoubleProperty(SimpleString key, double value);
-   
+
    void putStringProperty(SimpleString key, SimpleString value);
-   
+
+   void putObjectProperty(SimpleString key, Object value) throws PropertyConversionException;
+
    void putBooleanProperty(String key, boolean value);
-   
+
    void putByteProperty(String key, byte value);
-   
+
    void putBytesProperty(String key, byte[] value);
-   
+
    void putShortProperty(String key, short value);
-   
+
    void putIntProperty(String key, int value);
-   
+
    void putLongProperty(String key, long value);
-   
+
    void putFloatProperty(String key, float value);
-   
+
    void putDoubleProperty(String key, double value);
-   
+
    void putStringProperty(String key, String value);
-   
+
+   void putObjectProperty(String key, Object value) throws PropertyConversionException;
+
    void putTypedProperties(TypedProperties properties);
 
-   // TODO - should have typed property getters and do conversions herein
-   
    Object getProperty(SimpleString key);
-   
+
    Object removeProperty(SimpleString key);
-   
+
    boolean containsProperty(SimpleString key);
-   
-   Object getProperty(String key);
-   
+
+   Object getObjectProperty(String key);
+
+   Boolean getBooleanProperty(SimpleString key) throws PropertyConversionException;
+
+   Byte getByteProperty(SimpleString key) throws PropertyConversionException;
+
+   Double getDoubleProperty(SimpleString key) throws PropertyConversionException;
+
+   Integer getIntProperty(SimpleString key) throws PropertyConversionException;
+
+   Long getLongProperty(SimpleString key) throws PropertyConversionException;
+
+   Object getObjectProperty(SimpleString key);
+
+   Short getShortProperty(SimpleString key) throws PropertyConversionException;
+
+   Float getFloatProperty(SimpleString key) throws PropertyConversionException;
+
+   String getStringProperty(SimpleString key) throws PropertyConversionException;
+
+   byte[] getBytesProperty(SimpleString key) throws PropertyConversionException;
+
    Object removeProperty(String key);
-   
+
    boolean containsProperty(String key);
-   
+
    Set<SimpleString> getPropertyNames();
-   
+
    Map<String, Object> toMap();
-   
+
    // Body
    // ---------------------------------------------------------------------------------
-   
+
    HornetQBuffer getBody();
-   
+
    void setBody(HornetQBuffer body);
-   
+
 }

Added: trunk/src/main/org/hornetq/core/message/PropertyConversionException.java
===================================================================
--- trunk/src/main/org/hornetq/core/message/PropertyConversionException.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/core/message/PropertyConversionException.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.message;
+
+/**
+ * A PropertyConversionException
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class PropertyConversionException extends Exception
+{
+
+   private static final long serialVersionUID = -3010008708334904332L;
+
+   public PropertyConversionException(String message)
+   {
+      super(message);
+   }
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -25,9 +25,10 @@
 
 import org.hornetq.core.buffers.ChannelBuffers;
 import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.LargeMessageEncodingContext;
 import org.hornetq.core.message.Message;
+import org.hornetq.core.message.PropertyConversionException;
 import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.message.LargeMessageEncodingContext;
 import org.hornetq.utils.SimpleString;
 import org.hornetq.utils.TypedProperties;
 
@@ -60,15 +61,15 @@
    public static final SimpleString HDR_GROUP_ID = new SimpleString("_HQ_GROUP_ID");
 
    public static final SimpleString HDR_SCHEDULED_DELIVERY_TIME = new SimpleString("_HQ_SCHED_DELIVERY");
-   
+
    public static final SimpleString HDR_DUPLICATE_DETECTION_ID = new SimpleString("_HQ_DUPL_ID");
 
    public static final SimpleString HDR_ROUTE_TO_IDS = new SimpleString("_HQ_ROUTE_TO");
-   
+
    public static final SimpleString HDR_FROM_CLUSTER = new SimpleString("_HQ_FROM_CLUSTER");
 
    public static final SimpleString HDR_LAST_VALUE_NAME = new SimpleString("_HQ_LVQ_NAME");
-  
+
    // Attributes ----------------------------------------------------
 
    protected long messageID;
@@ -92,7 +93,7 @@
 
    /** Used on LargeMessages */
    private InputStream bodyInputStream;
-   
+
    // Constructors --------------------------------------------------
 
    protected MessageImpl()
@@ -141,7 +142,7 @@
       this.properties = new TypedProperties(other.properties);
       this.body = other.body;
    }
-   
+
    /*
     * Copy constructor
     */
@@ -158,7 +159,6 @@
       this.properties = new TypedProperties(other.getProperties());
       this.body = other.getBody();
    }
-   
 
    protected MessageImpl(final long messageID)
    {
@@ -174,7 +174,7 @@
       buffer.writeInt(getBodySize());
       encodeBody(buffer);
    }
-   
+
    public int getEncodeSize()
    {
       return getHeadersAndPropertiesEncodeSize() + SIZE_INT + getBodySize();
@@ -246,7 +246,7 @@
       buffer.readBytes(bytes);
 
       // Reuse the same body on the initial body created
-      body = ChannelBuffers.dynamicBuffer(bytes); 
+      body = ChannelBuffers.dynamicBuffer(bytes);
    }
 
    public long getMessageID()
@@ -318,7 +318,7 @@
 
       return System.currentTimeMillis() - expiration >= 0;
    }
-   
+
    /**
     * @return the bodyInputStream
     */
@@ -338,7 +338,7 @@
    public Map<String, Object> toMap()
    {
       Map<String, Object> map = new HashMap<String, Object>();
-      
+
       map.put("messageID", messageID);
       map.put("destination", destination.toString());
       map.put("type", type);
@@ -346,14 +346,13 @@
       map.put("expiration", expiration);
       map.put("timestamp", timestamp);
       map.put("priority", priority);
-      for (SimpleString propName: properties.getPropertyNames())
+      for (SimpleString propName : properties.getPropertyNames())
       {
          map.put(propName.toString(), properties.getProperty(propName));
       }
-      return map;      
+      return map;
    }
-     
-   
+
    // Properties
    // ---------------------------------------------------------------------------------------
 
@@ -402,6 +401,57 @@
       properties.putStringProperty(key, value);
    }
    
+   public void putObjectProperty(SimpleString key, Object value) throws PropertyConversionException
+   {
+      if (value == null)
+      {
+         // This is ok - when we try to read the same key it will return null too
+         return;
+      }
+
+      if (value instanceof Boolean)
+      {
+         properties.putBooleanProperty(key, (Boolean)value);
+      }
+      else if (value instanceof Byte)
+      {
+         properties.putByteProperty(key, (Byte)value);
+      }
+      else if (value instanceof Short)
+      {
+         properties.putShortProperty(key, (Short)value);
+      }
+      else if (value instanceof Integer)
+      {
+         properties.putIntProperty(key, (Integer)value);
+      }
+      else if (value instanceof Long)
+      {
+         properties.putLongProperty(key, (Long)value);
+      }
+      else if (value instanceof Float)
+      {
+         properties.putFloatProperty(key, (Float)value);
+      }
+      else if (value instanceof Double)
+      {
+         properties.putDoubleProperty(key, (Double)value);
+      }
+      else if (value instanceof String)
+      {
+         properties.putStringProperty(key, new SimpleString((String)value));
+      }
+      else
+      {
+         throw new PropertyConversionException(value.getClass() + " is not a valid property type");
+      }
+   }
+
+   public void putObjectProperty(String key, Object value) throws PropertyConversionException
+   {
+      putObjectProperty(new SimpleString(key), value);
+   }
+
    public void putBooleanProperty(final String key, final boolean value)
    {
       properties.putBooleanProperty(new SimpleString(key), value);
@@ -456,17 +506,269 @@
    {
       return properties.getProperty(key);
    }
+
+   public Boolean getBooleanProperty(SimpleString key) throws PropertyConversionException
+   {
+      final Object value = getObjectProperty(key);
+      if (value == null)
+      {
+         return Boolean.valueOf(null);
+      }
+
+      if (value instanceof Boolean)
+      {
+         return (Boolean)value;
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Boolean.valueOf(((SimpleString)value).toString()).booleanValue();
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Byte getByteProperty(SimpleString key) throws PropertyConversionException
+   {
+      final Object value = properties.getProperty(key);
+
+      if (value == null)
+      {
+         return Byte.valueOf(null);
+      }
+
+      if (value instanceof Byte)
+      {
+         return (Byte)value;
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Byte.parseByte(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
    
-   public Object getProperty(final String key)
+   public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
    {
+      final Object value = properties.getProperty(key);
+
+      if (value == null)
+      {
+         throw new IllegalArgumentException(key + " property is not defined");
+      }
+
+      if (value instanceof byte[])
+      {
+         return (byte[])value;
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Double getDoubleProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = getProperty(key);
+      if (value == null)
+      {
+         return Double.valueOf(null);
+      }
+
+      if (value instanceof Float)
+      {
+         return ((Float)value).doubleValue();
+      }
+      else if (value instanceof Double)
+      {
+         return (Double)value;
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Double.parseDouble(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Integer getIntProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = getObjectProperty(key);
+      if (value == null)
+      {
+         return Integer.valueOf(null);
+      }
+      else if (value instanceof Integer)
+      {
+         return (Integer)value;
+      }
+      else if (value instanceof Byte)
+      {
+         return ((Byte)value).intValue();
+      }
+      else if (value instanceof Short)
+      {
+         return ((Short)value).intValue();
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Integer.parseInt(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Long getLongProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = getObjectProperty(key);
+      if (value == null)
+      {
+         return Long.valueOf(null);
+      }
+      else if (value instanceof Long)
+      {
+         return (Long)value;
+      }
+      else if (value instanceof Byte)
+      {
+         return ((Byte)value).longValue();
+      }
+      else if (value instanceof Short)
+      {
+         return ((Short)value).longValue();
+      }
+      else if (value instanceof Integer)
+      {
+         return ((Integer)value).longValue();
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Long.parseLong(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Short getShortProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = getObjectProperty(key);
+      if (value == null)
+      {
+         return Short.valueOf(null);
+      }
+      else if (value instanceof Byte)
+      {
+         return ((Byte)value).shortValue();
+      }
+      else if (value instanceof Short)
+      {
+         return (Short)value;
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Short.parseShort(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid Conversion.");
+      }
+
+   }
+
+   public Float getFloatProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = getProperty(key);
+      if (value == null)
+      {
+         return Float.valueOf(null);
+      }
+
+      if (value instanceof Float)
+      {
+         return ((Float)value).floatValue();
+      }
+      else if (value instanceof SimpleString)
+      {
+         return Float.parseFloat(((SimpleString)value).toString());
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public String getStringProperty(SimpleString key) throws PropertyConversionException
+   {
+      Object value = properties.getProperty(key);
+
+      if (value == null)
+      {
+         return null;
+      }
+
+      if (value instanceof SimpleString)
+      {
+         return ((SimpleString)value).toString();
+      }
+      else if (value instanceof Boolean)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Byte)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Short)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Integer)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Long)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Float)
+      {
+         return value.toString();
+      }
+      else if (value instanceof Double)
+      {
+         return value.toString();
+      }
+      else
+      {
+         throw new PropertyConversionException("Invalid conversion");
+      }
+   }
+
+   public Object getObjectProperty(final String key)
+   {
       return properties.getProperty(new SimpleString(key));
    }
 
+   public Object getObjectProperty(final SimpleString key)
+   {
+      return properties.getProperty(key);
+   }
+   
    public Object removeProperty(final SimpleString key)
    {
       return properties.removeProperty(key);
    }
-   
+
    public Object removeProperty(final String key)
    {
       return properties.removeProperty(new SimpleString(key));
@@ -476,7 +778,7 @@
    {
       return properties.containsProperty(key);
    }
-   
+
    public boolean containsProperty(final String key)
    {
       return properties.containsProperty(new SimpleString(key));
@@ -491,7 +793,7 @@
    {
       return this.properties;
    }
-      
+
    // Body
    // -------------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/hornetq/jms/client/HornetQMessage.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQMessage.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/src/main/org/hornetq/jms/client/HornetQMessage.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -39,6 +39,7 @@
 import org.hornetq.core.client.impl.ClientMessageImpl;
 import org.hornetq.core.exception.HornetQException;
 import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.PropertyConversionException;
 import org.hornetq.core.message.impl.MessageImpl;
 import org.hornetq.core.remoting.spi.HornetQBuffer;
 import org.hornetq.jms.HornetQDestination;
@@ -604,72 +605,38 @@
 
    public boolean getBooleanProperty(final String name) throws JMSException
    {
-      Object value = message.getProperty(new SimpleString(name));
-      if (value == null)
+      try
       {
-         return Boolean.valueOf(null).booleanValue();
+         return message.getBooleanProperty(new SimpleString(name));
       }
-
-      if (value instanceof Boolean)
+      catch (PropertyConversionException e)
       {
-         return ((Boolean)value).booleanValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof SimpleString)
-      {
-         return Boolean.valueOf(((SimpleString)value).toString()).booleanValue();
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public byte getByteProperty(final String name) throws JMSException
    {
-      Object value = message.getProperty(new SimpleString(name));
-      if (value == null)
+      try
       {
-         throw new NumberFormatException("Message property '" + name + "' not set.");
+         return message.getByteProperty(new SimpleString(name));
       }
-
-      if (value instanceof Byte)
+      catch (PropertyConversionException e)
       {
-         return ((Byte)value).byteValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof SimpleString)
-      {
-         return Byte.parseByte(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public short getShortProperty(final String name) throws JMSException
    {
-      Object value = message.getProperty(new SimpleString(name));
-      if (value == null)
+      try
       {
-         throw new NumberFormatException("Message property '" + name + "' not set.");
+         return message.getShortProperty(new SimpleString(name));
       }
-
-      if (value instanceof Byte)
+      catch (PropertyConversionException e)
       {
-         return ((Byte)value).shortValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Short)
-      {
-         return ((Short)value).shortValue();
-      }
-      else if (value instanceof SimpleString)
-      {
-         return Short.parseShort(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public int getIntProperty(final String name) throws JMSException
@@ -679,33 +646,14 @@
          return message.getDeliveryCount();
       }
 
-      Object value = message.getProperty(new SimpleString(name));
-
-      if (value == null)
+      try
       {
-         return Integer.valueOf(null);
+         return message.getIntProperty(new SimpleString(name));
       }
-
-      if (value instanceof Byte)
+      catch (PropertyConversionException e)
       {
-         return ((Byte)value).intValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Short)
-      {
-         return ((Short)value).intValue();
-      }
-      else if (value instanceof Integer)
-      {
-         return ((Integer)value).intValue();
-      }
-      else if (value instanceof SimpleString)
-      {
-         return Integer.parseInt(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public long getLongProperty(final String name) throws JMSException
@@ -715,85 +663,38 @@
          return message.getDeliveryCount();
       }
 
-      Object value = message.getProperty(new SimpleString(name));
-
-      if (value == null)
+      try
       {
-         return Long.valueOf(null);
+         return message.getLongProperty(new SimpleString(name));
       }
-
-      if (value instanceof Byte)
+      catch (PropertyConversionException e)
       {
-         return ((Byte)value).longValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Short)
-      {
-         return ((Short)value).longValue();
-      }
-      else if (value instanceof Integer)
-      {
-         return ((Integer)value).longValue();
-      }
-      else if (value instanceof Long)
-      {
-         return ((Long)value).longValue();
-      }
-      else if (value instanceof SimpleString)
-      {
-         return Long.parseLong(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public float getFloatProperty(final String name) throws JMSException
    {
-      Object value = message.getProperty(new SimpleString(name));
-      if (value == null)
+      try
       {
-         return Float.valueOf(null).floatValue();
+         return message.getFloatProperty(new SimpleString(name));
       }
-
-      if (value instanceof Float)
+      catch (PropertyConversionException e)
       {
-         return ((Float)value).floatValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof SimpleString)
-      {
-         return Float.parseFloat(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public double getDoubleProperty(final String name) throws JMSException
    {
-      Object value = message.getProperty(new SimpleString(name));
-      if (value == null)
+      try
       {
-         return Double.valueOf(null).doubleValue();
+         return message.getDoubleProperty(new SimpleString(name));
       }
-
-      if (value instanceof Float)
+      catch (PropertyConversionException e)
       {
-         return ((Float)value).doubleValue();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Double)
-      {
-         return ((Double)value).doubleValue();
-      }
-      else if (value instanceof SimpleString)
-      {
-         return Double.parseDouble(((SimpleString)value).toString());
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public String getStringProperty(final String name) throws JMSException
@@ -802,56 +703,22 @@
       {
          return String.valueOf(message.getDeliveryCount());
       }
-      Object value;
-      if (JMSXGROUPID.equals(name))
-      {
-         value = message.getProperty(MessageImpl.HDR_GROUP_ID);
-      }
-      else
-      {
-         value = message.getProperty(new SimpleString(name));
-      }
-      if (value == null)
-      {
-         return null;
-      }
 
-      if (value instanceof SimpleString)
+      try
       {
-         return ((SimpleString)value).toString();
+         if (JMSXGROUPID.equals(name))
+         {
+            return message.getStringProperty(MessageImpl.HDR_GROUP_ID);
+         }
+         else
+         {
+            return message.getStringProperty(new SimpleString(name));
+         }
       }
-      else if (value instanceof Boolean)
+      catch (PropertyConversionException e)
       {
-         return value.toString();
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Byte)
-      {
-         return value.toString();
-      }
-      else if (value instanceof Short)
-      {
-         return value.toString();
-      }
-      else if (value instanceof Integer)
-      {
-         return value.toString();
-      }
-      else if (value instanceof Long)
-      {
-         return value.toString();
-      }
-      else if (value instanceof Float)
-      {
-         return value.toString();
-      }
-      else if (value instanceof Double)
-      {
-         return value.toString();
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid conversion");
-      }
    }
 
    public Object getObjectProperty(final String name) throws JMSException
@@ -892,51 +759,44 @@
 
    public void setBooleanProperty(final String name, final boolean value) throws JMSException
    {
-      Boolean b = Boolean.valueOf(value);
-      checkProperty(name, b);
-      message.putBooleanProperty(new SimpleString(name), b);
+      checkProperty(name, value);
+      message.putBooleanProperty(new SimpleString(name), value);
    }
 
    public void setByteProperty(final String name, final byte value) throws JMSException
    {
-      Byte b = new Byte(value);
-      checkProperty(name, b);
+      checkProperty(name, value);
       message.putByteProperty(new SimpleString(name), value);
    }
 
    public void setShortProperty(final String name, final short value) throws JMSException
    {
-      Short s = new Short(value);
-      checkProperty(name, s);
+      checkProperty(name, value);
       message.putShortProperty(new SimpleString(name), value);
    }
 
    public void setIntProperty(final String name, final int value) throws JMSException
    {
-      Integer i = new Integer(value);
-      checkProperty(name, i);
+      checkProperty(name, value);
       message.putIntProperty(new SimpleString(name), value);
    }
 
    public void setLongProperty(final String name, final long value) throws JMSException
    {
-      Long l = new Long(value);
-      checkProperty(name, l);
+      checkProperty(name, value);
       message.putLongProperty(new SimpleString(name), value);
    }
 
    public void setFloatProperty(final String name, final float value) throws JMSException
    {
-      Float f = new Float(value);
-      checkProperty(name, f);
-      message.putFloatProperty(new SimpleString(name), f);
+      checkProperty(name, value);
+      message.putFloatProperty(new SimpleString(name), value);
    }
 
    public void setDoubleProperty(final String name, final double value) throws JMSException
    {
-      Double d = new Double(value);
-      checkProperty(name, d);
-      message.putDoubleProperty(new SimpleString(name), d);
+      checkProperty(name, value);
+      message.putDoubleProperty(new SimpleString(name), value);
    }
 
    public void setStringProperty(final String name, final String value) throws JMSException
@@ -989,44 +849,14 @@
          return;
       }
 
-      SimpleString key = new SimpleString(name);
-
-      if (value instanceof Boolean)
+      try
       {
-         message.putBooleanProperty(key, (Boolean)value);
+         message.putObjectProperty(new SimpleString(name), value);
       }
-      else if (value instanceof Byte)
+      catch (PropertyConversionException e)
       {
-         message.putByteProperty(key, (Byte)value);
+         throw new MessageFormatException(e.getMessage());
       }
-      else if (value instanceof Short)
-      {
-         message.putShortProperty(key, (Short)value);
-      }
-      else if (value instanceof Integer)
-      {
-         message.putIntProperty(key, (Integer)value);
-      }
-      else if (value instanceof Long)
-      {
-         message.putLongProperty(key, (Long)value);
-      }
-      else if (value instanceof Float)
-      {
-         message.putFloatProperty(key, (Float)value);
-      }
-      else if (value instanceof Double)
-      {
-         message.putDoubleProperty(key, (Double)value);
-      }
-      else if (value instanceof String)
-      {
-         message.putStringProperty(key, new SimpleString((String)value));
-      }
-      else
-      {
-         throw new MessageFormatException("Invalid property type");
-      }
    }
 
    public void acknowledge() throws JMSException

Modified: trunk/tests/src/org/hornetq/tests/integration/InterceptorTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/InterceptorTest.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/integration/InterceptorTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -272,7 +272,7 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals("orange", ((SimpleString)message.getProperty(key)).toString());
+         assertEquals("orange", ((SimpleString)message.getObjectProperty(key)).toString());
       }
       
       server.getRemotingService().removeInterceptor(interceptor);
@@ -290,7 +290,7 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals("apple", ((SimpleString)message.getProperty(key)).toString());
+         assertEquals("apple", ((SimpleString)message.getObjectProperty(key)).toString());
       }
      
       session.close();
@@ -365,7 +365,7 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals("orange", ((SimpleString)message.getProperty(key)).toString());
+         assertEquals("orange", ((SimpleString)message.getObjectProperty(key)).toString());
       }
       
       sf.removeInterceptor(interceptor);
@@ -383,7 +383,7 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals("apple", ((SimpleString)message.getProperty(key)).toString());
+         assertEquals("apple", ((SimpleString)message.getObjectProperty(key)).toString());
       }
      
       session.close();
@@ -460,10 +460,10 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals(1, ((Integer)message.getProperty("a")).intValue());
-         assertEquals(2, ((Integer)message.getProperty("b")).intValue());
-         assertEquals(3, ((Integer)message.getProperty("c")).intValue());
-         assertEquals(4, ((Integer)message.getProperty("d")).intValue());
+         assertEquals(1, ((Integer)message.getObjectProperty("a")).intValue());
+         assertEquals(2, ((Integer)message.getObjectProperty("b")).intValue());
+         assertEquals(3, ((Integer)message.getObjectProperty("c")).intValue());
+         assertEquals(4, ((Integer)message.getObjectProperty("d")).intValue());
       }
       
       server.getRemotingService().removeInterceptor(interceptor2);
@@ -479,10 +479,10 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals(1, ((Integer)message.getProperty("a")).intValue());
-         assertNull(message.getProperty("b"));
-         assertEquals(3, ((Integer)message.getProperty("c")).intValue());
-         assertEquals(4, ((Integer)message.getProperty("d")).intValue());
+         assertEquals(1, ((Integer)message.getObjectProperty("a")).intValue());
+         assertNull(message.getObjectProperty("b"));
+         assertEquals(3, ((Integer)message.getObjectProperty("c")).intValue());
+         assertEquals(4, ((Integer)message.getObjectProperty("d")).intValue());
         
       }
       
@@ -549,10 +549,10 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals(1, ((Integer)message.getProperty("a")).intValue());
-         assertEquals(2, ((Integer)message.getProperty("b")).intValue());
-         assertEquals(3, ((Integer)message.getProperty("c")).intValue());
-         assertEquals(4, ((Integer)message.getProperty("d")).intValue());
+         assertEquals(1, ((Integer)message.getObjectProperty("a")).intValue());
+         assertEquals(2, ((Integer)message.getObjectProperty("b")).intValue());
+         assertEquals(3, ((Integer)message.getObjectProperty("c")).intValue());
+         assertEquals(4, ((Integer)message.getObjectProperty("d")).intValue());
       }
       
       sf.removeInterceptor(interceptor2);
@@ -568,10 +568,10 @@
       {
          ClientMessage message = consumer.receive(1000);
          
-         assertEquals(1, ((Integer)message.getProperty("a")).intValue());
-         assertNull(message.getProperty("b"));
-         assertEquals(3, ((Integer)message.getProperty("c")).intValue());
-         assertEquals(4, ((Integer)message.getProperty("d")).intValue());
+         assertEquals(1, ((Integer)message.getObjectProperty("a")).intValue());
+         assertNull(message.getObjectProperty("b"));
+         assertEquals(3, ((Integer)message.getObjectProperty("c")).intValue());
+         assertEquals(4, ((Integer)message.getObjectProperty("d")).intValue());
         
       }
       

Modified: trunk/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/integration/client/ConsumerTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -365,7 +365,7 @@
       {
          ClientMessage message = (ClientMessage)consumer.receive();
 
-         int count = (Integer)message.getProperty("count");
+         int count = (Integer)message.getObjectProperty("count");
 
          boolean redelivered = message.getDeliveryCount() > 1;
 
@@ -425,7 +425,7 @@
       {
          ClientMessage message = (ClientMessage)consumer.receive();
 
-         int count = (Integer)message.getProperty("count");
+         int count = (Integer)message.getObjectProperty("count");
 
          boolean redelivered = message.getDeliveryCount() > 1;
 

Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -260,7 +260,7 @@
 
             // messages must remain ordered but there could be a "jump" if messages
             // are missing or duplicated
-            int count = (Integer)message.getProperty("counter");
+            int count = (Integer)message.getObjectProperty("counter");
             counts.add(count);
             if (count != lastCount + 1)
             {
@@ -379,7 +379,7 @@
 
                // There may be some missing or duplicate messages - but the order should be correct
 
-               int count = (Integer)message.getProperty("counter");
+               int count = (Integer)message.getObjectProperty("counter");
 
                assertTrue("count:" + count + " last count:" + lastCount, count >= lastCount);
 

Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/failover/FailoverTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -155,7 +155,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -227,7 +227,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -393,7 +393,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -482,7 +482,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -553,7 +553,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -636,7 +636,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -659,7 +659,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -964,7 +964,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -1041,7 +1041,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -1127,7 +1127,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -1228,7 +1228,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -1393,7 +1393,7 @@
 
                assertMessageBody(i, message);
 
-               assertEquals(i, message.getProperty("counter"));
+               assertEquals(i, message.getObjectProperty("counter"));
 
                message.acknowledge();
             }
@@ -1465,7 +1465,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
       }
 
       fail(session, latch);
@@ -1482,7 +1482,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -1545,7 +1545,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
       }
 
       fail(session, latch);
@@ -1564,7 +1564,7 @@
 
             assertMessageBody(i, message);
 
-            assertEquals(i, message.getProperty("counter"));
+            assertEquals(i, message.getObjectProperty("counter"));
 
             message.acknowledge();
          }
@@ -1628,7 +1628,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -1658,7 +1658,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -1882,7 +1882,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }
@@ -2022,7 +2022,7 @@
 
          assertMessageBody(i, message);
 
-         assertEquals(i, message.getProperty("counter"));
+         assertEquals(i, message.getObjectProperty("counter"));
 
          message.acknowledge();
       }

Modified: trunk/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/integration/largemessage/LargeMessageTestBase.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -50,7 +50,7 @@
  *
  *
  */
-public class LargeMessageTestBase extends ServiceTestBase
+public abstract class LargeMessageTestBase extends ServiceTestBase
 {
 
    // Constants -----------------------------------------------------

Added: trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.unit.core.message.impl;
+
+import static org.hornetq.tests.util.RandomUtil.randomBoolean;
+import static org.hornetq.tests.util.RandomUtil.randomByte;
+import static org.hornetq.tests.util.RandomUtil.randomDouble;
+import static org.hornetq.tests.util.RandomUtil.randomFloat;
+import static org.hornetq.tests.util.RandomUtil.randomInt;
+import static org.hornetq.tests.util.RandomUtil.randomShort;
+import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
+import static org.hornetq.tests.util.UnitTestCase.assertEqualsByteArrays;
+import junit.framework.TestCase;
+
+import org.hornetq.core.client.impl.ClientMessageImpl;
+import org.hornetq.core.message.Message;
+import org.hornetq.core.message.PropertyConversionException;
+import org.hornetq.tests.util.RandomUtil;
+import org.hornetq.utils.SimpleString;
+
+/**
+ * A MessagePropertyConversionTest
+ *
+ * @author jmesnil
+ *
+ *
+ */
+public class MessagePropertyConversionTest extends TestCase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private Message msg;
+
+   private SimpleString key;
+
+   private SimpleString unknownKey = new SimpleString("this.key.is.never.used");
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      key = randomSimpleString();
+      msg = new ClientMessageImpl(false);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      key = null;
+      msg = null;
+
+      super.tearDown();
+   }
+
+   public void testBooleanProperty() throws Exception
+   {
+      Boolean val = randomBoolean();
+      msg.putBooleanProperty(key, val);
+
+      assertEquals(val, msg.getBooleanProperty(key));
+      assertEquals(Boolean.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Boolean.toString(val)));
+      assertEquals(val, msg.getBooleanProperty(key));
+      
+      try
+      {
+         msg.putByteProperty(key, randomByte());
+         msg.getBooleanProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+      
+      assertFalse(msg.getBooleanProperty(unknownKey));
+   }
+
+   public void testByteProperty() throws Exception
+   {
+      Byte val = randomByte();
+      msg.putByteProperty(key, val);
+
+      assertEquals(val, msg.getByteProperty(key));
+      assertEquals(Byte.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Byte.toString(val)));
+      assertEquals(val, msg.getByteProperty(key));
+      
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getByteProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+      
+      try
+      {
+         msg.getByteProperty(unknownKey);
+         fail();
+      }
+      catch (NumberFormatException e)
+      {
+      }
+   }
+   
+   public void testIntProperty() throws Exception
+   {
+      Integer val = randomInt();
+      msg.putIntProperty(key, val);
+
+      assertEquals(val, msg.getIntProperty(key));
+      assertEquals(Integer.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Integer.toString(val)));
+      assertEquals(val, msg.getIntProperty(key));
+      
+      Byte byteVal = randomByte();
+      msg.putByteProperty(key, byteVal);
+      assertEquals(Integer.valueOf(byteVal), msg.getIntProperty(key));
+      
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getIntProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+      
+      try
+      {
+         msg.getIntProperty(unknownKey);
+         fail();
+      }
+      catch (NumberFormatException e)
+      {
+      }
+   }
+
+   public void testLongProperty() throws Exception
+   {
+      Long val = RandomUtil.randomLong();
+      msg.putLongProperty(key, val);
+
+      assertEquals(val, msg.getLongProperty(key));
+      assertEquals(Long.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Long.toString(val)));
+      assertEquals(val, msg.getLongProperty(key));
+      
+      Byte byteVal = randomByte();
+      msg.putByteProperty(key, byteVal);
+      assertEquals(Long.valueOf(byteVal), msg.getLongProperty(key));
+
+      Short shortVal = randomShort();
+      msg.putShortProperty(key, shortVal);
+      assertEquals(Long.valueOf(shortVal), msg.getLongProperty(key));
+
+      Integer intVal = randomInt();
+      msg.putIntProperty(key, intVal);
+      assertEquals(Long.valueOf(intVal), msg.getLongProperty(key));
+
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getLongProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+      
+      try
+      {
+         msg.getLongProperty(unknownKey);
+         fail();
+      }
+      catch (NumberFormatException e)
+      {
+      }
+   }
+   
+   public void testDoubleProperty() throws Exception
+   {
+      Double val = randomDouble();
+      msg.putDoubleProperty(key, val);
+
+      assertEquals(val, msg.getDoubleProperty(key));
+      assertEquals(Double.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Double.toString(val)));
+      assertEquals(val, msg.getDoubleProperty(key));
+      
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getDoubleProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+
+      try
+      {
+         msg.getDoubleProperty(unknownKey);
+         fail();
+      }
+      catch (Exception e)
+      {
+      }
+   }
+
+   public void testFloatProperty() throws Exception
+   {
+      Float val = randomFloat();
+      msg.putFloatProperty(key, val);
+
+      assertEquals(val, msg.getFloatProperty(key));
+      assertEquals(Double.valueOf(val), msg.getDoubleProperty(key));
+      assertEquals(Float.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Float.toString(val)));
+      assertEquals(val, msg.getFloatProperty(key));
+
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getFloatProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+      
+      try
+      {
+         msg.getFloatProperty(unknownKey);
+         fail();
+      }
+      catch (Exception e)
+      {
+      }
+   }
+
+   public void testShortProperty() throws Exception
+   {
+      Short val = randomShort();
+      msg.putShortProperty(key, val);
+
+      assertEquals(val, msg.getShortProperty(key));
+      assertEquals(Integer.valueOf(val), msg.getIntProperty(key));
+      assertEquals(Short.toString(val), msg.getStringProperty(key));
+
+      msg.putStringProperty(key, new SimpleString(Short.toString(val)));
+      assertEquals(val, msg.getShortProperty(key));
+      
+      Byte byteVal = randomByte();
+      msg.putByteProperty(key, byteVal);
+      assertEquals(Short.valueOf(byteVal), msg.getShortProperty(key));
+      
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getShortProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+
+      try
+      {
+         msg.getShortProperty(unknownKey);
+         fail();
+      }
+      catch (NumberFormatException e)
+      {
+      }
+   }
+
+   public void testStringProperty() throws Exception
+   {
+      SimpleString strVal = randomSimpleString();
+      msg.putStringProperty(key, strVal);
+      assertEquals(strVal.toString(), msg.getStringProperty(key));
+   }
+   
+   public void testBytesProperty() throws Exception
+   {
+      byte[] val = RandomUtil.randomBytes();
+      msg.putBytesProperty(key, val);
+
+      assertEqualsByteArrays(val, msg.getBytesProperty(key));
+     
+      try
+      {
+         msg.putBooleanProperty(key, randomBoolean());
+         msg.getBytesProperty(key);
+         fail();
+      }
+      catch (PropertyConversionException e)
+      {
+      }
+
+      try
+      {
+         msg.getBytesProperty(unknownKey);
+         fail();
+      }
+      catch (Exception e)
+      {
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -22,16 +22,21 @@
 
 import org.hornetq.core.exception.HornetQException;
 import org.hornetq.core.filter.Filter;
+import org.hornetq.core.message.LargeMessageEncodingContext;
+import org.hornetq.core.message.PropertyConversionException;
 import org.hornetq.core.paging.PagingStore;
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.BindingType;
 import org.hornetq.core.postoffice.impl.BindingsImpl;
 import org.hornetq.core.remoting.spi.HornetQBuffer;
-import org.hornetq.core.server.*;
+import org.hornetq.core.server.Bindable;
+import org.hornetq.core.server.MessageReference;
+import org.hornetq.core.server.Queue;
+import org.hornetq.core.server.RoutingContext;
+import org.hornetq.core.server.ServerMessage;
 import org.hornetq.core.server.impl.RoutingContextImpl;
 import org.hornetq.core.transaction.Transaction;
 import org.hornetq.core.transaction.TransactionOperation;
-import org.hornetq.core.message.LargeMessageEncodingContext;
 import org.hornetq.tests.util.UnitTestCase;
 import org.hornetq.utils.SimpleString;
 import org.hornetq.utils.TypedProperties;
@@ -289,7 +294,7 @@
       public void setOriginalHeaders(ServerMessage other, boolean expiry)
       {
          // TODO Auto-generated method stub
-         
+
       }
 
       public Map<String, Object> toMap()
@@ -455,7 +460,7 @@
 
       public void encodeBody(HornetQBuffer bufferOut, LargeMessageEncodingContext context, int size)
       {
-         //To change body of implemented methods use File | Settings | File Templates.
+         // To change body of implemented methods use File | Settings | File Templates.
       }
 
       /* (non-Javadoc)
@@ -680,6 +685,24 @@
       {
 
       }
+      
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#putObjectProperty(org.hornetq.utils.SimpleString, java.lang.Object)
+       */
+      public void putObjectProperty(SimpleString key, Object value)
+      {
+         // TODO Auto-generated method stub
+         
+      }
+      
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#putObjectProperty(java.lang.String, java.lang.Object)
+       */
+      public void putObjectProperty(String key, Object value)
+      {
+         // TODO Auto-generated method stub
+         
+      }
 
       /* (non-Javadoc)
        * @see org.hornetq.core.message.Message#putTypedProperties(org.hornetq.utils.TypedProperties)
@@ -774,16 +797,16 @@
        */
       public boolean containsProperty(String key)
       {
-         
+
          return false;
       }
 
       /* (non-Javadoc)
        * @see org.hornetq.core.message.Message#getProperty(java.lang.String)
        */
-      public Object getProperty(String key)
+      public Object getObjectProperty(String key)
       {
-         
+
          return null;
       }
 
@@ -792,8 +815,7 @@
        */
       public void putBooleanProperty(String key, boolean value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -801,8 +823,7 @@
        */
       public void putByteProperty(String key, byte value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -810,8 +831,7 @@
        */
       public void putBytesProperty(String key, byte[] value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -819,8 +839,7 @@
        */
       public void putDoubleProperty(String key, double value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -828,8 +847,7 @@
        */
       public void putFloatProperty(String key, float value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -837,8 +855,7 @@
        */
       public void putIntProperty(String key, int value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -846,8 +863,7 @@
        */
       public void putLongProperty(String key, long value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -855,8 +871,7 @@
        */
       public void putShortProperty(String key, short value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -864,8 +879,7 @@
        */
       public void putStringProperty(String key, String value)
       {
-         
-         
+
       }
 
       /* (non-Javadoc)
@@ -873,11 +887,101 @@
        */
       public Object removeProperty(String key)
       {
-         
+
          return null;
       }
 
       /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getStringProperty(org.hornetq.utils.SimpleString)
+       */
+      public String getStringProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getBooleanProperty(org.hornetq.utils.SimpleString)
+       */
+      public Boolean getBooleanProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return false;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getByteProperty(org.hornetq.utils.SimpleString)
+       */
+      public Byte getByteProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getBytesProperty(org.hornetq.utils.SimpleString)
+       */
+      public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+      
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getDoubleProperty(org.hornetq.utils.SimpleString)
+       */
+      public Double getDoubleProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0.0;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getFloatProperty(org.hornetq.utils.SimpleString)
+       */
+      public Float getFloatProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0f;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getIntProperty(org.hornetq.utils.SimpleString)
+       */
+      public Integer getIntProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getLongProperty(org.hornetq.utils.SimpleString)
+       */
+      public Long getLongProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0L;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getObjectProperty(org.hornetq.utils.SimpleString)
+       */
+      public Object getObjectProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.message.Message#getShortProperty(org.hornetq.utils.SimpleString)
+       */
+      public Short getShortProperty(SimpleString key)
+      {
+         // TODO Auto-generated method stub
+         return 0;
+      }
+
+      /* (non-Javadoc)
        * @see org.hornetq.core.server.ServerMessage#decrementRefCount(org.hornetq.core.paging.PagingStore, org.hornetq.core.server.MessageReference)
        */
       public int decrementRefCount(PagingStore pagingStore, MessageReference reference) throws Exception
@@ -1058,7 +1162,7 @@
       public void route(ServerMessage message, RoutingContext context) throws Exception
       {
          // TODO Auto-generated method stub
-         
+
       }
 
    }

Modified: trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java	2009-11-05 14:23:20 UTC (rev 8223)
+++ trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java	2009-11-05 14:38:23 UTC (rev 8224)
@@ -47,7 +47,7 @@
  * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
  *
  */
-public class ServiceTestBase extends UnitTestCase
+public abstract class ServiceTestBase extends UnitTestCase
 {
 
    // Constants -----------------------------------------------------



More information about the hornetq-commits mailing list