boolean trustAll = rand.nextBoolean();
String crlPath = TestUtils.randomUnicodeString(100);
int reconnectAttempts = TestUtils.randomPositiveInt();
long reconnectInterval = TestUtils.randomPositiveInt();
JsonObject json = new JsonObject();
json.put("sendBufferSize", sendBufferSize)
.put("receiveBufferSize", receiverBufferSize)
.put("reuseAddress", reuseAddress)
.put("trafficClass", trafficClass)
.put("tcpNoDelay", tcpNoDelay)
.put("tcpKeepAlive", tcpKeepAlive)
.put("soLinger", soLinger)
.put("usePooledBuffers", usePooledBuffers)
.put("idleTimeout", idleTimeout)
.put("ssl", ssl)
.put("enabledCipherSuites", new JsonArray().add(enabledCipher))
.put("connectTimeout", connectTimeout)
.put("trustAll", trustAll)
.put("crlPaths", new JsonArray().add(crlPath))
.put("keyStoreOptions", new JsonObject().put("type", "jks").put("password", ksPassword).put("path", ksPath))
.put("trustStoreOptions", new JsonObject().put("type", "jks").put("password", tsPassword).put("path", tsPath))
.put("reconnectAttempts", reconnectAttempts)
.put("reconnectInterval", reconnectInterval);
NetClientOptions options = new NetClientOptions(json);
assertEquals(sendBufferSize, options.getSendBufferSize());
assertEquals(receiverBufferSize, options.getReceiveBufferSize());
assertEquals(reuseAddress, options.isReuseAddress());
assertEquals(trafficClass, options.getTrafficClass());
assertEquals(tcpKeepAlive, options.isTcpKeepAlive());
assertEquals(tcpNoDelay, options.isTcpNoDelay());
assertEquals(soLinger, options.getSoLinger());
assertEquals(usePooledBuffers, options.isUsePooledBuffers());
assertEquals(idleTimeout, options.getIdleTimeout());
assertEquals(ssl, options.isSsl());
assertNotSame(keyStoreOptions, options.getKeyStoreOptions());
assertEquals(ksPassword, ((JKSOptions) options.getKeyStoreOptions()).getPassword());
assertEquals(ksPath, ((JKSOptions) options.getKeyStoreOptions()).getPath());
assertNotSame(trustStoreOptions, options.getTrustStoreOptions());
assertEquals(tsPassword, ((JKSOptions) options.getTrustStoreOptions()).getPassword());
assertEquals(tsPath, ((JKSOptions) options.getTrustStoreOptions()).getPath());
assertEquals(1, options.getEnabledCipherSuites().size());
assertTrue(options.getEnabledCipherSuites().contains(enabledCipher));
assertEquals(connectTimeout, options.getConnectTimeout());
assertEquals(trustAll, options.isTrustAll());
assertEquals(1, options.getCrlPaths().size());
assertEquals(crlPath, options.getCrlPaths().get(0));
assertEquals(reconnectAttempts, options.getReconnectAttempts());
assertEquals(reconnectInterval, options.getReconnectInterval());
// Test other keystore/truststore types
json.put("keyStoreOptions", new JsonObject().put("type", "pkcs12").put("password", ksPassword))
.put("trustStoreOptions", new JsonObject().put("type", "pkcs12").put("password", tsPassword));
options = new NetClientOptions(json);
assertTrue(options.getTrustStoreOptions() instanceof PKCS12Options);
assertTrue(options.getKeyStoreOptions() instanceof PKCS12Options);
json.put("keyStoreOptions", new JsonObject().put("type", "keyCert"))
.put("trustStoreOptions", new JsonObject().put("type", "ca"));
options = new NetClientOptions(json);
assertTrue(options.getTrustStoreOptions() instanceof CaOptions);
assertTrue(options.getKeyStoreOptions() instanceof KeyCertOptions);
// Invalid types
json.put("keyStoreOptions", new JsonObject().put("type", "foo"));
assertIllegalArgumentException(() -> new NetClientOptions(json));
json.put("trustStoreOptions", new JsonObject().put("type", "foo"));
assertIllegalArgumentException(() -> new NetClientOptions(json));
}