use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_wrap_05.
/**
* javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, int offset,
* int length, ByteBuffer dst)
* Exception case: IllegalStateException should be thrown.
*/
@AndroidOnly("The RI doesn't throw the IllegalStateException.")
public void test_wrap_05() throws SSLException {
String host = "new host";
int port = 8080;
ByteBuffer bb = ByteBuffer.allocate(10);
ByteBuffer[] bbA = { ByteBuffer.allocate(5), ByteBuffer.allocate(10), ByteBuffer.allocate(5) };
SSLEngine sse = getEngine(host, port);
try {
sse.wrap(bbA, 0, bbA.length, bb);
fail("IllegalStateException wasn't thrown");
} catch (IllegalStateException iobe) {
//expected
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_WantClientAuth.
/**
* @throws NoSuchAlgorithmException
* javax.net.ssl.SSLEngine#setWantClientAuth(boolean want)
* javax.net.ssl.SSLEngine#getWantClientAuth()
*/
public void test_WantClientAuth() throws NoSuchAlgorithmException {
SSLEngine sse = getEngine();
try {
sse.setWantClientAuth(false);
assertFalse(sse.getWantClientAuth());
sse.setWantClientAuth(true);
assertTrue(sse.getWantClientAuth());
} catch (Exception ex) {
fail("Unexpected exception " + ex);
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_unwrap_ByteBuffer$ByteBuffer_03.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts)
* IllegalArgumentException should be thrown.
*/
@KnownFailure("Fixed on DonutBurger, Wrong Exception thrown")
public void test_unwrap_ByteBuffer$ByteBuffer_03() {
String host = "new host";
int port = 8080;
ByteBuffer[] bbA = { ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100) };
ByteBuffer[] bbN = { ByteBuffer.allocate(100), null, ByteBuffer.allocate(100) };
ByteBuffer[] bbAN = null;
ByteBuffer bb = ByteBuffer.allocate(10);
ByteBuffer bN = null;
SSLEngine sse = getEngine(host, port);
sse.setUseClientMode(true);
try {
sse.unwrap(bN, bbA);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iobe) {
//expected
} catch (NullPointerException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of IllegalArgumentException");
}
try {
sse.unwrap(bb, bbAN);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iobe) {
//expected
} catch (NullPointerException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of IllegalArgumentException");
}
try {
sse.unwrap(bb, bbN);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iobe) {
//expected
} catch (NullPointerException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of IllegalArgumentException");
}
try {
sse.unwrap(bN, bbAN);
fail("IllegalArgumentException wasn't thrown");
} catch (IllegalArgumentException iobe) {
//expected
} catch (NullPointerException npe) {
} catch (Exception e) {
fail(e + " was thrown instead of IllegalArgumentException");
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_getSupportedCipherSuites.
/**
* @throws NoSuchAlgorithmException
* javax.net.ssl.SSLEngine#getSupportedCipherSuites()
*/
public void test_getSupportedCipherSuites() throws NoSuchAlgorithmException {
SSLEngine sse = getEngine();
try {
String[] res = sse.getSupportedCipherSuites();
assertNotNull(res);
assertTrue(res.length > 0);
} catch (Exception ex) {
fail("Unexpected exception " + ex);
}
}
use of javax.net.ssl.SSLEngine in project robovm by robovm.
the class SSLEngineTest method test_unwrap_06.
/**
* javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts,
* int offset, int length)
*/
public void test_unwrap_06() {
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);
sse.setUseClientMode(true);
try {
SSLEngineResult res = sse.unwrap(bb, bbA, 0, bbA.length);
assertEquals(0, res.bytesConsumed());
assertEquals(0, res.bytesProduced());
} catch (Exception ex) {
fail("Unexpected exception: " + ex);
}
}
Aggregations