From ec3052d01898eb8b18f56f46b2502a0b1ee74b49 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 26 Jun 2012 09:21:53 -0500 Subject: [PATCH 1/2] additional test cases coming, fix to parser for empty payloads and improvement to frame parser payload length insertion to byte buffer --- .../websocket/generator/FrameGenerator.java | 37 ++- .../jetty/websocket/parser/Parser.java | 19 +- .../eclipse/jetty/websocket/ab/ABCase1.java | 220 ++++++++++++++++++ .../RFC6455ExamplesGeneratorTest.java | 2 +- 4 files changed, 266 insertions(+), 12 deletions(-) create mode 100644 jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java index bfe11dc2bcb..76d24542c13 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java @@ -68,23 +68,40 @@ public abstract class FrameGenerator // payload lengths int payloadLength = frame.getPayloadLength(); - if ((payloadLength >= 0x7F) && (payloadLength <= 0xFF_FF)) - { - // we have a 16 bit length - b |= 0x7E; - framing.put(b); // indicate 2 byte length - framing.putShort((short)(payloadLength & 0xFF_FF)); // write 2 byte length - } - else if (payloadLength >= 0xFFFF) + + + /* + * if length is over 65535 then its a 7 + 64 bit length + */ + if (payloadLength > 0xFF_FF) { // we have a 64 bit length b |= 0x7F; framing.put(b); // indicate 4 byte length - framing.putInt(payloadLength); // write 4 byte length + framing.put((byte)0); + framing.put((byte)0); + framing.put((byte)0); + framing.put((byte)0); + framing.put((byte)((payloadLength>>24) & 0xFF)); + framing.put((byte)((payloadLength>>16) & 0xFF)); + framing.put((byte)((payloadLength>>8) & 0xFF)); + framing.put((byte)(payloadLength & 0xFF)); + } + /* + * if payload is ge 126 we have a 7 + 16 bit length + */ + else if (payloadLength >= 0x7E) + { + b |= 0x7E; + framing.put(b); // indicate 2 byte length + framing.put((byte)((payloadLength>>8) & 0xFF)); + framing.put((byte)(payloadLength & 0xFF)); } + /* + * we have a 7 bit length + */ else { - // we have a 7 bit length b |= (payloadLength & 0x7F); framing.put(b); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java index 7ac15c74543..b9b589dc526 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java @@ -164,6 +164,23 @@ public class Parser } } } + + /* + * if the payload was empty we could end up in this state + * because there was no remaining bits to process + */ + if ( state == State.PAYLOAD ) + { + parser.getFrame().setPayload(ByteBuffer.allocate(0)); + notifyFrame( parser.getFrame() ); + parser.reset(); + if (parser.getFrame().isFin()) + { + reset(); + } + state = State.FINOP; + } + } catch (WebSocketException e) { @@ -174,7 +191,7 @@ public class Parser notifyWebSocketException(new WebSocketException(t)); } finally - { + { // Be sure to consume after exceptions buffer.position(buffer.limit()); } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java new file mode 100644 index 00000000000..243cd8dcf08 --- /dev/null +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java @@ -0,0 +1,220 @@ +package org.eclipse.jetty.websocket.ab; + + +import static org.hamcrest.Matchers.is; + +import java.nio.ByteBuffer; + +import org.eclipse.jetty.io.StandardByteBufferPool; +import org.eclipse.jetty.websocket.ByteBufferAssert; +import org.eclipse.jetty.websocket.api.WebSocketBehavior; +import org.eclipse.jetty.websocket.api.WebSocketPolicy; +import org.eclipse.jetty.websocket.frames.BinaryFrame; +import org.eclipse.jetty.websocket.frames.TextFrame; +import org.eclipse.jetty.websocket.generator.Generator; +import org.eclipse.jetty.websocket.parser.FrameParseCapture; +import org.eclipse.jetty.websocket.parser.Parser; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +public class ABCase1 +{ + StandardByteBufferPool bufferPool = new StandardByteBufferPool(); + WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); + + + @Test + public void testGenerateEmptyTextCase1_1_1() + { + TextFrame textFrame = new TextFrame(""); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(5); + + expected.put(new byte[] + { (byte)0x81, (byte)0x00 }); + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParseEmptyTextCase1_1_1() + { + + ByteBuffer expected = ByteBuffer.allocate(5); + + expected.put(new byte[] + { (byte)0x81, (byte)0x00 }); + + expected.flip(); + + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(0)); + ByteBufferAssert.assertSize("TextFrame.payload",0,pActual.getPayload()); + } + + @Test + public void testGenerate125ByteTextCase1_1_2() + { + int length = 125; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= length & 0x7F; + expected.put(b); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse125ByteTextCase1_1_2() + { + int length = 125; + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= length & 0x7F; + expected.put(b); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } + + @Test + public void testGenerate126ByteTextCase1_1_3() + { + int length = 126; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= length & 0x7E; + expected.put(b); + + //expected.put((byte)((length>>8) & 0xFF)); + //expected.put((byte)(length & 0xFF)); + expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse126ByteTextCase1_1_3() + { + int length = 126; + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= length & 0x7E; + expected.put(b); + expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } +} diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java index 2d4a2045062..7a238f21839 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java @@ -232,7 +232,7 @@ public class RFC6455ExamplesGeneratorTest ByteBuffer expected = ByteBuffer.allocate(dataSize + 10); // Raw bytes as found in RFC 6455, Section 5.7 - Examples - // 256 bytes binary message in a single unmasked frame + // 64k bytes binary message in a single unmasked frame expected.put(new byte[] { (byte)0x82, (byte)0x7F }); expected.putInt(0x0000000000010000); From 1a30f540bd39cb4dd1c1b5378e92990342cb5296 Mon Sep 17 00:00:00 2001 From: Jesse McConnell Date: Tue, 26 Jun 2012 10:58:20 -0500 Subject: [PATCH 2/2] more boundry tests and (temporary) fixes --- .../websocket/generator/FrameGenerator.java | 2 +- .../jetty/websocket/parser/FrameParser.java | 10 +- .../eclipse/jetty/websocket/ab/ABCase1.java | 312 ++++++++++++++++++ .../RFC6455ExamplesGeneratorTest.java | 3 +- 4 files changed, 323 insertions(+), 4 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java index 76d24542c13..dad21e71ab0 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java @@ -94,7 +94,7 @@ public abstract class FrameGenerator { b |= 0x7E; framing.put(b); // indicate 2 byte length - framing.put((byte)((payloadLength>>8) & 0xFF)); + framing.put((byte)(payloadLength>>8)); framing.put((byte)(payloadLength & 0xFF)); } /* diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/FrameParser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/FrameParser.java index b9a0b260678..14e00d278c9 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/FrameParser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/FrameParser.java @@ -145,12 +145,14 @@ public abstract class FrameParser getFrame().setMasked((b & 0x80) != 0); length = (byte)(0x7F & b); + System.out.println(length); if (length == 127) { - // length 4 bytes (extended payload length) + // length 8 bytes (extended payload length) if (buffer.remaining() >= 4) { - length = buffer.getInt(); + buffer.getInt(); //toss the first one, first 4 bytes + length = buffer.getInt(); // last 4 bytes for actual length } else { @@ -166,6 +168,10 @@ public abstract class FrameParser if (buffer.remaining() >= 2) { length = buffer.getShort(); + if (length == -1) + { + length = 65535; + } } else { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java index 243cd8dcf08..6d71a59e6a7 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/ABCase1.java @@ -7,6 +7,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.io.StandardByteBufferPool; import org.eclipse.jetty.websocket.ByteBufferAssert; +import org.eclipse.jetty.websocket.Debug; import org.eclipse.jetty.websocket.api.WebSocketBehavior; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.frames.BinaryFrame; @@ -14,6 +15,7 @@ import org.eclipse.jetty.websocket.frames.TextFrame; import org.eclipse.jetty.websocket.generator.Generator; import org.eclipse.jetty.websocket.parser.FrameParseCapture; import org.eclipse.jetty.websocket.parser.Parser; +import org.eclipse.jetty.websocket.parser.TextPayloadParser; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -217,4 +219,314 @@ public class ABCase1 Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); } + + @Test + public void testGenerate127ByteTextCase1_1_4() + { + int length = 127; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= length & 0x7E; + expected.put(b); + + //expected.put((byte)((length>>8) & 0xFF)); + //expected.put((byte)(length & 0xFF)); + expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse127ByteTextCase1_1_4() + { + int length = 127; + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= length & 0x7E; + expected.put(b); + expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } + + @Test + public void testGenerate128ByteTextCase1_1_5() + { + int length = 128; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= 0x7E; + expected.put(b); + + expected.put((byte)(length>>8)); + expected.put((byte)(length & 0xFF)); + //expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse128ByteTextCase1_1_5() + { + int length = 128; + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= 0x7E; + expected.put(b); + expected.putShort((short)length); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } + + @Test + public void testGenerate65535ByteTextCase1_1_6() + { + int length = 65535; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= 0x7E; + expected.put(b); + expected.put(new byte[]{ (byte)0xff, (byte)0xff}); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse65535ByteTextCase1_1_6() + { + Debug.enableDebugLogging(Parser.class); + Debug.enableDebugLogging(TextPayloadParser.class); + + int length = 65535; + + ByteBuffer expected = ByteBuffer.allocate(length + 5); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= 0x7E; + expected.put(b); + expected.put(new byte[]{ (byte)0xff, (byte)0xff}); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); + policy.setMaxTextMessageSize(length); + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } + + + @Test + public void testGenerate65536ByteTextCase1_1_7() + { + int length = 65536; + + StringBuilder builder = new StringBuilder(); + + for ( int i = 0 ; i < length ; ++i) + { + builder.append("*"); + } + + TextFrame textFrame = new TextFrame(builder.toString()); + textFrame.setFin(true); + + Generator generator = new Generator(bufferPool,policy); + ByteBuffer actual = generator.generate(textFrame); + + ByteBuffer expected = ByteBuffer.allocate(length + 11); + + expected.put(new byte[] + { (byte)0x81 }); + + byte b = 0x00; // no masking + b |= 0x7F; + expected.put(b); + expected.put(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}); + + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + actual.flip(); + expected.flip(); + + ByteBufferAssert.assertEquals("buffers do not match",expected,actual); + + } + + @Test + public void testParse65536ByteTextCase1_1_7() + { + int length = 65536; + + ByteBuffer expected = ByteBuffer.allocate(length + 11); + + expected.put(new byte[] + { (byte)0x81 }); + byte b = 0x00; // no masking + b |= 0x7F; + expected.put(b); + expected.put(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}); + + for ( int i = 0 ; i < length ; ++i ) + { + expected.put("*".getBytes()); + } + + expected.flip(); + + WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); + policy.setMaxTextMessageSize(length); + Parser parser = new Parser(policy); + FrameParseCapture capture = new FrameParseCapture(); + parser.addListener(capture); + parser.parse(expected); + + capture.assertNoErrors(); + capture.assertHasFrame(TextFrame.class,1); + + TextFrame pActual = (TextFrame)capture.getFrames().get(0); + Assert.assertThat("TextFrame.payloadLength",pActual.getPayloadLength(),is(length)); + ByteBufferAssert.assertSize("TextFrame.payload",length,pActual.getPayload()); + } } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java index 7a238f21839..4b045d2f225 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java @@ -235,7 +235,8 @@ public class RFC6455ExamplesGeneratorTest // 64k bytes binary message in a single unmasked frame expected.put(new byte[] { (byte)0x82, (byte)0x7F }); - expected.putInt(0x0000000000010000); + expected.putInt(0x00_00_00_00); + expected.putInt(0x00_01_00_00); for (int i = 0; i < dataSize; i++) {