use of org.apache.commons.configuration2.MapConfiguration in project bitflyer4j by after-the-sunrise.
the class KeyTypeTest method test.
@Test
public void test() throws ConfigurationException {
// Null input. (= Default value.)
assertEquals(VERSION.fetch(null), VERSION.getDefaultValue());
// Not found. (= Default value.)
Configuration conf = new MapConfiguration(new HashMap<>());
assertEquals(VERSION.fetch(conf), VERSION.getDefaultValue());
// Retrieved from properties. (Empty)
conf.setProperty(VERSION.getKey(), "");
assertNull(VERSION.fetch(conf));
// Retrieved from properties. (Configured)
conf.setProperty(VERSION.getKey(), "test");
assertEquals(VERSION.fetch(conf), "test");
}
use of org.apache.commons.configuration2.MapConfiguration in project bitflyer4j by after-the-sunrise.
the class EnvironmentImplTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
conf = new MapConfiguration(new HashMap<>());
target = new EnvironmentImpl(conf, conf);
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class ConfiguredGraphFactory method create.
/**
* Creates a {@link JanusGraph} configuration stored in the {@link ConfigurationManagementGraph}
* graph and a {@link JanusGraph} graph reference according to the single
* Template Configuration previously created by the {@link ConfigurationManagementGraph} API;
* A configuration for this graph must not already exist, and a Template Configuration must
* exist. If the Template Configuration does not include its
* backend's respective keyspace/table/storage_directory parameter, we set the keyspace/table
* to the supplied graphName or we append the graphName to the supplied
* storage_root parameter.
*
* @param graphName
*
* @return JanusGraph
*/
public static synchronized JanusGraph create(final String graphName) {
final ConfigurationManagementGraph configManagementGraph = getConfigGraphManagementInstance();
final Map<String, Object> graphConfigMap = configManagementGraph.getConfiguration(graphName);
Preconditions.checkState(null == graphConfigMap, String.format("Configuration for graph %s already exists.", graphName));
final Map<String, Object> templateConfigMap = configManagementGraph.getTemplateConfiguration();
Preconditions.checkNotNull(templateConfigMap, "Please create a template Configuration using the ConfigurationManagementGraph#createTemplateConfiguration API.");
templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_GRAPH_NAME, graphName);
templateConfigMap.put(ConfigurationManagementGraph.PROPERTY_CREATED_USING_TEMPLATE, true);
final JanusGraphManager jgm = JanusGraphManagerUtility.getInstance();
Preconditions.checkNotNull(jgm, JANUS_GRAPH_MANAGER_EXPECTED_STATE_MSG);
final CommonsConfiguration config = new CommonsConfiguration(ConfigurationUtil.loadMapConfiguration(templateConfigMap));
final JanusGraph g = (JanusGraph) jgm.openGraph(graphName, (String gName) -> new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(config)));
configManagementGraph.createConfiguration(new MapConfiguration(templateConfigMap));
return g;
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class ConfigurationUtil method loadMapConfiguration.
/**
* Load properties from a map object and return a MapConfiguration object. Comma-delimited values are interpreted as
* a list of values.
* @param configMap
* @return
*/
public static MapConfiguration loadMapConfiguration(Map<String, Object> configMap) {
final MapConfiguration mapConfiguration = new MapConfiguration(configMap);
mapConfiguration.setListDelimiterHandler(COMMA_DELIMITER_HANDLER);
return mapConfiguration;
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class CQLConfiguredGraphFactoryTest method createConfigurationShouldSupportMultiHosts.
@Test
public void createConfigurationShouldSupportMultiHosts() throws Exception {
final MapConfiguration graphConfig = getGraphConfigWithMultiHosts();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
try {
ConfiguredGraphFactory.createConfiguration(graphConfig);
final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
assertNotNull(graph);
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
Aggregations