| 24 | |
| 25 | |
| 26 | public class BlobTest |
| 27 | extends IonTestCase |
| 28 | { |
| 29 | public void checkNullBlob(IonBlob value) |
| 30 | throws IOException |
| 31 | { |
| 32 | assertSame(IonType.BLOB, value.getType()); |
| 33 | assertTrue(value.isNullValue()); |
| 34 | assertNull(value.newInputStream()); |
| 35 | assertNull(value.getBytes()); |
| 36 | |
| 37 | try |
| 38 | { |
| 39 | value.byteSize(); |
| 40 | fail("expected NullValueException"); |
| 41 | } |
| 42 | catch (NullValueException e) |
| 43 | { |
| 44 | } |
| 45 | |
| 46 | StringBuilder buf = new StringBuilder(); |
| 47 | try |
| 48 | { |
| 49 | value.printBase64(buf); |
| 50 | fail("expected NullValueException"); |
| 51 | } |
| 52 | catch (NullValueException e) { /* ok */ } |
| 53 | assertEquals(0, buf.length()); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |
| 58 | public void checkBlob(int[] expectedBytes, IonBlob value) |
| 59 | throws NullValueException, IOException |
| 60 | { |
| 61 | assertSame(IonType.BLOB, value.getType()); |
| 62 | |
| 63 | byte[] bytes = value.getBytes(); |
| 64 | assertNotSame(expectedBytes, bytes); |
| 65 | assertEquals(expectedBytes.length, bytes.length); |
| 66 | |
| 67 | InputStream in = value.newInputStream(); |
| 68 | for (int i = 0; i < expectedBytes.length; i++) |
| 69 | { |
| 70 | String msg = "index " + i; |
| 71 | assertEquals(msg, (byte) expectedBytes[i], bytes[i]); |
| 72 | assertEquals(msg, expectedBytes[i], in.read()); |
| 73 | } |
| 74 | assertEquals("should be at EOF", -1, in.read()); |
| 75 | assertEquals("should be at EOF", -1, in.read()); |
| 76 | assertEquals("should be at EOF", -1, in.read()); |
| 77 | } |
| 78 | |
| 79 | public void checkBlob(byte[] expectedBytes, IonBlob value) |
| 80 | throws NullValueException, IOException |
| 81 | { |
| 82 | assertSame(IonType.BLOB, value.getType()); |
| 83 |
nothing calls this directly
no test coverage detected
searching dependent graphs…