/** engineGenerateCertificate(InputStream inStream) method testing. */ public void testEngineGenerateCertificate() throws Exception { X509CertFactoryImpl certFactory = new X509CertFactoryImpl(); Certificate cert; // DER encoded certificate generation testing ByteArrayInputStream bais = new ByteArrayInputStream(CertFactoryTestData.getCertEncoding()); cert = certFactory.engineGenerateCertificate(bais); assertNotNull("First generated certificate is null", cert); cert = certFactory.engineGenerateCertificate(bais); assertNotNull("Second generated certificate is null", cert); try { certFactory.engineGenerateCertificate(bais); fail("Expected CertificateException was not thrown."); } catch (CertificateException e) { } // Base64 testing bais = new ByteArrayInputStream(CertFactoryTestData.getBase64CertEncoding()); cert = certFactory.engineGenerateCertificate(bais); assertNotNull("First generated certificate is null", cert); cert = certFactory.engineGenerateCertificate(bais); assertNotNull("Second generated certificate is null", cert); try { certFactory.engineGenerateCertificate(bais); fail("Expected CertificateException was not thrown."); } catch (CertificateException e) { } }
/** engineGenerateCertificates(InputStream inStream) method testing. */ public void testEngineGenerateCertificates() throws Exception { X509CertFactoryImpl certFactory = new X509CertFactoryImpl(); // DER encoded certificate generation testing ByteArrayInputStream bais = new ByteArrayInputStream(CertFactoryTestData.getCertEncoding()); assertEquals( "The size of collection is not correct", 2, certFactory.engineGenerateCertificates(bais).size()); // Base64 testing bais = new ByteArrayInputStream(CertFactoryTestData.getBase64CertEncoding()); assertEquals( "The size of collection is not correct", 2, certFactory.engineGenerateCertificates(bais).size()); }