Search in sources :

Example 6 with SSLContextSpiImpl

use of org.apache.harmony.xnet.tests.support.SSLContextSpiImpl in project robovm by robovm.

the class SSLContextSpiTest method test_engineCreateSSLEngine_02.

/**
     * javax.net.ssl.SSLContextSpi#engineCreateSSLEngine(String host, int port)
     * Verify exception when SSLContextSpi object wasn't initialiazed.
     */
public void test_engineCreateSSLEngine_02() {
    int[] invalid_port = { Integer.MIN_VALUE, -65535, -1, 65536, Integer.MAX_VALUE };
    SSLContextSpiImpl ssl = new SSLContextSpiImpl();
    try {
        SSLEngine sleng = ssl.engineCreateSSLEngine("localhost", 1080);
        fail("RuntimeException wasn't thrown");
    } catch (RuntimeException re) {
        String str = re.getMessage();
        if (!str.equals("Not initialiazed"))
            fail("Incorrect exception message: " + str);
    } catch (Exception e) {
        fail("Incorrect exception " + e + " was thrown");
    }
    for (int i = 0; i < invalid_port.length; i++) {
        try {
            SSLEngine sleng = ssl.engineCreateSSLEngine("localhost", invalid_port[i]);
            fail("IllegalArgumentException wasn't thrown");
        } catch (IllegalArgumentException iae) {
        //expected
        }
    }
}
Also used : SSLEngine(javax.net.ssl.SSLEngine) SSLContextSpiImpl(org.apache.harmony.xnet.tests.support.SSLContextSpiImpl) KeyManagementException(java.security.KeyManagementException)

Aggregations

KeyManagementException (java.security.KeyManagementException)6 SSLContextSpiImpl (org.apache.harmony.xnet.tests.support.SSLContextSpiImpl)6 SSLEngine (javax.net.ssl.SSLEngine)3 KeyStore (java.security.KeyStore)2 SecureRandom (java.security.SecureRandom)2 KeyManager (javax.net.ssl.KeyManager)2 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)2 TrustManager (javax.net.ssl.TrustManager)2 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)2 SSLContextSpi (javax.net.ssl.SSLContextSpi)1 SSLServerSocketFactory (javax.net.ssl.SSLServerSocketFactory)1 SSLSessionContext (javax.net.ssl.SSLSessionContext)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1