use of java.util.AbstractMap.SimpleEntry in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testKeySet.
private void testKeySet(Config config) throws Exception {
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
HazelcastInstance instance2 = hazelcastFactory.newHazelcastClient();
final ReplicatedMap<Integer, Integer> map1 = instance1.getReplicatedMap("default");
final ReplicatedMap<Integer, Integer> map2 = instance2.getReplicatedMap("default");
final SimpleEntry<Integer, Integer>[] testValues = buildTestValues();
int half = testValues.length / 2;
for (int i = 0; i < testValues.length; i++) {
ReplicatedMap<Integer, Integer> map = i < half ? map1 : map2;
SimpleEntry<Integer, Integer> entry = testValues[i];
map.put(entry.getKey(), entry.getValue());
}
Set<Integer> keys1 = new HashSet<Integer>(map1.keySet());
Set<Integer> keys2 = new HashSet<Integer>(map2.keySet());
for (SimpleEntry<Integer, Integer> e : testValues) {
assertContains(keys1, e.getKey());
assertContains(keys2, e.getKey());
}
}
use of java.util.AbstractMap.SimpleEntry in project hazelcast by hazelcast.
the class ReplicatedMapTest method testSize.
private void testSize(Config config) throws Exception {
TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = nodeFactory.newHazelcastInstance(config);
HazelcastInstance instance2 = nodeFactory.newHazelcastInstance(config);
final ReplicatedMap<String, String> map1 = instance1.getReplicatedMap("default");
final ReplicatedMap<String, String> map2 = instance2.getReplicatedMap("default");
final int partitionCount = getPartitionService(instance1).getPartitionCount();
final Set<String> keys = generateRandomKeys(instance1, partitionCount);
final SimpleEntry<String, String>[] testValues = buildTestValues(keys);
int half = testValues.length / 2;
for (int i = 0; i < testValues.length; i++) {
final ReplicatedMap<String, String> map = i < half ? map1 : map2;
final SimpleEntry<String, String> entry = testValues[i];
map.put(entry.getKey(), entry.getValue());
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(keys.size(), map1.size());
assertEquals(keys.size(), map2.size());
}
});
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method setup.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Before
public void setup() throws Exception {
initializeZookeeper();
configurationBuilder = new ConfigurationBuilder(APP_NAME, ENVIRONMENT, true, BootstrapConfiguration.REFLECTIONS);
configurationBuilder.withAppVersion(APP_VERSION);
TestUtils.resetArchaius();
resetZookeeper();
TestUtils.writePropertiesToFile(TEST_MODULE_CONFIG_PROPERTIES, filesCreated, new SimpleEntry[] { new SimpleEntry(MODULE_1_KEY_1, MODULE_1_VALUE_1), new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3) });
TestUtils.writePropertiesToFile(TEST_MODULE_CONFIG_PROPERTIES_2, filesCreated, new SimpleEntry(MODULE_2_KEY_1, MODULE_2_VALUE_1));
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaultsEnvironmentFileOverride.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void missingZookeeperConfig_writeDefaultsEnvironmentFileOverride() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "false"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "true"));
TestUtils.deleteAll(curatorFramework);
Assert.assertNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
configurationBuilder.withConfigurationProvider(new ZookeeperConfigurationProvider(zookeeperServer.getConnectString()));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
configurationBuilder.build();
Assert.assertNotNull(curatorFramework.checkExists().forPath(ZOOKEEPER_CONFIG_ROOT));
Assert.assertEquals(MODULE_1_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_1)));
Assert.assertEquals(MODULE_1_VALUE_2, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_2)));
Assert.assertEquals(MODULE_1_VALUE_3, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_1_KEY_3)));
Assert.assertEquals(MODULE_2_VALUE_1, new String(curatorFramework.getData().forPath(ZOOKEEPER_CONFIG_ROOT + "/" + MODULE_2_KEY_1)));
Assert.assertEquals(4, curatorFramework.getChildren().forPath(ZOOKEEPER_CONFIG_ROOT).size());
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method applicationConfigurationsWithEnvironmentConfiguration.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void applicationConfigurationsWithEnvironmentConfiguration() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES);
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
}
Aggregations