Search in sources :

Example 11 with Configuration

use of com.xilixir.fortniteapi.v2.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);
}
Also used : BaseConfiguration(org.apache.commons.configuration2.BaseConfiguration) Configuration(org.apache.commons.configuration2.Configuration) Configurations(org.apache.commons.configuration2.builder.fluent.Configurations)

Example 12 with Configuration

use of com.xilixir.fortniteapi.v2.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);
        }
    }
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) Test(org.testng.annotations.Test)

Example 13 with Configuration

use of com.xilixir.fortniteapi.v2.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());
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) Test(org.testng.annotations.Test)

Example 14 with Configuration

use of com.xilixir.fortniteapi.v2.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");
}
Also used : MapConfiguration(org.apache.commons.configuration2.MapConfiguration) Configuration(org.apache.commons.configuration2.Configuration) MapConfiguration(org.apache.commons.configuration2.MapConfiguration) Test(org.testng.annotations.Test)

Example 15 with Configuration

use of com.xilixir.fortniteapi.v2.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;
}
Also used : ImmutableNode(org.apache.commons.configuration2.tree.ImmutableNode) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) Configuration(org.apache.commons.configuration2.Configuration) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration)

Aggregations

Configuration (org.apache.commons.configuration2.Configuration)18 Configuration (org.graylog2.Configuration)10 Test (org.junit.Test)7 Configurations (org.apache.commons.configuration2.builder.fluent.Configurations)5 Before (org.junit.Before)5 Test (org.testng.annotations.Test)5 Configuration (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration)4 ConfigurationSet (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet)4 ArrayList (java.util.ArrayList)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)2 IOException (java.io.IOException)2 Map (java.util.Map)2 BaseConfiguration (org.apache.commons.configuration2.BaseConfiguration)2 HierarchicalConfiguration (org.apache.commons.configuration2.HierarchicalConfiguration)2 JCas (org.apache.uima.jcas.JCas)2 Role (org.graylog2.shared.users.Role)2 UserService (org.graylog2.shared.users.UserService)2 EventBus (com.google.common.eventbus.EventBus)1 Gson (com.google.gson.Gson)1