### Question:
PKIUtil { public KeyPair decodePrivateKey(final StringReader reader, final String passphrase) throws IOException { return doDecodePrivateKey(reader, passphrase); }  PublicKey decodePublicKey(final String keyLine); String encodePublicKey(final PublicKey publicKey); KeyPair decodePrivateKey(final StringReader reader, final String passphrase); KeyPair decodePrivateKey(final String keyPath, final String passphrase);  }### Answer:
@Test public void testRSAKey() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/rsa", ""); assertNotNull(keyPair); }
@Test public void testRSAEncryptedKey() throws IOException { KeyPair keyPair = null; try { keyPair = instance.decodePrivateKey("src/test/resources/rsa_encrypted", "passphrase"); } catch (IOException e) { LOG.error("Can not find file", e); } assertNotNull(keyPair); }
@Test(expected = EncryptionException.class) public void testRSAWrongPassphrase() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/rsa_encrypted", "wrong"); assertNull(keyPair); }
@Test public void testDSAKey() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/dsa", ""); assertNotNull(keyPair); }
@Test public void testDSAEncryptedKey() throws IOException { KeyPair keyPair = null; try { keyPair = instance.decodePrivateKey("src/test/resources/dsa_encrypted", "passphrase"); } catch (IOException e) { LOG.error("Can not find file", e); } assertNotNull(keyPair); }
@Test(expected = EncryptionException.class) public void testDSAWrongPassphrase() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/dsa_encrypted", "wrong"); assertNull(keyPair); }
@Test @SuppressWarnings("AbbreviationAsWordInName") public void testECDSAKey() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/ecdsa", ""); assertNotNull(keyPair); }
@Test @SuppressWarnings("AbbreviationAsWordInName") public void testECDSAEncryptedKey() throws IOException { KeyPair keyPair = null; try { keyPair = instance.decodePrivateKey("src/test/resources/ecdsa_encrypted", "passphrase"); } catch (IOException e) { LOG.error("Can not find file", e); } assertNotNull(keyPair); }
@Test(expected = EncryptionException.class) @SuppressWarnings("AbbreviationAsWordInName") public void testECDSAWrongPassphrase() throws IOException { KeyPair keyPair = instance.decodePrivateKey("src/test/resources/ecdsa_encrypted", "wrong"); assertNull(keyPair); }