activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r707064 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQStreamMessage.java test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java
Date Wed, 22 Oct 2008 13:02:31 GMT
Author: rajdavies
Date: Wed Oct 22 06:02:31 2008
New Revision: 707064

URL: http://svn.apache.org/viewvc?rev=707064&view=rev
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1964

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQStreamMessage.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQStreamMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQStreamMessage.java?rev=707064&r1=707063&r2=707064&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQStreamMessage.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQStreamMessage.java
Wed Oct 22 06:02:31 2008
@@ -1089,7 +1089,9 @@
             writeBytes((byte[])value);
         }else if (value instanceof Long) {
             writeLong(((Long)value).longValue());
-        } 
+        }else {
+            throw new MessageFormatException("Unsupported Object type: " + value.getClass());
+        }
     }
 
     /**

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java?rev=707064&r1=707063&r2=707064&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQStreamMessageTest.java
Wed Oct 22 06:02:31 2008
@@ -754,14 +754,10 @@
     public void testClearBody() throws JMSException {
         ActiveMQStreamMessage streamMessage = new ActiveMQStreamMessage();
         try {
-            streamMessage.writeObject(new Serializable() {
-                private static final long serialVersionUID = -5181896809607968727L;
-            });
+            streamMessage.writeObject(new Long(2));
             streamMessage.clearBody();
             assertFalse(streamMessage.isReadOnlyBody());
-            streamMessage.writeObject(new Serializable() {
-                private static final long serialVersionUID = 5074177640797561141L;
-            });
+            streamMessage.writeObject(new Long(2));
             streamMessage.readObject();
             fail("should throw exception");
         } catch (MessageNotReadableException mnwe) {
@@ -972,5 +968,33 @@
         } catch (MessageNotReadableException e) {
         }
     }
+    
+    public void testWriteObject() {
+        try {
+            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
+            message.clearBody();
+            message.writeObject("test");
+            message.writeObject(new Character('a'));
+            message.writeObject(new Boolean(false));
+            message.writeObject(new Byte((byte) 2));
+            message.writeObject(new Short((short) 2));
+            message.writeObject(new Integer(2));
+            message.writeObject(new Long(2l));
+            message.writeObject(new Float(2.0f));
+            message.writeObject(new Double(2.0d));
+        }catch(Exception e) {
+            fail(e.getMessage());
+        }
+        try {
+            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
+            message.clearBody();
+            message.writeObject(new Object());
+            fail("should throw an exception");
+        }catch(MessageFormatException e) {
+            
+        }catch(Exception e) {
+            fail(e.getMessage());
+        }
+    }
 
 }



Mime
View raw message