Search in sources :

Example 36 with SimpleEntry

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());
    }
}
Also used : SimpleEntry(java.util.AbstractMap.SimpleEntry) Entry(java.util.Map.Entry) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SimpleEntry(java.util.AbstractMap.SimpleEntry) HashSet(java.util.HashSet)

Example 37 with SimpleEntry

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()));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) SimpleEntry(java.util.AbstractMap.SimpleEntry)

Example 38 with SimpleEntry

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));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Example 39 with SimpleEntry

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();
}
Also used : SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Example 40 with SimpleEntry

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));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SimpleEntry(java.util.AbstractMap.SimpleEntry) Test(org.junit.Test)

Aggregations

SimpleEntry (java.util.AbstractMap.SimpleEntry)47 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)21 HashMap (java.util.HashMap)15 CucumberFeature (cucumber.runtime.model.CucumberFeature)10 Result (gherkin.formatter.model.Result)10 Entry (java.util.Map.Entry)10 HashSet (java.util.HashSet)9 Map (java.util.Map)8 Metacard (ddf.catalog.data.Metacard)7 Serializable (java.io.Serializable)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 List (java.util.List)6 UpdateRequest (ddf.catalog.operation.UpdateRequest)5 Set (java.util.Set)5 Configuration (org.apache.commons.configuration.Configuration)5 ZookeeperConfigurationProvider (com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider)4 LinkedList (java.util.LinkedList)4 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)3