### Question:
CelleryTrustManager implements X509TrustManager { @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { if (!validateServerCertificate) { return; } try { defaultTrustManager.checkServerTrusted(x509Certificates, s); } catch (CertificateException e) { trustManager.checkServerTrusted(x509Certificates, s); } } CelleryTrustManager(); @Override void checkClientTrusted(X509Certificate[] x509Certificates, String s); @Override void checkServerTrusted(X509Certificate[] x509Certificates, String s); @Override X509Certificate[] getAcceptedIssuers(); static final String TRUST_CERTS_DEFAULT_LOCATION; static final String TRUST_CERTS_LOCATION_ENV; public String trustCertsLocation; }### Answer:
@Test public void testCheckServerTrustedWithoutEnableTM() throws Exception { X509TrustManager celleryTrustManager = new CelleryTrustManager(); celleryTrustManager.checkServerTrusted(null, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCheckServerTrustedEnableTM() throws Exception { try { System.setProperty(VALIDATE_SERVER_CERT, "true"); X509TrustManager celleryTrustManager = new CelleryTrustManager(); celleryTrustManager.checkServerTrusted(null, null); } finally { System.getProperties().remove(VALIDATE_SERVER_CERT); } }