mirror of https://github.com/apache/activemq.git
BooleanStream now can handle more than 64*8 bits. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@382454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
acce91b74e
commit
4a65a33af0
|
@ -76,11 +76,11 @@ final public class BooleanStream {
|
|||
|
||||
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];
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
@ -32,13 +33,13 @@ public class BooleanStreamTest extends TestCase {
|
|||
|
||||
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 class BooleanStreamTest extends TestCase {
|
|||
});
|
||||
}
|
||||
|
||||
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 class BooleanStreamTest extends TestCase {
|
|||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue