Search in sources :

Example 16 with SimpleEntry

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

Example 17 with SimpleEntry

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

Example 18 with SimpleEntry

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));
}
Also used : ConfigurationBuilder(com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder) SimpleEntry(java.util.AbstractMap.SimpleEntry) Before(org.junit.Before)

Example 19 with SimpleEntry

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());
}
Also used : SimpleEntry(java.util.AbstractMap.SimpleEntry) ZookeeperConfigurationProvider(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationProvider) Test(org.junit.Test)

Example 20 with SimpleEntry

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));
}
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