use of com.hazelcast.core.MapStoreAdapter in project hazelcast by hazelcast.
the class MapTransactionTest method testGet_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb.
@Test
public void testGet_LoadsKeyFromMapLoader_whenKeyDoesNotExistsInDb() {
final String mapName = randomMapName();
final MapStoreAdapter mock = mock(MapStoreAdapter.class);
when(mock.load(anyObject())).thenReturn(null);
Config config = getConfig();
MapStoreConfig storeConfig = new MapStoreConfig();
storeConfig.setEnabled(true).setImplementation(mock);
config.getMapConfig(mapName).setMapStoreConfig(storeConfig);
HazelcastInstance instance = createHazelcastInstance(config);
instance.executeTransaction(new TransactionalTask<Object>() {
@Override
public Object execute(TransactionalTaskContext context) throws TransactionException {
TransactionalMap<Object, Object> map = context.getMap(mapName);
Object value = map.get(1);
assertNull("value should be null", value);
verify(mock, times(1)).load(anyObject());
return null;
}
});
}
use of com.hazelcast.core.MapStoreAdapter in project hazelcast by hazelcast.
the class ClientMapNearCacheTest method testMapDestroy_succeeds_when_writeBehind_and_nearCache_enabled.
@Test
public void testMapDestroy_succeeds_when_writeBehind_and_nearCache_enabled() {
Config config = newConfig();
MapConfig mapConfig = config.getMapConfig("default");
mapConfig.getMapStoreConfig().setEnabled(true).setWriteDelaySeconds(1).setImplementation(new MapStoreAdapter());
IMap<Integer, Integer> map = getNearCachedMapFromClient(config, newInvalidationEnabledNearCacheConfig());
populateMap(map, 10);
populateNearCache(map, 10);
map.destroy();
}
Aggregations