Esempio n. 1
0
  private HazelcastInstance createServerHazelcastInstance() throws Exception {
    log.info("Creating Server HazelcastInstance");

    XmlConfigBuilder configBuilder = new XmlConfigBuilder(hzFile);
    Config config = configBuilder.build();

    HazelcastInstance server = Hazelcast.newHazelcastInstance(config);
    log.info("Successfully created Server HazelcastInstance");
    return server;
  }
  @Test(timeout = 120000)
  public void testReadingConfiguration() throws Exception {
    String mapName = "mapstore-test";
    InputStream is =
        getClass().getResourceAsStream("/com/hazelcast/config/hazelcast-mapstore-config.xml");
    XmlConfigBuilder builder = new XmlConfigBuilder(is);
    Config config = builder.build();
    HazelcastInstance hz = createHazelcastInstance(config);
    MapProxyImpl map = (MapProxyImpl) hz.getMap(mapName);
    MapService mapService = (MapService) map.getService();
    MapContainer mapContainer = mapService.getMapServiceContext().getMapContainer(mapName);
    MapStoreWrapper mapStoreWrapper = mapContainer.getMapStoreContext().getMapStoreWrapper();
    Iterator keys = mapStoreWrapper.loadAllKeys().iterator();

    final Set<String> loadedKeySet = loadedKeySet(keys);
    final Set<String> expectedKeySet = expectedKeySet();

    assertEquals(expectedKeySet, loadedKeySet);

    assertEquals("true", mapStoreWrapper.load("my-prop-1"));
    assertEquals("foo", mapStoreWrapper.load("my-prop-2"));
  }