use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaults.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void missingZookeeperConfig_writeDefaults() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_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 fetchFromArchaius.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void fetchFromArchaius() {
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(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
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));
Assert.assertEquals(MODULE_1_VALUE_1, DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_1, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_2, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_3, null).getValue());
}
use of java.util.AbstractMap.SimpleEntry in project chassis by Kixeye.
the class ConfigurationBuilderTest method missingZookeeperConfig_writeDefaultsDisabledInConfig.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = ApplicationConfigurationNotFoundException.class)
public void missingZookeeperConfig_writeDefaultsDisabledInConfig() throws Exception {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName(), "false"));
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();
}
use of java.util.AbstractMap.SimpleEntry in project lucene-solr by apache.
the class DocumentDictionaryTest method generateIndexDocuments.
/** Returns Pair(list of invalid document terms, Map of document term -> document) */
private Map.Entry<List<String>, Map<String, Document>> generateIndexDocuments(int ndocs, boolean requiresContexts) {
Map<String, Document> docs = new HashMap<>();
List<String> invalidDocTerms = new ArrayList<>();
for (int i = 0; i < ndocs; i++) {
Document doc = new Document();
boolean invalidDoc = false;
Field field = null;
// usually have valid term field in document
if (usually()) {
field = new TextField(FIELD_NAME, "field_" + i, Field.Store.YES);
doc.add(field);
} else {
invalidDoc = true;
}
// even if payload is not required usually have it
if (usually()) {
Field payload = new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
doc.add(payload);
}
if (requiresContexts || usually()) {
if (usually()) {
for (int j = 0; j < atLeast(2); j++) {
doc.add(new StoredField(CONTEXT_FIELD_NAME, new BytesRef("context_" + i + "_" + j)));
}
}
// we should allow entries without context
}
// usually have valid weight field in document
if (usually()) {
Field weight = (rarely()) ? new StoredField(WEIGHT_FIELD_NAME, 100d + i) : new NumericDocValuesField(WEIGHT_FIELD_NAME, 100 + i);
doc.add(weight);
}
String term = null;
if (invalidDoc) {
term = (field != null) ? field.stringValue() : "invalid_" + i;
invalidDocTerms.add(term);
} else {
term = field.stringValue();
}
docs.put(term, doc);
}
return new SimpleEntry<>(invalidDocTerms, docs);
}
use of java.util.AbstractMap.SimpleEntry in project ddf by codice.
the class SolrProviderTest method testUpdateNonUniqueAttributeValue2.
/**
* Tests if we catch a rare case where some attribute value match multiple Metacards while
* others do not match any records.
*
* @throws IngestException
* @throws UnsupportedQueryException
*/
@Test(expected = IngestException.class)
public void testUpdateNonUniqueAttributeValue2() throws IngestException, UnsupportedQueryException {
deleteAllIn(provider);
MockMetacard m1 = new MockMetacard(Library.getFlagstaffRecord());
MockMetacard m2 = new MockMetacard(Library.getFlagstaffRecord());
List<Metacard> list = Arrays.asList((Metacard) m1, m2);
create(list);
provider.update(new UpdateRequest() {
@Override
public boolean hasProperties() {
return false;
}
@Override
public Serializable getPropertyValue(String name) {
return null;
}
@Override
public Set<String> getPropertyNames() {
return null;
}
@Override
public Map<String, Serializable> getProperties() {
return null;
}
@Override
public boolean containsPropertyName(String name) {
return false;
}
@Override
public List<Entry<Serializable, Metacard>> getUpdates() {
MockMetacard newMetacard = new MockMetacard(Library.getShowLowRecord());
List<Entry<Serializable, Metacard>> updateList = new ArrayList<Entry<Serializable, Metacard>>();
updateList.add(new SimpleEntry<Serializable, Metacard>(MockMetacard.DEFAULT_TITLE, newMetacard));
updateList.add(new SimpleEntry<Serializable, Metacard>(TAMPA_QUERY_PHRASE, newMetacard));
return updateList;
}
@Override
public String getAttributeName() {
return Metacard.TITLE;
}
});
}
Aggregations