Search in sources :

Example 1 with ConsistentSetMultimapService

use of io.atomix.core.multimap.impl.ConsistentSetMultimapService in project atomix by atomix.

the class ConsistentSetMultimapServiceTest method testSnapshot.

@Test
@SuppressWarnings("unchecked")
public void testSnapshot() throws Exception {
    ConsistentSetMultimapService service = new ConsistentSetMultimapService();
    service.put(new DefaultCommit<>(2, PUT, new Put("foo", Arrays.asList("Hello world!".getBytes()), Match.ANY), mock(Session.class), System.currentTimeMillis()));
    Buffer buffer = HeapBuffer.allocate();
    service.backup(buffer);
    service = new ConsistentSetMultimapService();
    service.restore(buffer.flip());
    Versioned<Collection<? extends byte[]>> value = service.get(new DefaultCommit<>(2, GET, new Get("foo"), mock(Session.class), System.currentTimeMillis()));
    assertNotNull(value);
    assertEquals(1, value.value().size());
    assertArrayEquals("Hello world!".getBytes(), value.value().iterator().next());
}
Also used : Buffer(io.atomix.storage.buffer.Buffer) HeapBuffer(io.atomix.storage.buffer.HeapBuffer) ConsistentSetMultimapService(io.atomix.core.multimap.impl.ConsistentSetMultimapService) Get(io.atomix.core.multimap.impl.ConsistentSetMultimapOperations.Get) Collection(java.util.Collection) Put(io.atomix.core.multimap.impl.ConsistentSetMultimapOperations.Put) Test(org.junit.Test)

Aggregations

Get (io.atomix.core.multimap.impl.ConsistentSetMultimapOperations.Get)1 Put (io.atomix.core.multimap.impl.ConsistentSetMultimapOperations.Put)1 ConsistentSetMultimapService (io.atomix.core.multimap.impl.ConsistentSetMultimapService)1 Buffer (io.atomix.storage.buffer.Buffer)1 HeapBuffer (io.atomix.storage.buffer.HeapBuffer)1 Collection (java.util.Collection)1 Test (org.junit.Test)1