qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgr...@apache.org
Subject svn commit: r488163 [3/4] - in /incubator/qpid/branches/new_persistence/java: ./ broker/ broker/bin/ broker/etc/ broker/src/main/java/org/apache/qpid/server/ broker/src/main/java/org/apache/qpid/server/exchange/ broker/src/main/java/org/apache/qpid/ser...
Date Mon, 18 Dec 2006 09:11:14 GMT
Modified: incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java Mon Dec 18 01:10:59 2006
@@ -23,10 +23,10 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.PropertyFieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.AMQException;
 
 import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
 import java.util.Enumeration;
 
 public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessage
@@ -58,7 +58,7 @@
 
         try
         {
-            _map = new PropertyFieldTable(getText());
+            _map = FieldTableFactory.newFieldTable(getText());
         }
         catch (JMSException e)
         {
@@ -68,7 +68,7 @@
 
     // AbstractJMSMessage Interface
 
-    public void clearBody() throws JMSException
+    public void clearBodyImpl() throws JMSException
     {
         if (_data != null)
         {
@@ -206,48 +206,55 @@
 
     public void setBoolean(String string, boolean b) throws JMSException
     {
+        checkWritable();
         _map.setBoolean(string, b);
     }
 
     public void setByte(String string, byte b) throws JMSException
     {
+        checkWritable();
         _map.setByte(string, b);
     }
 
     public void setShort(String string, short i) throws JMSException
     {
+        checkWritable();
         _map.setShort(string, i);
     }
 
     public void setChar(String string, char c) throws JMSException
     {
+        checkWritable();
         _map.setChar(string, c);
     }
 
     public void setInt(String string, int i) throws JMSException
     {
+        checkWritable();
         _map.setInteger(string, i);
     }
 
     public void setLong(String string, long l) throws JMSException
     {
+        checkWritable();
         _map.setLong(string, l);
     }
 
     public void setFloat(String string, float v) throws JMSException
     {
-
+        checkWritable();
         _map.setFloat(string, v);
     }
 
     public void setDouble(String string, double v) throws JMSException
     {
-
+        checkWritable();
         _map.setDouble(string, v);
     }
 
     public void setString(String string, String string1) throws JMSException
     {
+        checkWritable();
         _map.setString(string, string1);
     }
 
@@ -258,11 +265,13 @@
 
     public void setBytes(String string, byte[] bytes, int i, int i1) throws JMSException
     {
+        checkWritable();
         _map.setBytes(string, bytes, i, i1);
     }
 
     public void setObject(String string, Object object) throws JMSException
     {
+        checkWritable();
         _map.setObject(string, object);
     }
 

Modified: incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java Mon Dec 18 01:10:59 2006
@@ -36,7 +36,6 @@
 public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessage
 {
     static final String MIME_TYPE = "application/java-object-stream";
-    private final boolean _readonly;
 
     private static final int DEFAULT_BUFFER_SIZE = 1024;
 
@@ -56,7 +55,6 @@
             _data = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
             _data.setAutoExpand(true);
         }
-        _readonly = (data != null);
         getJmsContentHeaderProperties().setContentType(MIME_TYPE);
     }
 
@@ -66,10 +64,9 @@
     JMSObjectMessage(long messageNbr, ContentHeaderBody contentHeader, ByteBuffer data) throws AMQException
     {
         super(messageNbr, (BasicContentHeaderProperties) contentHeader.properties, data);
-        _readonly = data != null;
     }
 
-    public void clearBody() throws JMSException
+    public void clearBodyImpl() throws JMSException
     {
         if (_data != null)
         {
@@ -90,10 +87,7 @@
 
     public void setObject(Serializable serializable) throws JMSException
     {
-        if (_readonly)
-        {
-            throw new MessageNotWriteableException("Message is not writable.");
-        }
+        checkWritable();
 
         if (_data == null)
         {

Modified: incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java Mon Dec 18 01:10:59 2006
@@ -66,7 +66,7 @@
         setText(text);
     }
 
-    public void clearBody() throws JMSException
+    public void clearBodyImpl() throws JMSException
     {
         if (_data != null)
         {
@@ -93,6 +93,8 @@
 
     public void setText(String string) throws JMSException
     {
+        checkWritable();
+        
         clearBody();
         try
         {

Modified: incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java Mon Dec 18 01:10:59 2006
@@ -21,6 +21,7 @@
 package org.apache.qpid.client.security.amqplain;
 
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
@@ -71,7 +72,7 @@
         {
             throw new SaslException("Error handling SASL callbacks: " + e, e);
         }
-        FieldTable table = new FieldTable();
+        FieldTable table = FieldTableFactory.newFieldTable();
         table.put("LOGIN", nameCallback.getName());
         table.put("PASSWORD", pwdCallback.getPassword());
         return table.getDataAsBytes();

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/client/message/TestMessageHelper.java Mon Dec 18 01:10:59 2006
@@ -39,7 +39,7 @@
         return new JMSMapMessage();
     }
 
-    public static JMSStreamMessage newJMSStreamMessage() throws JMSException
+    public static JMSStreamMessage newJMSStreamMessage()
     {
         return new JMSStreamMessage();
     }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPAdministrator.java Mon Dec 18 01:10:59 2006
@@ -41,7 +41,7 @@
  * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
  *
  */
-package org.exolab.jmscts.amqp;
+package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
 
 import org.apache.qpid.client.*;
 import org.exolab.jmscts.provider.Administrator;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/cts/src/providers/amqp/org/exolab/jmscts/amqp/AMQPProvider.java Mon Dec 18 01:10:59 2006
@@ -41,7 +41,7 @@
  * Copyright 2001, 2003 (C) Exoffice Technologies Inc. All Rights Reserved.
  *
  */
-package org.exolab.jmscts.amqp;
+package org.apache.qpid.cts.src.providers.amqp.org.exolab.jmscts.amqp;
 
 import javax.jms.JMSException;
 

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/FileMessageDispatcher.java Mon Dec 18 01:10:59 2006
@@ -19,7 +19,7 @@
 package org.apache.qpid.example.publisher;
 
 import org.apache.log4j.Logger;
-import java.util.Properties;
+
 import java.io.File;
 
 import org.apache.qpid.example.shared.FileUtils;
@@ -34,12 +34,17 @@
  */
 public class FileMessageDispatcher {
 
-    private static final Logger _logger = Logger.getLogger(FileMessageDispatcher.class);
-
-    private static Publisher _publisher = null;
+    protected static final Logger _logger = Logger.getLogger(FileMessageDispatcher.class);
 
-    private static final String DEFAULT_PUB_NAME = "Publisher";
+    protected static Publisher _publisher = null;
 
+    /**
+     * To use this main method you need to specify a path or file to use for input
+     * This class then uses file contents from the dir/file specified to generate
+     * messages to publish
+     * Intended to be a very simple way to get going with publishing using the broker
+     * @param args - must specify one value, the path to file(s) for publisher
+     */
     public static void main(String[] args)
     {
 
@@ -52,7 +57,7 @@
         {
             try
             {
-                //publish message(s) from file(s) and send message to monitor queue
+                //publish message(s) from file(s) to configured queue
                 publish(args[0]);
 
                 //Move payload file(s) to archive location as no error
@@ -60,7 +65,8 @@
             }
             catch(Exception e)
             {
-                System.err.println("Error trying to dispatch message: " + e);
+                //log error and exit
+                _logger.error("Error trying to dispatch message: " + e);
                 System.exit(1);
             }
             finally
@@ -81,8 +87,12 @@
         System.exit(0);
     }
 
-
-    //Publish files or file as message
+    /**
+     * Publish the content of a file or files from a directory as messages
+     * @param path - from main args
+     * @throws JMSException
+     * @throws MessageFactoryException - if cannot create message from file content
+     */
     public static void publish(String path) throws JMSException, MessageFactoryException
     {
         File tempFile = new File(path);
@@ -100,7 +110,7 @@
                 for (File file : files)
                 {
                     //Create message factory passing in payload path
-                    MessageFactory factory = new MessageFactory(getPublisher().getSession(), file.toString());
+                    FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(), file.toString());
 
                     //Send the message generated from the payload using the _publisher
                     getPublisher().sendMessage(factory.createEventMessage());
@@ -110,16 +120,18 @@
         }
         else
         {
-            //handle as single file
+            //handle a single file
             //Create message factory passing in payload path
-            MessageFactory factory = new MessageFactory(getPublisher().getSession(),tempFile.toString());
+            FileMessageFactory factory = new FileMessageFactory(getPublisher().getSession(),tempFile.toString());
 
             //Send the message generated from the payload using the _publisher
             getPublisher().sendMessage(factory.createEventMessage());
         }
     }
 
-    //cleanup publishers
+    /**
+     * Cleanup before exit
+     */
     public static void cleanup()
     {
         if (getPublisher() != null)
@@ -128,8 +140,8 @@
         }
     }
 
-    /*
-     * Returns a _publisher for a queue
+    /**
+     * @return A Publisher instance
      */
     private static Publisher getPublisher()
     {
@@ -141,7 +153,6 @@
        //Create a _publisher
        _publisher = new Publisher();
 
-       _publisher.setName(DEFAULT_PUB_NAME);
        return _publisher;
     }
 

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java Mon Dec 18 01:10:59 2006
@@ -20,8 +20,9 @@
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.BasicConfigurator;
-import org.apache.qpid.example.shared.Statics;
+
 import javax.jms.*;
+
 import java.util.Properties;
 
 /**
@@ -32,14 +33,18 @@
 
     private static final Logger _logger = Logger.getLogger(MonitorMessageDispatcher.class);
 
-    private static MonitorPublisher _monitorPublisher = null;
+    protected static MonitorPublisher _monitorPublisher = null;
 
-    private static final String DEFAULT_MONITOR_PUB_NAME = "MonitorPublisher";
+    protected static final String DEFAULT_MONITOR_PUB_NAME = "MonitorPublisher";
 
+    /**
+     * Easy entry point for running a message dispatcher for monitoring consumption
+     * @param args
+     */
     public static void main(String[] args)
     {
 
-        //@TODO switch on logging appropriately at your app level
+        //Switch on logging appropriately for your app
         BasicConfigurator.configure();
 
         try
@@ -61,7 +66,7 @@
                 }
                 catch(UndeliveredMessageException a)
                 {
-                    //@TODO trigger application specific failure handling here
+                    //trigger application specific failure handling here
                     _logger.error("Problem delivering monitor message");
                     break;
                 }
@@ -69,8 +74,7 @@
         }
         catch(Exception e)
         {
-
-            System.err.println("Error trying to dispatch AMS monitor message: " + e);
+            _logger.error("Error trying to dispatch AMS monitor message: " + e);
             System.exit(1);
         }
         finally
@@ -84,15 +88,21 @@
         System.exit(1);
     }
 
-    //Publish heartbeat message
+    /**
+     * Publish heartbeat message
+     * @throws JMSException
+     * @throws UndeliveredMessageException
+     */
     public static void publish() throws JMSException, UndeliveredMessageException
     {
         //Send the message generated from the payload using the _publisher
         getMonitorPublisher().sendImmediateMessage
-          (MessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
+          (FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
     }
 
-    //cleanup publishers
+    /**
+     * Cleanup publishers
+     */
     public static void cleanup()
     {
         if (getMonitorPublisher() != null)
@@ -113,9 +123,6 @@
        {
            return _monitorPublisher;
        }
-
-       //Create _publisher using system properties
-       Properties props = System.getProperties();
 
        //Create a _publisher using failover details and constant for monitor queue
        _monitorPublisher = new MonitorPublisher();

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/publisher/Publisher.java Mon Dec 18 01:10:59 2006
@@ -22,14 +22,14 @@
 
 import org.apache.qpid.client.AMQConnectionFactory;
 
-import org.apache.qpid.jms.Session;
-
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.DeliveryMode;
 import javax.jms.Queue;
 import javax.jms.MessageProducer;
 import javax.jms.Connection;
+import javax.jms.Session;
+
 import javax.naming.InitialContext;
 
 import org.apache.qpid.example.shared.InitialContextHelper;
@@ -44,7 +44,7 @@
 
     protected Session _session;
 
-    private MessageProducer _producer;
+    protected MessageProducer _producer;
 
     protected String _destinationDir;
 
@@ -54,7 +54,10 @@
 
     protected static final String _defaultDestinationDir = "/tmp";
 
-    //constructor for use with a single host
+    /**
+     * Creates a Publisher instance using properties from example.properties
+     * See InitialContextHelper for details of how context etc created
+     */
     public Publisher()
     {
         try
@@ -68,7 +71,7 @@
             _connection = cf.createConnection();
 
             //create a transactional session
-            _session = (Session) _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
+            _session = _connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
 
             //lookup the example queue and use it
             //Queue is non-exclusive and not deleted when last consumer detaches
@@ -90,8 +93,9 @@
     }
 
     /**
-    * Publishes a non-persistent message using transacted session
-    **/
+     * Publishes a non-persistent message using transacted session
+     * Note that persistent is the default mode for send - so need to specify for transient
+     */
     public boolean sendMessage(Message message)
     {
         try
@@ -124,6 +128,9 @@
         return true;
     }
 
+    /**
+     * Cleanup resources before exit
+     */
     public void cleanup()
     {
         try
@@ -138,11 +145,15 @@
         }
         catch(Exception e)
         {
-            System.err.println("Error trying to cleanup publisher " + e);
+            _log.error("Error trying to cleanup publisher " + e);
             System.exit(1);
         }
     }
 
+    /**
+     * Exposes session
+     * @return  Session
+     */
     public Session getSession()
     {
         return _session;

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriber.java Mon Dec 18 01:10:59 2006
@@ -42,6 +42,9 @@
         _monitorDestinationName = _destinationName + Statics.MONITOR_QUEUE_SUFFIX;
     }
 
+    /**
+     * MessageListener implementation for this subscriber
+     */
     public static class MonitorMessageListener implements MessageListener
     {
         private String _name;
@@ -52,9 +55,10 @@
 
         }
 
-        /*
-        * Listens for heartbeat messages and acknowledges them
-        */
+        /**
+         * Listens for heartbeat messages and acknowledges them
+         * @param message
+         */
         public void onMessage(javax.jms.Message message)
         {
             _logger.info(_name + " monitor got message '" + message + "'");
@@ -79,9 +83,9 @@
         }
     }
 
-    /*
-    * Subscribes to Queue and attaches additional monitor listener
-    */
+    /**
+     * Subscribes to Queue and attaches additional monitor listener
+     */
     public void subscribeAndMonitor()
     {
         try
@@ -115,7 +119,9 @@
         }
     }
 
-    //stop consuming
+    /**
+     * Stop consuming
+     */
     public void stopMonitor()
     {
         try

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/MonitoredSubscriptionWrapper.java Mon Dec 18 01:10:59 2006
@@ -19,9 +19,6 @@
 package org.apache.qpid.example.subscriber;
 
 import org.apache.log4j.BasicConfigurator;
-import org.apache.qpid.example.shared.Statics;
-
-import java.util.Properties;
 
 /**
  * Allows you to simply start a monitored subscriber
@@ -30,6 +27,10 @@
 
     private static MonitoredSubscriber _subscriber;
 
+    /**
+     * Create a monitored subscriber and start it
+     * @param args - no params required
+     */
     public static void main(String args[])
     {
         //switch on logging
@@ -37,15 +38,12 @@
 
         _subscriber = new MonitoredSubscriber();
 
-        //using system props but can replace with app appropriate config here
-        Properties props = System.getProperties();
-
-        //note that for failover should set -Dhost=host1:port1;host2:port2
-        //Client will then failover in order i.e. connect to first host and failover to second and so on
         _subscriber.subscribe();
     }
 
-    //Stop subscribing now ...
+    /**
+     * Stop subscribing now ...
+     */
     public static void stop()
     {
         _subscriber.stop();

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/Subscriber.java Mon Dec 18 01:10:59 2006
@@ -69,9 +69,9 @@
         }
     }
 
-    /*
-    * Listener class that handles messages
-    */
+    /**
+     * Listener class that handles messages
+     */
     public static class ExampleMessageListener implements MessageListener
     {
         private String _name;
@@ -82,10 +82,10 @@
 
         }
 
-        /*
-        * Listens for message callbacks, handles and then acknowledges them
-        * @param message - the message received
-        */
+        /**
+         * Listens for message callbacks, handles and then acknowledges them
+         * @param message - the message received
+         */
         public void onMessage(javax.jms.Message message)
         {
             _log.info(_name + " got message '" + message + "'");
@@ -113,9 +113,9 @@
         }
     }
 
-    /*
-    * Subscribes to example Queue and attaches listener
-    */
+    /**
+     * Subscribes to example Queue and attaches listener
+     */
     public void subscribe()
     {
         _log.info("Starting subscription ...");
@@ -160,14 +160,18 @@
         }
     }
 
+    /**
+     * Set destination (queue or topic) name
+     * @param name
+     */
     public void setDestinationName(String name)
     {
         _destinationName = name;
     }
 
-    /*
-    * stop consuming and close connection
-    */
+    /**
+     * Stop consuming and close connection
+     */
     public void stop()
     {
         try

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/example/subscriber/SubscriptionWrapper.java Mon Dec 18 01:10:59 2006
@@ -18,10 +18,6 @@
  */
 package org.apache.qpid.example.subscriber;
 
-import org.apache.qpid.example.shared.Statics;
-
-import java.util.Properties;
-
 import org.apache.log4j.BasicConfigurator;
 
 /**
@@ -31,6 +27,10 @@
 
     private static Subscriber _subscriber;
 
+    /**
+     * Create a subscriber and start it
+     * @param args
+     */
     public static void main(String args[])
     {
         //switch on logging
@@ -38,15 +38,12 @@
         
          _subscriber = new Subscriber();
 
-        //using system props but can replace with app appropriate config here
-        Properties props = System.getProperties();
-
-        //note that for failover should set -Dhost=host1:port1;host2:port2
-        //Client will then failover in order i.e. connect to first host and failover to second and so on
         _subscriber.subscribe();
     }
 
-    //Stop subscribing now ...
+    /**
+     * Stop subscribing now ...
+     */
     public static void stop()
     {
         _subscriber.stop();

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/framing/FieldTableTest.java Mon Dec 18 01:10:59 2006
@@ -33,6 +33,33 @@
 
 public class FieldTableTest extends TestCase
 {
+
+    public void testEncoding()
+    {
+        FieldTable table = FieldTableFactory.newFieldTable();
+
+        String key = "String";
+        String value = "Hello";
+        table.put(key, value);
+
+        //Add one for the type encoding
+        int size = EncodingUtils.encodedShortStringLength(key) + 1 +
+                   EncodingUtils.encodedLongStringLength(value);
+
+        assertEquals(table.getEncodedSize(), size);
+        
+        key = "Integer";
+        Integer number = new Integer(60);
+        table.put(key, number);
+
+        //Add one for the type encoding
+        size += EncodingUtils.encodedShortStringLength(key) + 1 + 4;
+
+
+        assertEquals(table.getEncodedSize(), size);
+    }
+
+
     public void testDataDump() throws IOException, AMQFrameDecodingException
     {
         byte[] data = readBase64("content.txt");
@@ -46,7 +73,7 @@
         ByteBuffer buffer = ByteBuffer.allocate(data.length);
         buffer.put(data);
         buffer.flip();
-        FieldTable table = new FieldTable(buffer, size);
+        FieldTable table = FieldTableFactory.newFieldTable(buffer, size);
     }
 
     /*
@@ -107,7 +134,7 @@
 
     FieldTable load(String name) throws IOException
     {
-        return populate(new FieldTable(), read(name));
+        return populate(FieldTableFactory.newFieldTable(), read(name));
     }
 
     Properties read(String name) throws IOException
@@ -123,11 +150,12 @@
         {
             String key = (String) i.nextElement();
             String value = properties.getProperty(key);
-            try{
+            try
+            {
                 int ival = Integer.parseInt(value);
                 table.put(key, (long) ival);
             }
-            catch(NumberFormatException e)
+            catch (NumberFormatException e)
             {
                 table.put(key, value);
             }
@@ -144,7 +172,8 @@
     {
         StringBuffer buffer = new StringBuffer();
         String line = in.readLine();
-        while (line != null){
+        while (line != null)
+        {
             buffer.append(line).append(" ");
             line = in.readLine();
         }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/headers/MessageFactory.java Mon Dec 18 01:10:59 2006
@@ -22,6 +22,7 @@
 
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 
 import javax.jms.BytesMessage;
 import javax.jms.Destination;
@@ -127,14 +128,14 @@
 
     FieldTable getConsumerBinding()
     {
-        FieldTable binding = new FieldTable();
+        FieldTable binding = FieldTableFactory.newFieldTable();
         binding.put("SF0000", "value");
         return binding;
     }
 
     FieldTable getControllerBinding()
     {
-        FieldTable binding = new FieldTable();
+        FieldTable binding = FieldTableFactory.newFieldTable();
         binding.put("SCONTROL", "value");
         return binding;
     }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/requestreply1/ServiceRequestingClient.java Mon Dec 18 01:10:59 2006
@@ -107,6 +107,7 @@
             }
             try
             {
+                m.getPropertyNames();
                 if (m.propertyExists("timeSent"))
                 {
                     long timeSent = Long.parseLong(m.getStringProperty("timeSent"));

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java Mon Dec 18 01:10:59 2006
@@ -135,6 +135,8 @@
             buffer.get(data);
             actual.add(data);
 
+
+            //Check Body Write Status
             try
             {
                 m.writeBoolean(true);
@@ -144,6 +146,41 @@
             {
                 //normal execution
             }
+
+            m.clearBody();
+
+            try
+            {
+                m.writeBoolean(true);
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
+
+
+            //Check property write status
+            try
+            {
+                m.setStringProperty("test", "test");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearProperties();
+
+            try
+            {
+                m.setStringProperty("test", "test");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
+
         }
 
         assertEqual(messages.iterator(), actual.iterator());

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java Mon Dec 18 01:10:59 2006
@@ -21,10 +21,13 @@
 package org.apache.qpid.test.unit.basic;
 
 import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.client.message.JMSTextMessage;
 import org.apache.qpid.client.message.TestMessageHelper;
 
 import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import javax.jms.JMSException;
 
@@ -34,20 +37,28 @@
 {
     public void testKeyEnumeration()
     {
-        FieldTable result = new FieldTable();
+        FieldTable result = FieldTableFactory.newFieldTable();
         result.put("one", 1L);
         result.put("two", 2L);
         result.put("three", 3L);
         result.put("four", 4L);
         result.put("five", 5L);
 
-        Enumeration e = result.keys();
+        Iterator iterator = result.keySet().iterator();
+
+        try
+        {
+            assertTrue("one".equals(iterator.next()));
+            assertTrue("two".equals(iterator.next()));
+            assertTrue("three".equals(iterator.next()));
+            assertTrue("four".equals(iterator.next()));
+            assertTrue("five".equals(iterator.next()));
+        }
+        catch (NoSuchElementException e)
+        {
+            fail("All elements should be found.");
+        }
 
-        assertTrue("one".equals(e.nextElement()));
-        assertTrue("two".equals(e.nextElement()));
-        assertTrue("three".equals(e.nextElement()));
-        assertTrue("four".equals(e.nextElement()));
-        assertTrue("five".equals(e.nextElement()));
     }
 
     public void testPropertEnu()

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java Mon Dec 18 01:10:59 2006
@@ -26,10 +26,12 @@
 import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.message.JMSBytesMessage;
 import org.apache.qpid.framing.AMQFrameDecodingException;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.FieldTableTest;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.test.VMBrokerSetup;
 import org.apache.mina.common.ByteBuffer;
+import org.apache.log4j.Logger;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -39,6 +41,9 @@
 
 public class FieldTableMessageTest extends TestCase implements MessageListener
 {
+
+    private static final Logger _logger = Logger.getLogger(FieldTableMessageTest.class);
+
     private AMQConnection _connection;
     private AMQDestination _destination;
     private AMQSession _session;
@@ -50,7 +55,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-        init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));        
+        init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
     }
 
     protected void tearDown() throws Exception
@@ -80,7 +85,7 @@
 
     private FieldTable load() throws IOException
     {
-        FieldTable result = new FieldTable();
+        FieldTable result = FieldTableFactory.newFieldTable();
         result.put("one", 1L);
         result.put("two", 2L);
         result.put("three", 3L);
@@ -128,7 +133,7 @@
         for (Object m : received)
         {
             ByteBuffer buffer = ((JMSBytesMessage) m).getData();
-            FieldTable actual = new FieldTable(buffer, buffer.remaining());
+            FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
             new FieldTableTest().assertEquivalent(_expected, actual);
         }
     }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java Mon Dec 18 01:10:59 2006
@@ -47,6 +47,7 @@
     private final List<String> messages = new ArrayList<String>();
     private int _count = 100;
     public String _connectionString = "vm://:1";
+    private byte[] _bytes = {99, 98, 97, 96, 95};
 
     protected void setUp() throws Exception
     {
@@ -104,9 +105,31 @@
             MapMessage message = _session.createMapMessage();
 
             message.setBoolean("odd", i / 2 == 0);
+            message.setByte("byte", (byte) Byte.MAX_VALUE);
+
+            message.setBytes("bytes", _bytes);
+            message.setChar("char", (char) 'c');
+            message.setDouble("double", (double) Double.MAX_VALUE);
+            message.setFloat("float", (float) Float.MAX_VALUE);
+
             message.setInt("messageNumber", i);
+            message.setInt("int", (int) Integer.MAX_VALUE);
+
+            message.setLong("long", (long) Long.MAX_VALUE);
+            message.setShort("short", (short) Short.MAX_VALUE);
             message.setString("message", text);
 
+
+            message.setObject("object-bool", true);
+            message.setObject("object-byte", Byte.MAX_VALUE);
+            message.setObject("object-bytes", _bytes);
+            message.setObject("object-char", 'c');
+            message.setObject("object-double", Double.MAX_VALUE);
+            message.setObject("object-float", Float.MAX_VALUE);
+            message.setObject("object-int", Integer.MAX_VALUE);
+            message.setObject("object-long", Long.MAX_VALUE);
+            message.setObject("object-short", Short.MAX_VALUE);
+
             producer.send(message);
         }
     }
@@ -130,24 +153,91 @@
         {
             actual.add(m.getString("message"));
             assertEqual(m.getInt("messageNumber"), count);
-            assertEqual(m.getBoolean("odd"), count / 2 == 0);
 
-//            try
-//            {
-//                m.setInt("testint", 3);
-//                fail("Message should not be writeable");
-//            }
-//            catch (MessageNotWriteableException mnwe)
-//            {
-//                //normal execution
-//            }
 
+            assertEqual(count / 2 == 0, m.getBoolean("odd"));
+            assertEqual((byte) Byte.MAX_VALUE, m.getByte("byte"));
+
+            assertBytesEqual(_bytes, m.getBytes("bytes"));
+            assertEqual((char) 'c', m.getChar("char"));
+            assertEqual((double) Double.MAX_VALUE, m.getDouble("double"));
+            assertEqual((float) Float.MAX_VALUE, m.getFloat("float"));
+
+            assertEqual(count, m.getInt("messageNumber"));
+            assertEqual((int) Integer.MAX_VALUE, m.getInt("int"));
+            assertEqual((long) Long.MAX_VALUE, m.getLong("long"));
+            assertEqual((short) Short.MAX_VALUE, m.getShort("short"));
+
+            assertEqual(true, m.getObject("object-bool"));
+            assertEqual(Byte.MAX_VALUE, m.getObject("object-byte"));
+            assertBytesEqual(_bytes, (byte[]) m.getObject("object-bytes"));
+            assertEqual('c', m.getObject("object-char"));
+            assertEqual(Double.MAX_VALUE, m.getObject("object-double"));
+            assertEqual(Float.MAX_VALUE, m.getObject("object-float"));
+            assertEqual(Integer.MAX_VALUE, m.getObject("object-int"));
+            assertEqual(Long.MAX_VALUE, m.getObject("object-long"));
+            assertEqual(Short.MAX_VALUE, m.getObject("object-short"));
+
+
+            try
+            {
+                m.setInt("testint", 3);
+                fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearBody();
+
+            try
+            {
+                m.setInt("testint", 3);
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
+
+            //Check property write status
+            try
+            {
+                m.setStringProperty("test", "test");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearProperties();
+
+            try
+            {
+                m.setStringProperty("test", "test");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
 
             count++;
         }
 
         assertEqual(messages.iterator(), actual.iterator());
     }
+
+    private void assertBytesEqual(byte[] expected, byte[] actual)
+    {
+        Assert.assertEquals(expected.length, actual.length);
+
+        for (int index = 0; index < expected.length; index++)
+        {
+            Assert.assertEquals(expected[index], actual[index]);
+        }
+    }
+
 
     private static void assertEqual(Iterator expected, Iterator actual)
     {

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java Mon Dec 18 01:10:59 2006
@@ -125,19 +125,53 @@
         {
             actual.add(m.getObject());
 
-//            try
-//            {
-//                m.setObject("Test text");
-//                Assert.fail("Message should not be writeable");
-//            }
-//            catch (MessageNotWriteableException mnwe)
-//            {
-//                //normal execution
-//            }
+            try
+            {
+                m.setObject("Test text");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearBody();
+
+            try
+            {
+                m.setObject("Test text");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
+
+              //Check property write status
+            try
+            {
+                m.setStringProperty("test", "test");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearProperties();
+
+            try
+            {
+                m.setStringProperty("test", "test");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
 
         }
 
         assertEqual(messages.iterator(), actual.iterator());
+
     }
 
     private static void assertEqual(Iterator expected, Iterator actual)

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java Mon Dec 18 01:10:59 2006
@@ -28,6 +28,7 @@
 import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.client.message.JMSTextMessage;
 import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.log4j.Logger;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -39,6 +40,8 @@
 
 public class TextMessageTest extends TestCase implements MessageListener
 {
+    private static final Logger _logger = Logger.getLogger(TextMessageTest.class);
+
     private AMQConnection _connection;
     private Destination _destination;
     private AMQSession _session;
@@ -100,7 +103,11 @@
         {
             String text = "Message " + i;
             messages.add(text);
-            producer.send(_session.createTextMessage(text));
+            Message m = _session.createTextMessage(text);
+            m.setStringProperty("String", "hello");
+
+            _logger.info("Sending Msg:" + m);
+            producer.send(m);
         }
     }
 
@@ -122,15 +129,49 @@
         {
             actual.add(m.getText());
 
-//            try
-//            {
-//                m.setText("Test text");
-//                Assert.fail("Message should not be writeable");
-//            }
-//            catch (MessageNotWriteableException mnwe)
-//            {
-//                //normal execution
-//            }
+            //Check body write status            
+            try
+            {
+                m.setText("Test text");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearBody();
+
+            try
+            {
+                m.setText("Test text");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
+
+            //Check property write status
+            try
+            {
+                m.setStringProperty("test", "test");
+                Assert.fail("Message should not be writeable");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                //normal execution
+            }
+
+            m.clearProperties();
+
+            try
+            {
+                m.setStringProperty("test", "test");
+            }
+            catch (MessageNotWriteableException mnwe)
+            {
+                Assert.fail("Message should be writeable");
+            }
 
         }
 

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connection/ConnectionTest.java Mon Dec 18 01:10:59 2006
@@ -22,12 +22,10 @@
 
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQAuthenticationException;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
 import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQConnectionException;
 import org.apache.qpid.AMQUnresolvedAddressException;
-import org.apache.qpid.test.VMBrokerSetup;
 
 import javax.jms.Connection;
 
@@ -40,6 +38,18 @@
     String _broker_NotRunning = "vm://:2";
     String _broker_BadDNS = "tcp://hg3sgaaw4lgihjs";
 
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        TransportConnection.createVMBroker(1);
+    }
+
+    protected void tearDown() throws Exception
+    {
+        TransportConnection.killAllVMBrokers();
+    }
+
     public void testSimpleConnection()
     {
         try
@@ -102,8 +112,30 @@
         }
     }
 
+    public void testClientIdCannotBeChanged() throws Exception
+    {
+        Connection connection = new AMQConnection(_broker, "guest", "guest",
+                                                  "fred", "/test");
+        try
+        {
+            connection.setClientID("someClientId");
+            fail("No IllegalStateException thrown when resetting clientid");
+        }
+        catch (javax.jms.IllegalStateException e)
+        {
+            // PASS
+        }
+    }
+
+    public void testClientIdIsPopulatedAutomatically() throws Exception
+    {
+        Connection connection = new AMQConnection(_broker, "guest", "guest",
+                                                  null, "/test");
+        assertNotNull(connection.getClientID());
+    }
+
     public static junit.framework.Test suite()
     {
-        return new VMBrokerSetup(new junit.framework.TestSuite(ConnectionTest.class));
+        return new junit.framework.TestSuite(ConnectionTest.class);
     }
 }

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java Mon Dec 18 01:10:59 2006
@@ -310,29 +310,7 @@
         assertTrue(connectionurl.getBrokerCount() == 1);
     }
 
-    // FIXME Connection now parses but result is wrong QPID-71
-    /*
-    public void testWrongOptionSeparatorInBroker()
-    {
-        String url = "amqp://user:@/test?brokerlist='tcp://localhost:5672+option='value''";
-
-        try
-        {
-            AMQConnectionURL connection = new AMQConnectionURL(url);
 
-            Float version = Float.parseFloat(System.getProperty("java.specification.version"));
-            if (version > 1.5)
-            {
-                fail("URL Should not parse on Java " + version + " Connection is:" + connection);
-            }
-        }
-        catch (URLSyntaxException urise)
-        {
-            assertTrue(urise.getReason().equals("Illegal character in port number"));
-        }
-
-    }
-    */
 
     public void testWrongOptionSeparatorInOptions()
     {
@@ -349,18 +327,6 @@
 
     }
 
-    public void testTransportsDefaultToTCP() throws URLSyntaxException
-    {
-        String url = "amqp://guest:guest@/test?brokerlist='localhost:5672;myhost:5673'&failover='roundrobin'";
-
-        AMQConnectionURL connection = new AMQConnectionURL(url);
-
-        BrokerDetails broker = connection.getBrokerDetails(0);
-        assertTrue(broker.getTransport().equals("tcp"));
-
-        broker = connection.getBrokerDetails(1);
-        assertTrue(broker.getTransport().equals("tcp"));
-    }
 
     public void testNoUserDetailsProvidedWithClientID()
 

Modified: incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java (original)
+++ incubator/qpid/branches/new_persistence/java/client/src/test/java/org/apache/qpid/test/unit/client/message/ObjectMessageTest.java Mon Dec 18 01:10:59 2006
@@ -24,8 +24,6 @@
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.test.VMBrokerSetup;
 
 import javax.jms.MessageListener;
@@ -36,6 +34,7 @@
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import junit.framework.TestCase;
 
@@ -44,6 +43,7 @@
     private AMQConnection connection;
     private AMQDestination destination;
     private AMQSession session;
+    private MessageProducer producer;
     private Serializable[] data;
     private volatile boolean waiting;
     private int received;
@@ -57,6 +57,13 @@
         connection = new AMQConnection(_broker, "guest", "guest", randomize("Client"), "/test_path");
         destination = new AMQQueue(randomize("LatencyTest"), true);
         session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+
+        //set up a consumer
+        session.createConsumer(destination).setMessageListener(this);
+        connection.start();
+
+        //create a publisher
+         producer = session.createProducer(destination, false, false, true);
         A a1 = new A(1, "A");
         A a2 = new A(2, "a");
         B b = new B(1, "B");
@@ -83,7 +90,7 @@
         _broker = broker;
     }
 
-    public void test() throws Exception
+    public void testSendAndReceive() throws Exception
     {
         try
         {
@@ -102,16 +109,68 @@
         }
     }
 
-    private void send() throws Exception
+    public void testSetObjectPropertyForString() throws Exception
     {
-        //set up a consumer
-        session.createConsumer(destination).setMessageListener(this);
-        connection.start();
+        String testStringProperty = "TestStringProperty";
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestStringProperty",testStringProperty);
+        assertEquals(testStringProperty, msg.getObjectProperty("TestStringProperty"));
+    }
 
-        //create a publisher
-        MessageProducer producer = session.createProducer(destination, false, false, true);
+    public void testSetObjectPropertyForBoolean() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestBooleanProperty",Boolean.TRUE);
+        assertEquals(Boolean.TRUE, msg.getObjectProperty("TestBooleanProperty"));
+    }
 
+    public void testSetObjectPropertyForByte() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestByteProperty",Byte.MAX_VALUE);
+        assertEquals(Byte.MAX_VALUE, msg.getObjectProperty("TestByteProperty"));
+    }
 
+    public void testSetObjectPropertyForShort() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestShortProperty",Short.MAX_VALUE);
+        assertEquals(Short.MAX_VALUE, msg.getObjectProperty("TestShortProperty"));
+    }
+    public void testSetObjectPropertyForInteger() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestIntegerProperty",Integer.MAX_VALUE);
+        assertEquals(Integer.MAX_VALUE, msg.getObjectProperty("TestIntegerProperty"));
+    }
+
+    public void testSetObjectPropertyForDouble() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestDoubleProperty",Double.MAX_VALUE);
+        assertEquals(Double.MAX_VALUE, msg.getObjectProperty("TestDoubleProperty"));
+    }
+
+    public void testSetObjectPropertyForFloat() throws Exception
+    {
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestFloatProperty",Float.MAX_VALUE);
+        assertEquals(Float.MAX_VALUE, msg.getObjectProperty("TestFloatProperty"));
+    }
+
+    public void testSetObjectPropertyForByteArray() throws Exception
+    {
+        byte[] array = {1,2,3,4,5};
+        ObjectMessage msg = session.createObjectMessage(data[0]);
+        msg.setObjectProperty("TestByteArrayProperty",array);
+        assertTrue(Arrays.equals(array,(byte[])msg.getObjectProperty("TestByteArrayProperty")));
+    }
+
+
+
+
+    private void send() throws Exception
+    {
         for (int i = 0; i < data.length; i++)
         {
             ObjectMessage msg;
@@ -207,7 +266,7 @@
         {
             System.out.println("Usage: <broker>");
         }
-        new ObjectMessageTest(broker).test();
+        new ObjectMessageTest(broker).testSendAndReceive();
     }
 
     private static class A implements Serializable

Modified: incubator/qpid/branches/new_persistence/java/cluster/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/cluster/pom.xml?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/cluster/pom.xml (original)
+++ incubator/qpid/branches/new_persistence/java/cluster/pom.xml Mon Dec 18 01:10:59 2006
@@ -53,11 +53,6 @@
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>      
     </dependency>
-    <dependency>
-      <groupId>ant</groupId>
-      <artifactId>ant-junit</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <build>

Modified: incubator/qpid/branches/new_persistence/java/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/pom.xml?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/pom.xml (original)
+++ incubator/qpid/branches/new_persistence/java/common/pom.xml Mon Dec 18 01:10:59 2006
@@ -39,7 +39,7 @@
         <spec.stylesheet>${basedir}/src/main/xsl/framing.xsl</spec.stylesheet>
         <registry.stylesheet>${basedir}/src/main/xsl/registry.xsl</registry.stylesheet>
         <registry.template>${basedir}/src/main/xsl/registry.template</registry.template>
-        <generated.path>${project.build.directory}/generated/xsl</generated.path>
+        <generated.path>${project.build.directory}/generated-sources/xsl</generated.path>
         <generated.package>org/apache/qpid/framing</generated.package>
         <generated.dir>${generated.path}/${generated.package}</generated.dir>
         <specs.dir>${topDirectoryLocation}/../specs</specs.dir>
@@ -47,7 +47,6 @@
 
     <build>
         <plugins>          
-
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
@@ -90,10 +89,6 @@
          <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ant</groupId>
-            <artifactId>ant-junit</artifactId>
         </dependency>
     </dependencies>
 </project>

Modified: incubator/qpid/branches/new_persistence/java/common/protocol-version.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/protocol-version.xml?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/protocol-version.xml (original)
+++ incubator/qpid/branches/new_persistence/java/common/protocol-version.xml Mon Dec 18 01:10:59 2006
@@ -21,6 +21,8 @@
 <project name="Qpid Common Protocol Versions" default="generate">
 
   <property name="saxon.jar" value="lib/saxon/saxon8.jar"/>
+  <!-- temporarily hard-wired XML spec version for build avoidance -->
+  <property name="amqp.xml" value="${specs.dir}/amqp-8.0.xml"/>
   
   <macrodef name="saxon">
     <attribute name="out"/>
@@ -61,8 +63,7 @@
               flags="s" byline="true"/>
 
       <!-- Create directory; generate from specification file -->
-      <mkdir dir="${generated.dir}_${@{ver}.amqp(major)}_${@{ver}.amqp(minor)}"/>
-      <saxon out="${generated.dir}_${@{ver}.amqp(major)}_${@{ver}.amqp(minor)}/results.out"
+      <saxon out="${generated.dir}/results.out"
              src="${specs.dir}/amqp-@{ver}.xml" 
              xsl="${spec.stylesheet}">
         <arg value="major=${@{ver}.amqp(major)}"/>
@@ -70,14 +71,14 @@
         <arg value="registry_name=MainRegistry"/>
       </saxon>
       <!--  -->
-      <saxon out="${generated.dir}_${@{ver}.amqp(major)}_${@{ver}.amqp(minor)}/cluster.out"
+      <saxon out="${generated.dir}/cluster.out"
              src="${cluster.asl}"
              xsl="${spec.stylesheet}">
         <arg value="major=${@{ver}.amqp(major)}"/>
         <arg value="minor=${@{ver}.amqp(minor)}"/>
         <arg value="registry_name=ClusterRegistry"/>
       </saxon>
-      <saxon out="${generated.dir}_${@{ver}.amqp(major)}_${@{ver}.amqp(minor)}/registry.out"
+      <saxon out="${generated.dir}/registry.out"
              src="${registry.template}"
              xsl="${registry.stylesheet}">
         <arg value="major=${@{ver}.amqp(major)}"/>
@@ -86,11 +87,10 @@
     </sequential>
   </macrodef>
 
-<!--  <uptodate property="generated" targetfile="${generated.dir}/results.out"
-            srcfile="${amqp.xml}"/> -->
+  <uptodate property="generated" targetfile="${generated.dir}/results.out"
+            srcfile="${amqp.xml}"/>
 
-<!--  <target name="generate" unless="generated"> -->
-  <target name="generate">
+  <target name="generate" unless="generated">
     <mkdir dir="${generated.dir}"/>
     <copy file="src/main/versions/ProtocolVersionList.java.tmpl" tofile="${proto_version}"
             overwrite="true"/>

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Mon Dec 18 01:10:59 2006
@@ -241,7 +241,7 @@
             }
         }
     }
-    
+
     public void populatePropertiesFromBuffer(ByteBuffer buffer, int propertyFlags, int size)
             throws AMQFrameDecodingException
     {
@@ -402,6 +402,7 @@
             decodeUpToContentType();
         }
     }
+
     public String getContentType()
     {
         decodeContentTypeIfNecessary();
@@ -431,6 +432,12 @@
     public FieldTable getHeaders()
     {
         decodeHeadersIfNecessary();
+
+        if (_headers == null)
+        {
+            setHeaders(FieldTableFactory.newFieldTable());
+        }
+
         return _headers;
     }
 
@@ -587,6 +594,6 @@
 
     public String toString()
     {
-        return "reply-to = " + _replyTo + " propertyFlags = " + _propertyFlags;   
+        return "reply-to = " + _replyTo + " propertyFlags = " + _propertyFlags;
     }
 }

Modified: incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=488163&r1=488162&r2=488163
==============================================================================
--- incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ incubator/qpid/branches/new_persistence/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Mon Dec 18 01:10:59 2006
@@ -98,6 +98,12 @@
         }
     }
 
+    public static int encodedContentLength(Content table)
+    {
+    	// TODO: New Content class required for AMQP 0-9.
+        return 0;
+    }
+
     public static void writeShortStringBytes(ByteBuffer buffer, String s)
     {
         if (s != null)
@@ -108,9 +114,7 @@
             {
                 encodedString[i] = (byte) cha[i];
             }
-            // TODO: check length fits in an unsigned byte
-            writeUnsignedByte(buffer, (short) encodedString.length);
-            buffer.put(encodedString);
+            writeBytes(buffer,encodedString);
         }
         else
         {
@@ -227,6 +231,11 @@
         }
     }
 
+    public static void writeContentBytes(ByteBuffer buffer, Content content)
+    {
+    	// TODO: New Content class required for AMQP 0-9.
+    }
+
     public static void writeBooleans(ByteBuffer buffer, boolean[] values)
     {
         byte packedValue = 0;
@@ -243,6 +252,7 @@
 
     /**
      * This is used for writing longstrs.
+     *
      * @param buffer
      * @param data
      */
@@ -286,10 +296,16 @@
         }
         else
         {
-            return new FieldTable(buffer, length);
+            return FieldTableFactory.newFieldTable(buffer, length);
         }
     }
 
+    public static Content readContent(ByteBuffer buffer) throws AMQFrameDecodingException
+    {
+    	// TODO: New Content class required for AMQP 0-9.
+    	return null;
+    }
+
     public static String readShortString(ByteBuffer buffer)
     {
         short length = buffer.getUnsigned();
@@ -330,9 +346,9 @@
             // than constructing one from a char array.
             // this approach here is valid since we know that all the chars are
             // ASCII (0-127)
-            byte[] stringBytes = new byte[(int)length];
-            buffer.get(stringBytes, 0, (int)length);
-            char[] stringChars = new char[(int)length];
+            byte[] stringBytes = new byte[(int) length];
+            buffer.get(stringBytes, 0, (int) length);
+            char[] stringChars = new char[(int) length];
             for (int i = 0; i < stringChars.length; i++)
             {
                 stringChars[i] = (char) stringBytes[i];
@@ -350,7 +366,7 @@
         }
         else
         {
-            byte[] result = new byte[(int)length];
+            byte[] result = new byte[(int) length];
             buffer.get(result);
             return result;
         }
@@ -363,97 +379,6 @@
         return buffer.getUnsignedInt();
     }
 
-    // Will barf with a NPE on a null input. Not sure whether it should return null or
-    // an empty field-table (which would be slower - perhaps unnecessarily).
-    //
-    // Some sample input and the result output:
-    //
-    // Input: "a=1" "a=2 c=3" "a=3 c=4 d" "a='four' b='five'" "a=bad"
-    //
-    //    Parsing <a=1>...
-    //    {a=1}
-    //    Parsing <a=2 c=3>...
-    //    {a=2, c=3}
-    //    Parsing <a=3 c=4 d>...
-    //    {a=3, c=4, d=null}
-    //    Parsing <a='four' b='five'>...
-    //    {a=four, b=five}
-    //    Parsing <a=bad>...
-    //    java.lang.IllegalArgumentException: a: Invalid integer in <bad> from <a=bad>.
-    //
-    public static FieldTable createFieldTableFromMessageSelector(String selector)
-    {
-        boolean debug = _logger.isDebugEnabled();
-
-        // TODO: Doesn't support embedded quotes properly.
-        String[] expressions = selector.split(" +");
-
-        FieldTable result = new FieldTable();
-
-        for (int i = 0; i < expressions.length; i++)
-        {
-            String expr = expressions[i];
-
-            if (debug)
-            {
-                _logger.debug("Expression = <" + expr + ">");
-            }
-
-            int equals = expr.indexOf('=');
-
-            if (equals < 0)
-            {
-                // Existence check
-                result.put("S" + expr.trim(), null);
-            }
-            else
-            {
-                String key = expr.substring(0, equals).trim();
-                String value = expr.substring(equals + 1).trim();
-
-                if (debug)
-                {
-                    _logger.debug("Key = <" + key + ">, Value = <" + value + ">");
-                }
-
-                if (value.charAt(0) == '\'')
-                {
-                    if (value.charAt(value.length() - 1) != '\'')
-                    {
-                        throw new IllegalArgumentException(key + ": Missing quote in <" + value + "> from <" + selector + ">.");
-                    }
-                    else
-                    {
-                        value = value.substring(1, value.length() - 1);
-
-                        result.put("S" + key, value);
-                    }
-                }
-                else
-                {
-                    try
-                    {
-                        int intValue = Integer.parseInt(value);
-
-                        result.put("i" + key, value);
-                    }
-                    catch (NumberFormatException e)
-                    {
-                        throw new IllegalArgumentException(key + ": Invalid integer in <" + value + "> from <" + selector + ">.");
-
-                    }
-                }
-            }
-        }
-
-        if (debug)
-        {
-            _logger.debug("Field-table created from <" + selector + "> is <" + result + ">");
-        }
-
-        return (result);
-
-    }
 
     static byte[] hexToByteArray(String id)
     {
@@ -481,7 +406,7 @@
     public static char[] convertToHexCharArray(byte[] from)
     {
         int length = from.length;
-        char[]    result_buff = new char[length * 2 + 2];
+        char[] result_buff = new char[length * 2 + 2];
 
         result_buff[0] = '0';
         result_buff[1] = 'x';
@@ -526,24 +451,155 @@
         return (new String(convertToHexCharArray(from)));
     }
 
-    public static void main(String[] args)
+    private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    //**** new methods
+
+    // BOOLEAN_PROPERTY_PREFIX
+
+    public static void writeBoolean(ByteBuffer buffer, Boolean aBoolean)
     {
-        for (int i = 0; i < args.length; i++)
-        {
-            String selector = args[i];
+        buffer.put((byte) (aBoolean ? 1 : 0));
+    }
+
+    public static Boolean readBoolean(ByteBuffer buffer)
+    {
+        byte packedValue = buffer.get();
+        return (packedValue == 1);
+    }
 
-            System.err.println("Parsing <" + selector + ">...");
+    public static int encodedBooleanLength()
+    {
+        return 1;
+    }
 
-            try
-            {
-                System.err.println(createFieldTableFromMessageSelector(selector));
-            }
-            catch (IllegalArgumentException e)
-            {
-                System.err.println(e);
-            }
+    // BYTE_PROPERTY_PREFIX
+    public static void writeByte(ByteBuffer buffer, Byte aByte)
+    {
+        buffer.put(aByte);
+    }
+
+    public static Byte readByte(ByteBuffer buffer)
+    {
+        return buffer.get();
+    }
+
+    public static int encodedByteLength()
+    {
+        return 1;
+    }
+
+
+    // SHORT_PROPERTY_PREFIX
+    public static void writeShort(ByteBuffer buffer, Short aShort)
+    {
+        buffer.putShort(aShort);
+    }
+
+    public static Short readShort(ByteBuffer buffer)
+    {
+        return buffer.getShort();
+    }
+
+    public static int encodedShortLength()
+    {
+        return 2;
+    }
+
+    // INTEGER_PROPERTY_PREFIX
+    public static void writeInteger(ByteBuffer buffer, Integer aInteger)
+    {
+        buffer.putInt(aInteger);
+    }
+
+    public static Integer readInteger(ByteBuffer buffer)
+    {
+        return buffer.getInt();
+    }
+
+    public static int encodedIntegerLength()
+    {
+        return 4;
+    }
+
+    // LONG_PROPERTY_PREFIX
+    public static void writeLong(ByteBuffer buffer, Long aLong)
+    {
+        buffer.putLong(aLong);
+    }
+
+    public static Long readLong(ByteBuffer buffer)
+    {
+        return buffer.getLong();
+    }
+
+    public static int encodedLongLength()
+    {
+        return 8;
+    }
+
+    // Float_PROPERTY_PREFIX
+    public static void writeFloat(ByteBuffer buffer, Float aFloat)
+    {
+        buffer.putFloat(aFloat);
+    }
+
+    public static Float readFloat(ByteBuffer buffer)
+    {
+        return buffer.getFloat();
+    }
+
+    public static int encodedFloatLength()
+    {
+        return 4;
+    }
+
+
+    // Double_PROPERTY_PREFIX
+    public static void writeDouble(ByteBuffer buffer, Double aDouble)
+    {
+        buffer.putDouble(aDouble);
+    }
+
+    public static Double readDouble(ByteBuffer buffer)
+    {
+        return buffer.getDouble();
+    }
+
+    public static int encodedDoubleLength()
+    {
+        return 8;
+    }
+
+
+    public static byte[] readBytes(ByteBuffer buffer)
+    {
+        short length = buffer.getUnsigned();
+        if (length == 0)
+        {
+            return null;
+        }
+        else
+        {
+            byte[] dataBytes = new byte[length];
+            buffer.get(dataBytes, 0, length);
+
+            return dataBytes;
         }
     }
 
-    private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+    public static void writeBytes(ByteBuffer buffer, byte[] data)
+    {
+        if (data != null)
+        {
+            // TODO: check length fits in an unsigned byte            
+            writeUnsignedByte(buffer, (short) data.length);
+            buffer.put(data);
+        }
+        else
+        {
+            // really writing out unsigned byte
+            buffer.put((byte) 0);
+        }
+    }
 }



Mime
View raw message