Pointer { @CheckForNull public static Map<String, String> parsePointer(@Nonnull InputStream stream) throws IOException { byte[] buffer = new byte[Constants.POINTER_MAX_SIZE]; int size = 0; while (size < buffer.length) { int len = stream.read(buffer, size, buffer.length - size); if (len <= 0) { return parsePointer(buffer, 0, size); } size += len; } return null; }  @Nonnull static byte[] serializePointer(@Nonnull Map<String, String> pointer); @Nonnull static Map<String, String> createPointer(@Nonnull String oid, long size); @CheckForNull static Map<String, String> parsePointer(@Nonnull InputStream stream); @CheckForNull static Map<String, String> parsePointer(@Nonnull byte[] blob, final int offset, final int length); @CheckForNull static Map<String, String> parsePointer(@Nonnull byte[] blob);  }
@Test(dataProvider = "parseValidProvider") public void parseValid(@Nonnull String fileName, @Nonnull Map<String, String> expected) throws IOException { try (InputStream stream = getClass().getResourceAsStream(fileName)) { Assert.assertNotNull(stream); Assert.assertEquals(Pointer.parsePointer(stream), expected); } }
@Test(dataProvider = "parseInvalidProvider") public void parseInvalid(@Nonnull String fileName, @Nonnull String description) throws IOException { try (InputStream stream = getClass().getResourceAsStream(fileName)) { Assert.assertNotNull(stream); Assert.assertNull(Pointer.parsePointer(stream), description); } }