File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed
main/java/org/msgpack/unpacker
test/java/org/msgpack/unpacker Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1717//
1818package org .msgpack .unpacker ;
1919
20- import org . msgpack . MessageTypeException ;
20+ import java . io . IOException ;
2121
2222
2323@ SuppressWarnings ("serial" )
24- public class SizeLimitException extends MessageTypeException {
24+ public class SizeLimitException extends IOException {
2525 public SizeLimitException () {
2626 super ();
2727 }
Original file line number Diff line number Diff line change 1- package org .msgpack ;
1+ package org .msgpack . unpacker ;
22
33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertTrue ;
1212import java .util .Map ;
1313
1414import org .junit .Test ;
15+ import org .msgpack .MessagePack ;
1516import org .msgpack .packer .Packer ;
1617import org .msgpack .template .ListTemplate ;
1718import org .msgpack .template .MapTemplate ;
Original file line number Diff line number Diff line change 1+ package org .msgpack .unpacker ;
2+
3+ import static org .junit .Assert .assertEquals ;
4+
5+ import java .io .ByteArrayInputStream ;
6+ import java .io .ByteArrayOutputStream ;
7+
8+ import org .junit .Test ;
9+ import org .msgpack .MessagePack ;
10+ import org .msgpack .packer .Packer ;
11+
12+ public class TestUnpackerInterator {
13+
14+ @ Test
15+ public void testSample () throws Exception {
16+ MessagePack msgpack = new MessagePack ();
17+
18+ ByteArrayOutputStream out = new ByteArrayOutputStream ();
19+ Packer packer = msgpack .createPacker (out );
20+ packer .write (1 );
21+ packer .write (2 );
22+ packer .write (3 );
23+ byte [] bytes = out .toByteArray ();
24+
25+ Unpacker unpacker = msgpack .createUnpacker (new ByteArrayInputStream (bytes ));
26+ UnpackerIterator iter = unpacker .iterator ();
27+ unpacker .resetReadByteCount ();
28+ iter .hasNext ();
29+ iter .next ();
30+ assertEquals (1 , unpacker .getReadByteCount ());
31+ unpacker .resetReadByteCount ();
32+ iter .hasNext ();
33+ iter .next ();
34+ assertEquals (1 , unpacker .getReadByteCount ());
35+ unpacker .resetReadByteCount ();
36+ iter .hasNext ();
37+ iter .next ();
38+ assertEquals (1 , unpacker .getReadByteCount ());
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments