List of usage examples for org.apache.commons.configuration PropertiesConfiguration load
public synchronized void load(Reader in) throws ConfigurationException
From source file:org.apache.atlas.web.security.SSLAndKerberosTest.java
@BeforeClass public void setUp() throws Exception { jksPath = new Path(Files.createTempDirectory("tempproviders").toString(), "test.jks"); providerUrl = JavaKeyStoreProvider.SCHEME_NAME + "://file/" + jksPath.toUri(); String persistDir = TestUtils.getTempDirectory(); setupKDCAndPrincipals();/*from w w w. j a v a 2 s . c o m*/ setupCredentials(); // client will actually only leverage subset of these properties final PropertiesConfiguration configuration = getSSLConfiguration(providerUrl); persistSSLClientConfiguration(configuration); TestUtils.writeConfiguration(configuration, persistDir + File.separator + ApplicationProperties.APPLICATION_PROPERTIES); String confLocation = System.getProperty("atlas.conf"); URL url; if (confLocation == null) { url = SSLAndKerberosTest.class.getResource("/" + ApplicationProperties.APPLICATION_PROPERTIES); } else { url = new File(confLocation, ApplicationProperties.APPLICATION_PROPERTIES).toURI().toURL(); } configuration.load(url); configuration.setProperty(TLS_ENABLED, true); configuration.setProperty("atlas.authentication.method.kerberos", "true"); configuration.setProperty("atlas.authentication.keytab", userKeytabFile.getAbsolutePath()); configuration.setProperty("atlas.authentication.principal", "dgi/localhost@" + kdc.getRealm()); configuration.setProperty("atlas.authentication.method.file", "false"); configuration.setProperty("atlas.authentication.method.kerberos", "true"); configuration.setProperty("atlas.authentication.method.kerberos.principal", "HTTP/localhost@" + kdc.getRealm()); configuration.setProperty("atlas.authentication.method.kerberos.keytab", httpKeytabFile.getAbsolutePath()); configuration.setProperty("atlas.authentication.method.kerberos.name.rules", "RULE:[1:$1@$0](.*@EXAMPLE.COM)s/@.*//\nDEFAULT"); configuration.setProperty("atlas.authentication.method.file", "true"); configuration.setProperty("atlas.authentication.method.file.filename", persistDir + "/users-credentials"); configuration.setProperty("atlas.auth.policy.file", persistDir + "/policy-store.txt"); TestUtils.writeConfiguration(configuration, persistDir + File.separator + "atlas-application.properties"); setupUserCredential(persistDir); setUpPolicyStore(persistDir); subject = loginTestUser(); UserGroupInformation.loginUserFromSubject(subject); UserGroupInformation proxyUser = UserGroupInformation.createProxyUser("testUser", UserGroupInformation.getLoginUser()); // save original setting originalConf = System.getProperty("atlas.conf"); System.setProperty("atlas.conf", persistDir); originalHomeDir = System.getProperty("atlas.home"); System.setProperty("atlas.home", TestUtils.getTargetDirectory()); dgiCLient = proxyUser.doAs(new PrivilegedExceptionAction<AtlasClient>() { @Override public AtlasClient run() throws Exception { return new AtlasClient(configuration, DGI_URL); } }); secureEmbeddedServer = new TestSecureEmbeddedServer(21443, getWarPath()) { @Override public PropertiesConfiguration getConfiguration() { return configuration; } }; secureEmbeddedServer.getServer().start(); }
From source file:org.apache.fluo.api.config.SimpleConfiguration.java
/** * Read a properties style config from given file. *//*from ww w . j a v a 2s. com*/ public SimpleConfiguration(File propertiesFile) { this(); try { PropertiesConfiguration config = new PropertiesConfiguration(); // disabled to prevent accumulo classpath value from being shortened config.setDelimiterParsingDisabled(true); config.load(propertiesFile); ((CompositeConfiguration) internalConfig).addConfiguration(config); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } }
From source file:org.apache.fluo.api.config.SimpleConfiguration.java
/** * Read a properties style config from given input stream. *//*from w w w . ja va 2s . c o m*/ public SimpleConfiguration(InputStream in) { this(); try { PropertiesConfiguration config = new PropertiesConfiguration(); // disabled to prevent accumulo classpath value from being shortened config.setDelimiterParsingDisabled(true); config.load(in); ((CompositeConfiguration) internalConfig).addConfiguration(config); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } }
From source file:org.apache.gobblin.util.PullFileLoader.java
/** * Load a {@link Properties} compatible path using fallback as fallback. * @return The {@link Config} in path with fallback as fallback. * @throws IOException//from w w w. j ava 2s.co m */ private Config loadJavaPropsWithFallback(Path propertiesPath, Config fallback) throws IOException { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); try (InputStreamReader inputStreamReader = new InputStreamReader(this.fs.open(propertiesPath), Charsets.UTF_8)) { propertiesConfiguration.setDelimiterParsingDisabled(ConfigUtils.getBoolean(fallback, PROPERTY_DELIMITER_PARSING_ENABLED_KEY, DEFAULT_PROPERTY_DELIMITER_PARSING_ENABLED_KEY)); propertiesConfiguration.load(inputStreamReader); Config configFromProps = ConfigUtils .propertiesToConfig(ConfigurationConverter.getProperties(propertiesConfiguration)); return ConfigFactory .parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY, PathUtils.getPathWithoutSchemeAndAuthority(propertiesPath).toString())) .withFallback(configFromProps).withFallback(fallback); } catch (ConfigurationException ce) { throw new IOException(ce); } }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldAcceptMandatoryValues() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)).isEqualTo(TikaConfiguration .builder().enabled().host("172.0.0.5").port(889).timeoutInMillis(500).cacheDisabled() .cacheWeightInBytes(100L * 1024L * 1024L).cacheEvictionPeriod(Duration.ofDays(1)).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldReturnDefaultOnMissingHost() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration .load(new StringReader("tika.enabled=true\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)).isEqualTo( TikaConfiguration.builder().enabled().host("127.0.0.1").port(889).timeoutInMillis(500).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldReturnDefaultOnMissingPort() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load( new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.timeoutInMillis=500\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)).isEqualTo( TikaConfiguration.builder().enabled().host("172.0.0.5").port(9998).timeoutInMillis(500).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldReturnDefaultOnMissingTimeout() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.port=889\n")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)).isEqualTo(TikaConfiguration .builder().enabled().host("172.0.0.5").port(889).timeoutInMillis(30 * 1000).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void tikaShouldBeDisabledByDefault() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo(TikaConfiguration.builder().disabled().build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldParseUnitForCacheEvictionPeriod() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n" + "tika.cache.eviction.period=2H")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo(TikaConfiguration.builder().enabled().host("172.0.0.5").port(889).timeoutInMillis(500) .cacheEvictionPeriod(Duration.ofHours(2)).build()); }