use of com.hazelcast.internal.nio.ascii.TextProtocolClient in project hazelcast by hazelcast.
the class SingleProtocolHandlerRegressionTest method testWrongProtocolRegressionTest.
/**
* Regression test for #19756
*/
@Test
@Repeat(50)
public void testWrongProtocolRegressionTest() {
HazelcastInstance instance = Hazelcast.newHazelcastInstance(createMemberEndpointConfig());
ServerConnectionManager connectionManager = ((HazelcastInstanceProxy) instance).getOriginal().node.getServer().getConnectionManager(CLIENT);
// Get address of the client endpoint
InetAddress address = instance.getCluster().getLocalMember().getSocketAddress(CLIENT).getAddress();
int port = instance.getCluster().getLocalMember().getSocketAddress(CLIENT).getPort();
textProtocolClient = new TextProtocolClient(address, port);
textProtocolClient.connect();
assertTrueEventually(() -> assertTrue(textProtocolClient.isConnected()), ASSERT_TRUE_TIMEOUT_SECS);
assertTrueEventually(() -> assertEquals(connectionManager.getConnections().size(), 1), ASSERT_TRUE_TIMEOUT_SECS);
// Send wrong protocol data to client endpoint
textProtocolClient.sendData("AAACP2CP2");
// Assert that connection must be closed on the member side
assertTrueEventually(() -> assertTrue("Connection must be closed on the member side", connectionManager.getConnections().isEmpty()), ASSERT_TRUE_TIMEOUT_SECS);
}
Aggregations