Search in sources :

Example 46 with ClientInvocation

use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.

the class DisabledOperationsTest method assertFailure.

private void assertFailure(ClientMessage clientMessage, String expectedExceptionMsg) throws Exception {
    ClientInvocation invocation = new ClientInvocation(client, clientMessage, null);
    ClientInvocationFuture future = invocation.invoke();
    assertThatThrownBy(() -> future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)).hasCauseInstanceOf(AccessControlException.class).hasRootCauseMessage(expectedExceptionMsg);
}
Also used : AccessControlException(java.security.AccessControlException) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 47 with ClientInvocation

use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.

the class MCTrustedInterfacesTest method assertFailureOnUntrustedInterface.

private void assertFailureOnUntrustedInterface(ClientMessage clientMessage) throws Exception {
    ClientInvocation invocation = new ClientInvocation(((HazelcastClientProxy) client).client, clientMessage, null);
    ClientInvocationFuture future = invocation.invoke();
    try {
        future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
        fail("AccessControlException was expected.");
    } catch (ExecutionException e) {
        assertThat(e.getCause(), is(instanceOf(AccessControlException.class)));
    }
}
Also used : AccessControlException(java.security.AccessControlException) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ExecutionException(java.util.concurrent.ExecutionException) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 48 with ClientInvocation

use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.

the class MCTrustedInterfacesTest method testGetSystemPropertiesMessageTask_passing.

@Test
public void testGetSystemPropertiesMessageTask_passing() throws Exception {
    HazelcastInstance client = factory.newHazelcastClient(new ClientConfig(), "222.222.222.222");
    HazelcastClientInstanceImpl clientImpl = ((HazelcastClientProxy) client).client;
    ClientInvocation invocation = new ClientInvocation(clientImpl, MCGetSystemPropertiesCodec.encodeRequest(), null);
    ClientDelegatingFuture<List<Map.Entry<String, String>>> future = new ClientDelegatingFuture<>(invocation.invoke(), clientImpl.getSerializationService(), MCGetSystemPropertiesCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS).isEmpty());
}
Also used : MCGetSystemPropertiesCodec(com.hazelcast.client.impl.protocol.codec.MCGetSystemPropertiesCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) List(java.util.List) ArrayList(java.util.ArrayList) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) Map(java.util.Map) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 49 with ClientInvocation

use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.

the class MCMessageTasksTest method testHotRestartInterruptBackupMessageTask.

@Test
public void testHotRestartInterruptBackupMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCInterruptHotRestartBackupCodec.encodeRequest(), null);
    ClientDelegatingFuture<Void> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), clientMessage -> null);
    future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 50 with ClientInvocation

use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.

the class MCMessageTasksTest method testMatchMCConfigMessageTask.

@Test
public void testMatchMCConfigMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCMatchMCConfigCodec.encodeRequest(randomString()), null);
    ClientDelegatingFuture<Boolean> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCMatchMCConfigCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS));
}
Also used : MCMatchMCConfigCodec(com.hazelcast.client.impl.protocol.codec.MCMatchMCConfigCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)129 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)97 ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)54 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)51 Test (org.junit.Test)23 Data (com.hazelcast.internal.serialization.Data)22 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)19 QuickTest (com.hazelcast.test.annotation.QuickTest)19 UUID (java.util.UUID)18 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)16 Future (java.util.concurrent.Future)13 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)9 ArrayList (java.util.ArrayList)9 Nonnull (javax.annotation.Nonnull)9 ExecutionException (java.util.concurrent.ExecutionException)8 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)7 Collection (java.util.Collection)6 List (java.util.List)6 Map (java.util.Map)6 TimeUnit (java.util.concurrent.TimeUnit)6