X509TrustManagerWrapper implements X509TrustManager { @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { try { trustManager.checkServerTrusted(chain, authType); } catch (RuntimeException e) { throw new CertificateException("Unexpected error", e); } } X509TrustManagerWrapper(final X509TrustManager trustManager); static TrustManager[] wrap(TrustManager[] trustManagers); @Override void checkClientTrusted(X509Certificate[] chain, String authType); @Override void checkServerTrusted(X509Certificate[] chain, String authType); @Override X509Certificate[] getAcceptedIssuers();  }
@Test(expected = CertificateException.class) public void shouldRethrowCertificateExceptionOnCheckServerTrusted() throws Exception { Mockito.doThrow(new RuntimeException()).when(trustManager) .checkServerTrusted(Mockito.any(X509Certificate[].class), Mockito.anyString()); underTest.checkServerTrusted(null, null); }