TrustManagerProxy extends X509ExtendedTrustManager { @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { trustManager.checkServerTrusted(x509Certificates, s); } TrustManagerProxy(TrustManager[] trustManagers); void setTrustManager(final TrustManager[] trustManagers); @Override void checkClientTrusted(X509Certificate[] x509Certificates, String s); @Override void checkServerTrusted(X509Certificate[] x509Certificates, String s); @Override X509Certificate[] getAcceptedIssuers(); @Override void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket); @Override void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine); @Override void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket); @Override void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine);  }
@Test public void testTrustManagerProxyCheckServerTrusted(@Mocked X509ExtendedTrustManager mockedTrustManager) throws CertificateException { new Expectations() {{ mockedTrustManager.checkServerTrusted((X509Certificate[]) any, "cert"); times = 1; }}; TrustManagerProxy trustManagerProxy = new TrustManagerProxy(new TrustManager[]{mockedTrustManager}); trustManagerProxy.checkServerTrusted(null, "cert"); }