use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_wrap_04.
/**
* javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, int offset,
* int length, ByteBuffer dst)
* Exception case: IllegalArgumentException should be thrown.
*/
@KnownFailure("Fixed on DonutBurger, Wrong Exception thrown")
public void test_wrap_04() {
String host = "new host";
int port = 8080;
ByteBuffer[] bbA = { ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100) };
ByteBuffer[] bbN = null;
ByteBuffer bN = null;
SSLEngine e = getEngine(host, port);
e.setUseClientMode(true);
try {
e.wrap(bbA, 0, 3, bN);
fail("IllegalArgumentException must be thrown for null srcs byte buffer array");
} catch (NullPointerException npe) {
} catch (IllegalArgumentException ex) {
} catch (Exception ex) {
fail(ex + " was thrown instead of IllegalArgumentException");
}
try {
e.wrap(bbN, 0, 0, bN);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException ex) {
} catch (NullPointerException npe) {
} catch (Exception ex) {
fail(ex + " was thrown instead of IllegalArgumentException");
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_closeInbound.
/**
* @throws NoSuchAlgorithmException
* javax.net.ssl.SSLEngine#closeInbound()
* javax.net.ssl.SSLEngine#isInboundDone()
*/
public void test_closeInbound() throws NoSuchAlgorithmException {
SSLEngine sse = getEngine();
try {
assertFalse(sse.isInboundDone());
sse.closeInbound();
assertTrue(sse.isInboundDone());
} catch (Exception ex) {
fail("Unexpected exception: " + ex);
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_EnabledProtocols.
/**
* @throws NoSuchAlgorithmException
* javax.net.ssl.SSLEngine#setEnabledProtocols(String[] protocols)
* javax.net.ssl.SSLEngine#getEnabledProtocols()
*/
public void test_EnabledProtocols() throws NoSuchAlgorithmException {
SSLEngine sse = getEngine();
String[] pr = sse.getSupportedProtocols();
try {
sse.setEnabledProtocols(pr);
String[] res = sse.getEnabledProtocols();
assertNotNull("Null array was returned", res);
assertEquals("Incorrect array length", res.length, pr.length);
assertTrue("Incorrect array was returned", Arrays.equals(res, pr));
} catch (Exception ex) {
fail("Unexpected exception " + ex);
}
try {
sse.setEnabledProtocols(null);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_unwrap_05.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts,
* int offset, int length)
* Exception case: IllegalStateException should be thrown.
*/
@AndroidOnly("The RI doesn't throw the IllegalStateException.")
public void test_unwrap_05() {
String host = "new host";
int port = 8080;
ByteBuffer[] bbA = { ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100) };
ByteBuffer bb = ByteBuffer.allocate(10);
SSLEngine sse = getEngine(host, port);
try {
sse.unwrap(bb, bbA, 0, bbA.length);
fail("IllegalStateException wasn't thrown");
} catch (IllegalStateException iobe) {
//expected
} catch (Exception e) {
fail(e + " was thrown instead of IllegalStateException");
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_ConstructorLjava_lang_StringI02.
/**
* Test for <code>SSLEngine(String host, int port)</code> constructor
* @throws NoSuchAlgorithmException
*/
public void test_ConstructorLjava_lang_StringI02() throws NoSuchAlgorithmException {
String host = "new host";
int port = 8080;
SSLEngine e = getEngine(host, port);
assertEquals(e.getPeerHost(), host);
assertEquals(e.getPeerPort(), port);
String[] suites = e.getSupportedCipherSuites();
e.setEnabledCipherSuites(suites);
assertEquals(e.getEnabledCipherSuites().length, suites.length);
e.setUseClientMode(true);
assertTrue(e.getUseClientMode());
}
Aggregations