activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r382454 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/openwire/BooleanStream.java test/java/org/apache/activemq/openwire/BooleanStreamTest.java
Date Thu, 02 Mar 2006 17:27:28 GMT
Author: chirino
Date: Thu Mar  2 09:27:25 2006
New Revision: 382454

URL: http://svn.apache.org/viewcvs?rev=382454&view=rev
Log:
Fix for http://jira.activemq.org/jira/browse/AMQ-525
BooleanStream now can handle more than 64*8 bits.

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java?rev=382454&r1=382453&r2=382454&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java
Thu Mar  2 09:27:25 2006
@@ -76,11 +76,11 @@
     
     public void unmarshal(DataInputStream dataIn) throws IOException {
         
-        arrayLimit = dataIn.readByte();
-        if( (arrayLimit & 0x80)!=0 ) {
-            arrayLimit = dataIn.readShort();
-        } else if ( (arrayLimit & 0xC0)!=0 ) {
+        arrayLimit = (short) (dataIn.readByte() & 0xFF);
+        if ( arrayLimit == 0xC0 ) {
             arrayLimit = (short)(dataIn.readByte() & 0xFF);
+        } else if( arrayLimit == 0x80 ) {
+            arrayLimit = dataIn.readShort();
         } 
         if( data.length < arrayLimit ) {
             data = new byte[arrayLimit];

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java?rev=382454&r1=382453&r2=382454&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/openwire/BooleanStreamTest.java
Thu Mar  2 09:27:25 2006
@@ -22,6 +22,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 /**
@@ -32,13 +33,13 @@
 
     protected OpenWireFormat openWireformat;
     protected int endOfStreamMarker = 0x12345678;
-    int numberOfBytes = 8 * 50;
+    int numberOfBytes = 8 * 200;
 
     interface BooleanValueSet {
         public boolean getBooleanValueFor(int index, int count);
     }
 
-    public void testBooleanMarshallingUsingAllTrue() throws Exception {
+    public void testBooleanMarshallingUsingAllTrue() throws Throwable {
         testBooleanStream(numberOfBytes, new BooleanValueSet() {
             public boolean getBooleanValueFor(int index, int count) {
                 return true;
@@ -46,7 +47,7 @@
         });
     }
 
-    public void testBooleanMarshallingUsingAllFalse() throws Exception {
+    public void testBooleanMarshallingUsingAllFalse() throws Throwable {
         testBooleanStream(numberOfBytes, new BooleanValueSet() {
             public boolean getBooleanValueFor(int index, int count) {
                 return false;
@@ -54,17 +55,29 @@
         });
     }
 
-    public void testBooleanMarshallingUsingAlternateTrueFalse() throws Exception {
+    public void testBooleanMarshallingUsingOddAlternateTrueFalse() throws Throwable {
         testBooleanStream(numberOfBytes, new BooleanValueSet() {
             public boolean getBooleanValueFor(int index, int count) {
                 return (index & 1) == 0;
             }
         });
     }
+    
+    public void testBooleanMarshallingUsingEvenAlternateTrueFalse() throws Throwable {
+        testBooleanStream(numberOfBytes, new BooleanValueSet() {
+            public boolean getBooleanValueFor(int index, int count) {
+                return (index & 1) != 0;
+            }
+        });
+    }
 
     protected void testBooleanStream(int numberOfBytes, BooleanValueSet valueSet) throws
Exception {
         for (int i = 0; i < numberOfBytes; i++) {
-            assertMarshalBooleans(i, valueSet);
+            try {
+                assertMarshalBooleans(i, valueSet);
+            } catch (Throwable e) {
+                throw (AssertionFailedError) new AssertionFailedError("Iteration failed at:
"+i).initCause(e);
+            }
         }
     }
 



Mime
View raw message