Skip to content

Commit

Permalink
Fixes ClientMapStoreTest to obtain MapStore instance from MapContainer
Browse files Browse the repository at this point in the history
The test used to rely on erroneous behaviour fixed by hazelcast#15224
  • Loading branch information
vbekiaris committed Jul 8, 2019
1 parent 688eee3 commit d0230cc
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -27,6 +27,10 @@
import com.hazelcast.core.MapLoader;
import com.hazelcast.core.MapStore;
import com.hazelcast.map.ReachedMaxSizeException;
import com.hazelcast.map.impl.MapContainer;
import com.hazelcast.map.impl.MapService;
import com.hazelcast.map.impl.MapServiceContext;
import com.hazelcast.map.impl.proxy.MapProxyImpl;
import com.hazelcast.spi.properties.GroupProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
Expand Down Expand Up @@ -407,10 +411,7 @@ public void testIssue3023_testWithSubStringMapNames() {
IMap<Integer, Integer> map = client.getMap(mapNameWithStoreAndSize + "1");
map.put(1, 1);

MapStoreConfig mapStoreConfig = hz.getConfig()
.getMapConfig(mapNameWithStoreAndSize + "1")
.getMapStoreConfig();
final AMapStore store = (AMapStore) (mapStoreConfig.getImplementation());
final AMapStore store = getMapStoreInstance(hz, mapNameWithStoreAndSize + "1");

assertTrueEventually(new AssertTask() {
@Override
Expand All @@ -425,4 +426,14 @@ private Config buildConfig(String xml) {
XmlConfigBuilder configBuilder = new XmlConfigBuilder(bis);
return configBuilder.build();
}

// given a member-side HazelcastInstance and a mapName, return the MapStore instance
// or null if none configured
private <T extends MapStore> T getMapStoreInstance(HazelcastInstance hz, String mapName) {
MapProxyImpl map = (MapProxyImpl) hz.getMap(mapName);
MapService service = (MapService) map.getService();
MapServiceContext context = service.getMapServiceContext();
MapContainer container = context.getMapContainer(mapName);
return (T) container.getMapStoreContext().getMapStoreWrapper().getMapStore();
}
}

0 comments on commit d0230cc

Please sign in to comment.