private void test_generateCertificate_PartialInput(CertificateFactory cf) throws Exception {
        byte[] valid = VALID_CERTIFICATE_PEM.getBytes(Charset.defaultCharset());
        Certificate c = cf.generateCertificate(new SlowInputStream(new ByteArrayInputStream(valid)));
        assertNotNull(c);

        valid = TestUtils.decodeBase64(VALID_CERTIFICATE_DER_BASE64);
        c = cf.generateCertificate(new SlowInputStream(new ByteArrayInputStream(valid)));
        assertNotNull(c);
    }
An InputStream that only returns two bytes at a time, no matter how many were requested.
common/src/test/java/org/conscrypt/java/security/cert/CertificateFactoryTest.java