activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1489618 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/command/MessageId.java activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
Date Tue, 04 Jun 2013 21:25:10 GMT
Author: tabish
Date: Tue Jun  4 21:24:59 2013
New Revision: 1489618

URL: http://svn.apache.org/r1489618
Log:
Fix MessageId copy, wasn't copying the new textView field.  Fixes failing test.

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java?rev=1489618&r1=1489617&r2=1489618&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/command/MessageId.java
Tue Jun  4 21:24:59 2013
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.Atomi
 
 /**
  * @openwire:marshaller code="110"
- * 
+ *
  */
 public class MessageId implements DataStructure, Comparable<MessageId> {
 
@@ -93,10 +93,12 @@ public class MessageId implements DataSt
         return textView;
     }
 
+    @Override
     public byte getDataStructureType() {
         return DATA_STRUCTURE_TYPE;
     }
 
+    @Override
     public boolean equals(Object o) {
         if (this == o) {
             return true;
@@ -109,6 +111,7 @@ public class MessageId implements DataSt
         return producerSequenceId == id.producerSequenceId && producerId.equals(id.producerId);
     }
 
+    @Override
     public int hashCode() {
         if (hashCode == 0) {
             hashCode = producerId.hashCode() ^ (int)producerSequenceId;
@@ -124,6 +127,7 @@ public class MessageId implements DataSt
         }
     }
 
+    @Override
     public String toString() {
         if (key == null) {
             if( textView!=null ) {
@@ -172,6 +176,7 @@ public class MessageId implements DataSt
         this.brokerSequenceId = brokerSequenceId;
     }
 
+    @Override
     public boolean isMarshallAware() {
         return false;
     }
@@ -183,6 +188,7 @@ public class MessageId implements DataSt
         copy.dataLocator = dataLocator;
         copy.entryLocator = entryLocator;
         copy.plistLocator = plistLocator;
+        copy.textView = textView;
         return copy;
     }
 
@@ -191,6 +197,7 @@ public class MessageId implements DataSt
      * @return
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
+    @Override
     public int compareTo(MessageId other) {
         int result = -1;
         if (other != null) {

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java?rev=1489618&r1=1489617&r2=1489618&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
Tue Jun  4 21:24:59 2013
@@ -34,9 +34,6 @@ import org.apache.activemq.wireformat.Wi
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class ActiveMQMessageTest extends TestCase {
 
     private static final Logger LOG = LoggerFactory.getLogger(ActiveMQMessageTest.class);
@@ -144,7 +141,7 @@ public class ActiveMQMessageTest extends
     public void testShallowCopy() throws Exception {
         ActiveMQMessage msg1 = new ActiveMQMessage();
         msg1.setJMSMessageID(jmsMessageID);
-        ActiveMQMessage msg2 = (ActiveMQMessage)msg1.copy();
+        ActiveMQMessage msg2 = (ActiveMQMessage) msg1.copy();
         assertTrue(msg1 != msg2 && msg1.equals(msg2));
     }
 
@@ -175,7 +172,7 @@ public class ActiveMQMessageTest extends
         msg1.setReadOnlyProperties(true);
         ActiveMQMessage msg2 = new ActiveMQMessage();
         msg1.copy(msg2);
-        assertTrue(msg1.getJMSMessageID().equals(msg2.getJMSMessageID()));
+        assertEquals(msg1.getJMSMessageID(), msg2.getJMSMessageID());
         assertTrue(msg1.getJMSCorrelationID().equals(msg2.getJMSCorrelationID()));
         assertTrue(msg1.getJMSDestination().equals(msg2.getJMSDestination()));
         assertTrue(msg1.getJMSReplyTo().equals(msg2.getJMSReplyTo()));
@@ -302,14 +299,14 @@ public class ActiveMQMessageTest extends
     public void testGetByteProperty() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String name = "byteProperty";
-        msg.setByteProperty(name, (byte)1);
+        msg.setByteProperty(name, (byte) 1);
         assertTrue(msg.getByteProperty(name) == 1);
     }
 
     public void testGetShortProperty() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String name = "shortProperty";
-        msg.setShortProperty(name, (short)1);
+        msg.setShortProperty(name, (short) 1);
         assertTrue(msg.getShortProperty(name) == 1);
     }
 
@@ -353,7 +350,7 @@ public class ActiveMQMessageTest extends
         String name = "floatProperty";
         msg.setFloatProperty(name, 1.3f);
         assertTrue(msg.getObjectProperty(name) instanceof Float);
-        assertTrue(((Float)msg.getObjectProperty(name)).floatValue() == 1.3f);
+        assertTrue(((Float) msg.getObjectProperty(name)).floatValue() == 1.3f);
     }
 
     @SuppressWarnings("rawtypes")
@@ -482,13 +479,13 @@ public class ActiveMQMessageTest extends
 
         Map<String, Object> properties = msg.getProperties();
         assertEquals(properties.get("stringProperty"), "string");
-        assertEquals(((Byte)properties.get("byteProperty")).byteValue(), 1);
-        assertEquals(((Short)properties.get("shortProperty")).shortValue(), 1);
-        assertEquals(((Integer)properties.get("intProperty")).intValue(), 1);
-        assertEquals(((Long)properties.get("longProperty")).longValue(), 1);
-        assertEquals(((Float)properties.get("floatProperty")).floatValue(), 1.1f, 0);
-        assertEquals(((Double)properties.get("doubleProperty")).doubleValue(), 1.1, 0);
-        assertEquals(((Boolean)properties.get("booleanProperty")).booleanValue(), true);
+        assertEquals(((Byte) properties.get("byteProperty")).byteValue(), 1);
+        assertEquals(((Short) properties.get("shortProperty")).shortValue(), 1);
+        assertEquals(((Integer) properties.get("intProperty")).intValue(), 1);
+        assertEquals(((Long) properties.get("longProperty")).longValue(), 1);
+        assertEquals(((Float) properties.get("floatProperty")).floatValue(), 1.1f, 0);
+        assertEquals(((Double) properties.get("doubleProperty")).doubleValue(), 1.1, 0);
+        assertEquals(((Boolean) properties.get("booleanProperty")).booleanValue(), true);
         assertNull(properties.get("nullProperty"));
     }
 
@@ -543,7 +540,7 @@ public class ActiveMQMessageTest extends
         String propertyName = "property";
         msg.setBooleanProperty(propertyName, true);
 
-        assertEquals(((Boolean)msg.getObjectProperty(propertyName)).booleanValue(), true);
+        assertEquals(((Boolean) msg.getObjectProperty(propertyName)).booleanValue(), true);
         assertTrue(msg.getBooleanProperty(propertyName));
         assertEquals(msg.getStringProperty(propertyName), "true");
         try {
@@ -581,9 +578,9 @@ public class ActiveMQMessageTest extends
     public void testBytePropertyConversion() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String propertyName = "property";
-        msg.setByteProperty(propertyName, (byte)1);
+        msg.setByteProperty(propertyName, (byte) 1);
 
-        assertEquals(((Byte)msg.getObjectProperty(propertyName)).byteValue(), 1);
+        assertEquals(((Byte) msg.getObjectProperty(propertyName)).byteValue(), 1);
         assertEquals(msg.getByteProperty(propertyName), 1);
         assertEquals(msg.getShortProperty(propertyName), 1);
         assertEquals(msg.getIntProperty(propertyName), 1);
@@ -609,9 +606,9 @@ public class ActiveMQMessageTest extends
     public void testShortPropertyConversion() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String propertyName = "property";
-        msg.setShortProperty(propertyName, (short)1);
+        msg.setShortProperty(propertyName, (short) 1);
 
-        assertEquals(((Short)msg.getObjectProperty(propertyName)).shortValue(), 1);
+        assertEquals(((Short) msg.getObjectProperty(propertyName)).shortValue(), 1);
         assertEquals(msg.getShortProperty(propertyName), 1);
         assertEquals(msg.getIntProperty(propertyName), 1);
         assertEquals(msg.getLongProperty(propertyName), 1);
@@ -643,7 +640,7 @@ public class ActiveMQMessageTest extends
         String propertyName = "property";
         msg.setIntProperty(propertyName, 1);
 
-        assertEquals(((Integer)msg.getObjectProperty(propertyName)).intValue(), 1);
+        assertEquals(((Integer) msg.getObjectProperty(propertyName)).intValue(), 1);
         assertEquals(msg.getIntProperty(propertyName), 1);
         assertEquals(msg.getLongProperty(propertyName), 1);
         assertEquals(msg.getStringProperty(propertyName), "1");
@@ -679,7 +676,7 @@ public class ActiveMQMessageTest extends
         String propertyName = "property";
         msg.setLongProperty(propertyName, 1);
 
-        assertEquals(((Long)msg.getObjectProperty(propertyName)).longValue(), 1);
+        assertEquals(((Long) msg.getObjectProperty(propertyName)).longValue(), 1);
         assertEquals(msg.getLongProperty(propertyName), 1);
         assertEquals(msg.getStringProperty(propertyName), "1");
         try {
@@ -717,8 +714,8 @@ public class ActiveMQMessageTest extends
     public void testFloatPropertyConversion() throws JMSException {
         ActiveMQMessage msg = new ActiveMQMessage();
         String propertyName = "property";
-        msg.setFloatProperty(propertyName, (float)1.5);
-        assertEquals(((Float)msg.getObjectProperty(propertyName)).floatValue(), 1.5, 0);
+        msg.setFloatProperty(propertyName, (float) 1.5);
+        assertEquals(((Float) msg.getObjectProperty(propertyName)).floatValue(), 1.5, 0);
         assertEquals(msg.getFloatProperty(propertyName), 1.5, 0);
         assertEquals(msg.getDoubleProperty(propertyName), 1.5, 0);
         assertEquals(msg.getStringProperty(propertyName), "1.5");
@@ -753,7 +750,7 @@ public class ActiveMQMessageTest extends
         ActiveMQMessage msg = new ActiveMQMessage();
         String propertyName = "property";
         msg.setDoubleProperty(propertyName, 1.5);
-        assertEquals(((Double)msg.getObjectProperty(propertyName)).doubleValue(), 1.5, 0);
+        assertEquals(((Double) msg.getObjectProperty(propertyName)).doubleValue(), 1.5, 0);
         assertEquals(msg.getDoubleProperty(propertyName), 1.5, 0);
         assertEquals(msg.getStringProperty(propertyName), "1.5");
         try {
@@ -794,7 +791,7 @@ public class ActiveMQMessageTest extends
         String stringValue = "true";
         msg.setStringProperty(propertyName, stringValue);
         assertEquals(msg.getStringProperty(propertyName), stringValue);
-        assertEquals((String)msg.getObjectProperty(propertyName), stringValue);
+        assertEquals((String) msg.getObjectProperty(propertyName), stringValue);
         assertEquals(msg.getBooleanProperty(propertyName), true);
 
         stringValue = "1";
@@ -849,7 +846,7 @@ public class ActiveMQMessageTest extends
         String propertyName = "property";
         Object obj = new Object();
         try {
-            ((org.apache.activemq.command.Message)msg).setProperty(propertyName, obj); //
bypass
+            ((org.apache.activemq.command.Message) msg).setProperty(propertyName, obj); //
bypass
             // object
             // check
         } catch (IOException e) {
@@ -918,12 +915,12 @@ public class ActiveMQMessageTest extends
         } catch (MessageNotWriteableException e) {
         }
         try {
-            msg.setByteProperty(propertyName, (byte)1);
+            msg.setByteProperty(propertyName, (byte) 1);
             fail("Should have thrown exception");
         } catch (MessageNotWriteableException e) {
         }
         try {
-            msg.setShortProperty(propertyName, (short)1);
+            msg.setShortProperty(propertyName, (short) 1);
             fail("Should have thrown exception");
         } catch (MessageNotWriteableException e) {
         }
@@ -938,7 +935,7 @@ public class ActiveMQMessageTest extends
         } catch (MessageNotWriteableException e) {
         }
         try {
-            msg.setFloatProperty(propertyName, (float)1.5);
+            msg.setFloatProperty(propertyName, (float) 1.5);
             fail("Should have thrown exception");
         } catch (MessageNotWriteableException e) {
         }



Mime
View raw message