Search in sources :

Example 1 with MigrationEvent

use of com.hazelcast.core.MigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationFailed.

@Test
public void test_migrationFailed() {
    final MigrationEvent event = new MigrationEvent(0, null, null, FAILED);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationEvent.class));
    verify(listener, never()).migrationCompleted(any(MigrationEvent.class));
    verify(listener).migrationFailed(event);
}
Also used : MigrationEvent(com.hazelcast.core.MigrationEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with MigrationEvent

use of com.hazelcast.core.MigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationEvent_deserialization.

@Test
public void test_migrationEvent_deserialization() throws IOException {
    final ObjectDataInput input = mock(ObjectDataInput.class);
    when(input.readInt()).thenReturn(0);
    when(input.readObject()).thenReturn(null);
    when(input.readObject()).thenReturn(null);
    when(input.readByte()).thenReturn((byte) 0);
    final MigrationEvent event = new MigrationEvent();
    event.readData(input);
    assertEquals(0, event.getPartitionId());
    assertNull(event.getOldOwner());
    assertNull(event.getNewOwner());
    assertEquals(STARTED, event.getStatus());
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput) MigrationEvent(com.hazelcast.core.MigrationEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with MigrationEvent

use of com.hazelcast.core.MigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationEvent_serialization.

@Test
public void test_migrationEvent_serialization() throws IOException {
    final MigrationEvent event = new MigrationEvent(0, null, null, STARTED);
    final ObjectDataOutput output = mock(ObjectDataOutput.class);
    event.writeData(output);
    verify(output).writeInt(0);
    verify(output, times(2)).writeObject(null);
    verify(output).writeByte(0);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) MigrationEvent(com.hazelcast.core.MigrationEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with MigrationEvent

use of com.hazelcast.core.MigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationStarted.

@Test
public void test_migrationStarted() {
    final MigrationEvent event = new MigrationEvent(0, null, null, STARTED);
    adapter.onEvent(event);
    verify(listener).migrationStarted(event);
    verify(listener, never()).migrationCompleted(any(MigrationEvent.class));
    verify(listener, never()).migrationFailed(any(MigrationEvent.class));
}
Also used : MigrationEvent(com.hazelcast.core.MigrationEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with MigrationEvent

use of com.hazelcast.core.MigrationEvent in project hazelcast by hazelcast.

the class MigrationListenerAdapterTest method test_migrationCompleted.

@Test
public void test_migrationCompleted() {
    final MigrationEvent event = new MigrationEvent(0, null, null, COMPLETED);
    adapter.onEvent(event);
    verify(listener, never()).migrationStarted(any(MigrationEvent.class));
    verify(listener).migrationCompleted(event);
    verify(listener, never()).migrationFailed(any(MigrationEvent.class));
}
Also used : MigrationEvent(com.hazelcast.core.MigrationEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MigrationEvent (com.hazelcast.core.MigrationEvent)7 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 EventRegistration (com.hazelcast.spi.EventRegistration)2 EventService (com.hazelcast.spi.EventService)2 Member (com.hazelcast.core.Member)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 PartitionMigrationEvent (com.hazelcast.spi.PartitionMigrationEvent)1