PemReader { public static List<Entry> readAll(final Path path) throws IOException { Objects.requireNonNull(path); try (Reader reader = Files.newBufferedReader(path, StandardCharsets.US_ASCII)) { return readAll(reader); } } private  PemReader(); static List<Entry> readAll(final Path path); static List<Entry> readAllBlocking(final Vertx vertx, final Path path); static void readAll(final Vertx vertx, final Path path, final Handler<AsyncResult<List<Entry>>> handler); static List<Entry> readAll(final Reader reader);  }
@Test public void testCertPemPkcs8() throws IOException { final List<Entry> result = PemReader.readAll(this.basePath1.resolve("artemis-cert.pem")); assertEquals(2, result.size()); final Entry first = result.get(0); assertEquals("CERTIFICATE", first.getType()); final Entry second = result.get(1); assertEquals("CERTIFICATE", second.getType()); }
@Test public void testKeyPemPkcs8() throws IOException { final List<Entry> result = PemReader.readAll(this.basePath1.resolve("artemis-key.pem")); assertEquals(1, result.size()); final Entry first = result.get(0); assertEquals("PRIVATE KEY", first.getType()); }
@Test public void testKeyPemPkcs1Private() throws IOException { final List<Entry> result = PemReader.readAll(this.basePath2.resolve("pkcs1-private-key.pem")); assertEquals(1, result.size()); final Entry first = result.get(0); assertEquals("RSA PRIVATE KEY", first.getType()); }
@Test public void testKeyPemPkcs1Public() throws IOException { final List<Entry> result = PemReader.readAll(this.basePath2.resolve("pkcs1-public-key.pem")); assertEquals(1, result.size()); final Entry first = result.get(0); assertEquals("PUBLIC KEY", first.getType()); }
@Test public void testEmpty() throws IOException { final List<Entry> result = PemReader.readAll(this.basePath2.resolve("empty.pem")); assertTrue(result.isEmpty()); }
@Test public void testError1() throws IOException { assertThatThrownBy(() -> PemReader.readAll(this.basePath2.resolve("error1.pem"))).isInstanceOf(IOException.class); }
@Test public void testError2() throws IOException { assertThatThrownBy(() -> PemReader.readAll(this.basePath2.resolve("error2.pem"))).isInstanceOf(IOException.class); }
@Test public void testError3() throws IOException { assertThatThrownBy(() -> PemReader.readAll(this.basePath2.resolve("error3.pem"))).isInstanceOf(IOException.class); }
@Test public void testError4() throws IOException { assertThatThrownBy(() -> PemReader.readAll(this.basePath2.resolve("error4.pem"))).isInstanceOf(IOException.class); }
@Test public void testError5() throws IOException { assertThatThrownBy(() -> PemReader.readAll(this.basePath2.resolve("error5.pem"))).isInstanceOf(IOException.class); }