### Question:
KeypairService { public KeyPair createKeypair() { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); KeyPairGenerator keyGen = null; try { keyGen = KeyPairGenerator.getInstance("RSA", "BC"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchProviderException e) { e.printStackTrace(); } keyGen.initialize(2048); KeyPair keyPair = keyGen.genKeyPair(); return keyPair; }  KeyPair createKeypair(); String getPEM(PrivateKey privKey); String getPublicKeyString(PublicKey pubKey);  }### Answer:
@Test public void testCreateKeypair() { KeyPair kp = keypairService.createKeypair(); assertNotNull(kp); assert(kp.getClass().equals(KeyPair.class)); PrivateKey priv = kp.getPrivate(); PublicKey pub = kp.getPublic(); assertNotNull(priv); assertNotNull(pub); assertEquals(priv.getAlgorithm(), new String("RSA")); assertEquals(pub.getAlgorithm(), new String("RSA")); KeyPair kp2 = keypairService.createKeypair(); assertNotEquals(kp, kp2); }