### Question:
KeyInfoFactoryImpl implements KeyInfoFactory { @Override public Element generatePublicKeyInfo(X509Certificate recipientCert) throws ParserConfigurationException, XMLSecurityException { Document sharedDocument = xmlUtilities.newSafeDocument(XMLUtils.isValidating()); KeyInfo keyInfo = new KeyInfo(sharedDocument); sharedDocument.appendChild(keyInfo.getElement()); X509Data x509Data = new X509Data(sharedDocument); keyInfo.add(x509Data); x509Data.addCertificate(recipientCert); return keyInfo.getElement(); } @Inject  KeyInfoFactoryImpl(XMLUtilities xmlUtilities); @Override Element generatePublicKeyInfo(X509Certificate recipientCert);  }### Answer:
@Test public void testKeyInfoGeneration() throws Exception { Element element = new KeyInfoFactoryImpl(new XMLUtilitiesImpl()).generatePublicKeyInfo(getCertificate()); String stringKeyInfo = new XMLUtilitiesImpl().documentToStringConversion(element); assertTrue(stringKeyInfo.contains("KeyInfo")); assertTrue(stringKeyInfo.contains("X509Data")); assertTrue(stringKeyInfo.contains("X509Certificate")); }