use of java.util.AbstractMap.SimpleEntry in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testEntrySet.
private void testEntrySet(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<Entry<Integer, Integer>> entrySet1 = new HashSet<Entry<Integer, Integer>>(map1.entrySet());
Set<Entry<Integer, Integer>> entrySet2 = new HashSet<Entry<Integer, Integer>>(map2.entrySet());
for (Entry<Integer, Integer> entry : entrySet2) {
Integer value = findValue(entry.getKey(), testValues);
assertEquals(value, entry.getValue());
}
for (Entry<Integer, Integer> entry : entrySet1) {
Integer value = findValue(entry.getKey(), testValues);
assertEquals(value, entry.getValue());
}
}
use of java.util.AbstractMap.SimpleEntry in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testContainsValue.
private void testContainsValue(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());
}
for (SimpleEntry<Integer, Integer> testValue : testValues) {
assertTrue(map2.containsValue(testValue.getValue()));
}
int map1Contains = 0;
for (SimpleEntry<Integer, Integer> testValue : testValues) {
assertTrue(map1.containsValue(testValue.getValue()));
}
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method invalidApplicationConfigurationPath.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test(expected = ResourceLoadingException.class)
public void invalidApplicationConfigurationPath() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
configurationBuilder.withApplicationProperties("file://" + TEST_APP_CONFIG_PROPERTIES + ".foo");
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2, configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method moduleDefaultsWithConflictingKeys.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test(expected = ConflictingModuleConfigurationKeysException.class)
public void moduleDefaultsWithConflictingKeys() {
//add a key/value pair that will conflict with properties in TEST_MODULE_CONFIG_PROPERTIES
TestUtils.writePropertiesToFile(TEST_MODULE_CONFIG_PROPERTIES_2, filesCreated, new SimpleEntry(MODULE_1_KEY_1, MODULE_1_VALUE_1));
configurationBuilder.build();
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method applicationConfigurations.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void applicationConfigurations() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-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, configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
}
Aggregations