use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project winery by eclipse.
the class Environment method copyConfiguration.
/**
* Overwrite configuration parameters by using the given URL
*
* @param url a URL pointing to a file where the configuration should be read from
*/
public static void copyConfiguration(URL url) throws Exception {
Configurations configs = new Configurations();
Configuration configuration = configs.properties(url);
copyConfiguration(configuration);
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project bitflyer4j by after-the-sunrise.
the class ConfigurationTypeTest method test.
@Test
public void test() {
for (ConfigurationType type : ConfigurationType.values()) {
Configuration conf = type.get().orElse(null);
Map<String, String> map = new HashMap<>();
if (conf != null) {
for (Iterator<String> itr = conf.getKeys(); itr.hasNext(); ) {
String key = itr.next();
map.put(key, conf.getString(key));
}
}
switch(type) {
case VERSION:
assertNotNull(conf.getString(VERSION.getKey()));
assertEquals(map.size(), 1);
break;
case SYSTEM:
List<?> system = Collections.list(System.getProperties().propertyNames());
system.forEach(o -> assertTrue(conf.containsKey(o.toString()), "Missing : " + o));
assertEquals(map.size(), system.size());
break;
case HOME:
// Do nothing. (Dependent on the test machine.)
break;
case SITE:
assertEquals(conf.getString(VERSION.getKey()), "test");
assertEquals(conf.getString(SITE.getKey()), "test");
break;
default:
fail("Unknown type : " + type);
}
}
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project bitflyer4j by after-the-sunrise.
the class ConfigurationTypeTest method testGet.
@Test
public void testGet() throws Exception {
String site = "bitflyer4j-site.properties";
// Classpath exists
Configuration conf = ConfigurationType.get(site, null).get();
assertEquals(conf.getString(VERSION.getKey()), "test");
// Classpath does not exist. (And should not load from file path.)
assertFalse(ConfigurationType.get("build.gradle", null).isPresent());
// File exists.
conf = ConfigurationType.get(site, "src/test/resources").get();
assertEquals(conf.getString(VERSION.getKey()), "test");
// File does not exist. (And should not load from classpath.)
assertFalse(ConfigurationType.get(site, "build").isPresent());
}
use of de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration 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 de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration in project spoofax by metaborg.
the class AConfigBuilder method cloneConfiguration.
protected HierarchicalConfiguration<ImmutableNode> cloneConfiguration(IConfig config) {
// Clone configuration.
final IConfig iconfig = (IConfig) config;
final HierarchicalConfiguration<ImmutableNode> apacheConfig = iconfig.getConfig();
final Configuration clonedConfig = ConfigurationUtils.cloneConfiguration(apacheConfig);
@SuppressWarnings("unchecked") final HierarchicalConfiguration<ImmutableNode> clonedHierachicalConfig = (HierarchicalConfiguration<ImmutableNode>) clonedConfig;
return clonedHierachicalConfig;
}
Aggregations