use of org.apache.harmony.xnet.tests.support.MySSLContextSpi in project robovm by robovm.
the class MySslContext method test_ConstructorLjavax_net_ssl_SSLContextSpiLjava_security_ProviderLjava_lang_String.
/**
* Test for <code>SSLContext</code> constructor Assertion: returns
* SSLContext object
*/
public void test_ConstructorLjavax_net_ssl_SSLContextSpiLjava_security_ProviderLjava_lang_String() throws NoSuchAlgorithmException, KeyManagementException {
if (!DEFSupported) {
fail(NotSupportMsg);
return;
}
SSLContextSpi spi = new MySSLContextSpi();
SSLContext sslContext = new MySslContext(spi, defaultProvider, defaultProtocol);
assertEquals("Incorrect protocol", defaultProtocol, sslContext.getProtocol());
assertEquals("Incorrect provider", defaultProvider, sslContext.getProvider());
TrustManager[] tm = null;
KeyManager[] km = null;
sslContext.init(km, tm, new SecureRandom());
assertNotNull("No SSLEngine created", sslContext.createSSLEngine());
assertNotNull("No SSLEngine created", sslContext.createSSLEngine("host", 8888));
try {
sslContext.init(km, tm, null);
fail("KeyManagementException should be thrown for null " + "SecureRandom");
} catch (KeyManagementException e) {
}
sslContext = new MySslContext(null, null, null);
assertNull("Incorrect protocol", sslContext.getProtocol());
assertNull("Incorrect provider", sslContext.getProvider());
try {
sslContext.createSSLEngine();
fail("NullPointerException should be thrown");
} catch (NullPointerException e) {
}
try {
sslContext.getSocketFactory();
fail("NullPointerException should be thrown");
} catch (NullPointerException e) {
}
}
Aggregations