testComplete();
}
@Test
public void testServerOptions() {
NetServerOptions options = new NetServerOptions();
assertEquals(NetworkOptions.DEFAULT_SEND_BUFFER_SIZE, options.getSendBufferSize());
int rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setSendBufferSize(rand));
assertEquals(rand, options.getSendBufferSize());
assertIllegalArgumentException(() -> options.setSendBufferSize(0));
assertIllegalArgumentException(() -> options.setSendBufferSize(-123));
assertEquals(NetworkOptions.DEFAULT_RECEIVE_BUFFER_SIZE, options.getReceiveBufferSize());
rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setReceiveBufferSize(rand));
assertEquals(rand, options.getReceiveBufferSize());
assertIllegalArgumentException(() -> options.setReceiveBufferSize(0));
assertIllegalArgumentException(() -> options.setReceiveBufferSize(-123));
assertTrue(options.isReuseAddress());
assertEquals(options, options.setReuseAddress(false));
assertFalse(options.isReuseAddress());
assertEquals(NetworkOptions.DEFAULT_TRAFFIC_CLASS, options.getTrafficClass());
rand = 23;
assertEquals(options, options.setTrafficClass(rand));
assertEquals(rand, options.getTrafficClass());
assertIllegalArgumentException(() -> options.setTrafficClass(-1));
assertIllegalArgumentException(() -> options.setTrafficClass(256));
assertTrue(options.isTcpNoDelay());
assertEquals(options, options.setTcpNoDelay(false));
assertFalse(options.isTcpNoDelay());
boolean tcpKeepAlive = SocketDefaults.instance.isTcpKeepAlive();
assertEquals(tcpKeepAlive, options.isTcpKeepAlive());
assertEquals(options, options.setTcpKeepAlive(!tcpKeepAlive));
assertEquals(!tcpKeepAlive, options.isTcpKeepAlive());
int soLinger = SocketDefaults.instance.getSoLinger();
assertEquals(soLinger, options.getSoLinger());
rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setSoLinger(rand));
assertEquals(rand, options.getSoLinger());
assertIllegalArgumentException(() -> options.setSoLinger(-1));
assertFalse(options.isUsePooledBuffers());
assertEquals(options, options.setUsePooledBuffers(true));
assertTrue(options.isUsePooledBuffers());
rand = TestUtils.randomPositiveInt();
assertEquals(0, options.getIdleTimeout());
assertEquals(options, options.setIdleTimeout(rand));
assertEquals(rand, options.getIdleTimeout());
assertIllegalArgumentException(() -> options.setIdleTimeout(-1));
assertFalse(options.isSsl());
assertEquals(options, options.setSsl(true));
assertTrue(options.isSsl());
assertNull(options.getKeyStoreOptions());
JKSOptions keyStoreOptions = new JKSOptions().setPath(TestUtils.randomAlphaString(100)).setPassword(TestUtils.randomAlphaString(100));
assertEquals(options, options.setKeyStoreOptions(keyStoreOptions));
assertEquals(keyStoreOptions, options.getKeyStoreOptions());
assertNull(options.getTrustStoreOptions());
JKSOptions trustStoreOptions = new JKSOptions().setPath(TestUtils.randomAlphaString(100)).setPassword(TestUtils.randomAlphaString(100));
assertEquals(options, options.setTrustStoreOptions(trustStoreOptions));
assertEquals(trustStoreOptions, options.getTrustStoreOptions());
assertEquals(1024, options.getAcceptBacklog());
rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setAcceptBacklog(rand));
assertEquals(rand, options.getAcceptBacklog());
assertEquals(0, options.getPort());
assertEquals(options, options.setPort(1234));
assertEquals(1234, options.getPort());
assertIllegalArgumentException(() -> options.setPort(-1));
assertIllegalArgumentException(() -> options.setPort(65536));
assertEquals("0.0.0.0", options.getHost());
String randString = TestUtils.randomUnicodeString(100);
assertEquals(options, options.setHost(randString));
assertEquals(randString, options.getHost());
assertTrue(options.getEnabledCipherSuites().isEmpty());
assertEquals(options, options.addEnabledCipherSuite("foo"));
assertEquals(options, options.addEnabledCipherSuite("bar"));
assertNotNull(options.getEnabledCipherSuites());
assertTrue(options.getEnabledCipherSuites().contains("foo"));
assertTrue(options.getEnabledCipherSuites().contains("bar"));
testComplete();
}