@Test(
     expectedExceptions = CryptoException.class,
     expectedExceptionsMessageRegExp = "Invalid input parameter. Certificate can not be null")
 public void testCheckIfCertificateIsTrustedUsingInvalidInput_ThrowsCryptoException()
     throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore("truststore.jks", null);
   trustStore.isTrusted(null, null);
 }
 @Test
 public void testCheckIfCertificateIsTrusted_Ok() throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore("truststore.jks", null);
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }
 @Test(
     expectedExceptions = CryptoException.class,
     expectedExceptionsMessageRegExp = "General security error occurred. Uninitialized keystore")
 public void testUseUninitializedKeyStore_ThrowsCryptoException() throws Exception {
   JKSTrustStore trustStore = new JKSTrustStore(KeyStore.getInstance("JKS"), null);
   trustStore.isTrusted(
       (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))), null);
 }
 @Test
 public void testCheckIfCertificateIsTrustedWithEmail_Ok() throws Exception {
   JKSTrustStore trustStore =
       new JKSTrustStore(
           "truststore.jks",
           null,
           new X509CertificateSubjectRdnSelector("[email protected]"));
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }
 @Test(
     expectedExceptions = InvalidCertificateException.class,
     expectedExceptionsMessageRegExp =
         "Invalid certificated subject with subjectDN [email protected].*")
 public void
     testCheckIfCertificateIsTrustedWithInvalidEmail_ThrowsInvalidCertificateSubjectException()
         throws Exception {
   JKSTrustStore trustStore =
       new JKSTrustStore(
           "truststore.jks",
           null,
           new X509CertificateSubjectRdnSelector("[email protected]"));
   Assert.assertTrue(
       trustStore.isTrusted(
           (X509Certificate) X509CertUtil.toCert(Util.toByteArray(TestUtil.load("server.crt"))),
           null));
 }