use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.
the class RingbufferStoreTest method testRingbufferStoreFactory.
@Test
public void testRingbufferStoreFactory() {
final String ringbufferName = randomString();
final SimpleRingbufferStoreFactory rbStoreFactory = new SimpleRingbufferStoreFactory();
final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setEnabled(true).setFactoryImplementation(rbStoreFactory);
final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
final HazelcastInstance instance = createHazelcastInstance(config);
final Ringbuffer<Object> ringbuffer = instance.getRingbuffer(ringbufferName);
ringbuffer.add(1);
assertEquals(1, rbStoreFactory.stores.size());
final TestRingbufferStore ringbufferStore = (TestRingbufferStore) rbStoreFactory.stores.get(ringbufferName);
int size = ringbufferStore.store.size();
assertEquals("Ring buffer store size should be 1 but found " + size, 1, size);
}
use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.
the class RingbufferStoreTest method testRingbufferStore_addThrowsException.
@Test(expected = HazelcastException.class)
public void testRingbufferStore_addThrowsException() throws InterruptedException {
final String ringbufferName = randomString();
final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setStoreImplementation(new ExceptionThrowingRingbufferStore()).setEnabled(true);
final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
final HazelcastInstance node = createHazelcastInstance(config);
final Ringbuffer<Object> ringbuffer = node.getRingbuffer(ringbufferName);
ringbuffer.add(1);
}
use of com.hazelcast.config.RingbufferStoreConfig in project hazelcast by hazelcast.
the class RingbufferStoreTest method testRingbufferStoreFactoryIsNotInitialized_whenDisabledInRingbufferStoreConfig.
@Test
public void testRingbufferStoreFactoryIsNotInitialized_whenDisabledInRingbufferStoreConfig() {
final String ringbufferName = randomString();
final SimpleRingbufferStoreFactory rbStoreFactory = new SimpleRingbufferStoreFactory();
final RingbufferStoreConfig rbStoreConfig = new RingbufferStoreConfig().setEnabled(false).setFactoryImplementation(rbStoreFactory);
final Config config = getConfig(ringbufferName, DEFAULT_CAPACITY, OBJECT, rbStoreConfig);
final HazelcastInstance instance = createHazelcastInstance(config);
final Ringbuffer<Object> ringbuffer = instance.getRingbuffer(ringbufferName);
ringbuffer.add(1);
assertEquals("Expected that the ring buffer store would not be initialized" + " since we disabled it in the ring buffer store config but found initialized ", 0, rbStoreFactory.stores.size());
}
Aggregations