@Test
  public void readIntoSecretBytes_works() throws Exception {
    InputStream fragmentedInputStream =
        new InputStream() {
          byte nextNumber = 4;

          @Override
          public int read() {
            return 0;
          }

          @Override
          public int read(byte[] b, int off, int len) {
            b[off] = nextNumber;
            nextNumber++;
            return 1;
          }
        };
    SecretBytes result =
        Util.readIntoSecretBytes(fragmentedInputStream, 4, InsecureSecretKeyAccess.get());

    assertThat(result.toByteArray(InsecureSecretKeyAccess.get()))
        .isEqualTo(new byte[] {4, 5, 6, 7});

    result = Util.readIntoSecretBytes(fragmentedInputStream, 4, InsecureSecretKeyAccess.get());
    assertThat(result.toByteArray(InsecureSecretKeyAccess.get()))
        .isEqualTo(new byte[] {8, 9, 10, 11});
  }
Tests for Tink internal Util class.
java_src/src/test/java/com/google/crypto/tink/internal/UtilTest.java