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
}
}
}
Aggregations