Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#setProperty()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#setProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecureEmbeddedServerTestBase.java From atlas with Apache License 2.0 | 7 votes |
/** * Runs the existing webapp test cases, this time against the initiated secure server instance. * @throws Exception */ @Test public void runOtherSuitesAgainstSecureServer() throws Exception { final PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl); // setup the credential provider setupCredentials(); try { secureEmbeddedServer = new SecureEmbeddedServer( EmbeddedServer.ATLAS_DEFAULT_BIND_ADDRESS, securePort, TestUtils.getWarPath()) { @Override protected PropertiesConfiguration getConfiguration() { return configuration; } }; secureEmbeddedServer.server.start(); TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[]{AdminJerseyResourceIT.class, EntityJerseyResourceIT.class, TypesJerseyResourceIT.class}); testng.addListener(tla); testng.run(); } finally { secureEmbeddedServer.server.stop(); } }
Example 2
Source File: OfflineCredentialsTest.java From googleads-java-lib with Apache License 2.0 | 6 votes |
/** * Tests that the builder correctly reads properties from a configuration. */ @Test public void testReadPropertiesFromConfiguration_dfp() throws ValidationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientId", "clientId"); config.setProperty("api.admanager.clientSecret", "clientSecret"); config.setProperty("api.admanager.refreshToken", "refreshToken"); OfflineCredentials offlineCredentials = new OfflineCredentials.Builder() .forApi(OfflineCredentials.Api.AD_MANAGER) .from(config) .build(); assertEquals("clientId", offlineCredentials.getClientId()); assertEquals("clientSecret", offlineCredentials.getClientSecret()); assertEquals("refreshToken", offlineCredentials.getRefreshToken()); }
Example 3
Source File: GoogleClientSecretsBuilderTest.java From googleads-java-lib with Apache License 2.0 | 6 votes |
/** * Tests that the builder correctly leaves out the file path. */ @Test public void testReadPropertiesFromFile_clientSecretNoFilePath() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientId", "clientId"); config.setProperty("api.admanager.refreshToken", "refreshToken"); GoogleClientSecretsForApiBuilder builder = new GoogleClientSecretsForApiBuilder( configurationHelper, GoogleClientSecretsBuilder.Api.AD_MANAGER); thrown.expect(ValidationException.class); thrown.expectMessage("Client secret must be set." + "\nIf you do not have a client ID or secret, please create one in the API " + "console: https://console.developers.google.com"); builder.from(config).build(); }
Example 4
Source File: FormattedGraphParserTest.java From ldbc_graphalytics with Apache License 2.0 | 6 votes |
private static Fixture constructBasicGraph(String rootDir) { final String NAME = "Graph name"; final long NUM_VERTICES = 123; final long NUM_EDGES = 765; final boolean IS_DIRECTED = true; final String VERTEX_FILE_PATH = "example.graph.v"; final String EDGE_FILE_PATH = "other.example.graph.edges"; FormattedGraph formattedGraph = new FormattedGraph(NAME, NUM_VERTICES, NUM_EDGES, IS_DIRECTED, Paths.get(rootDir, VERTEX_FILE_PATH).toString(), Paths.get(rootDir, EDGE_FILE_PATH).toString(), new PropertyList(), new PropertyList()); PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty("meta.vertices", NUM_VERTICES); configuration.setProperty("meta.edges", NUM_EDGES); configuration.setProperty("directed", IS_DIRECTED); configuration.setProperty("vertex-file", VERTEX_FILE_PATH); configuration.setProperty("edge-file", EDGE_FILE_PATH); return new Fixture(NAME, formattedGraph, configuration); }
Example 5
Source File: DictionaryToRawIndexConverter.java From incubator-pinot with Apache License 2.0 | 6 votes |
/** * Helper method to update the metadata.properties for the converted segment. * * @param segmentDir Segment directory * @param columns Converted columns * @param tableName New table name to be written in the meta-data. Skipped if null. * @throws IOException * @throws ConfigurationException */ private void updateMetadata(File segmentDir, String[] columns, String tableName) throws IOException, ConfigurationException { File metadataFile = new File(segmentDir, V1Constants.MetadataKeys.METADATA_FILE_NAME); PropertiesConfiguration properties = new PropertiesConfiguration(metadataFile); if (tableName != null) { properties.setProperty(V1Constants.MetadataKeys.Segment.TABLE_NAME, tableName); } for (String column : columns) { properties.setProperty( V1Constants.MetadataKeys.Column.getKeyFor(column, V1Constants.MetadataKeys.Column.HAS_DICTIONARY), false); properties.setProperty( V1Constants.MetadataKeys.Column.getKeyFor(column, V1Constants.MetadataKeys.Column.BITS_PER_ELEMENT), -1); } properties.save(); }
Example 6
Source File: OfflineCredentialsTest.java From googleads-java-lib with Apache License 2.0 | 6 votes |
/** * Tests that the builder correctly identifies the file path. */ @Test public void testReadPropertiesFromFile_refreshTokenBadWithFilePath() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientId", "clientId"); config.setProperty("api.admanager.clientSecret", "clientSecret"); when(configurationHelper.fromFile("/home/user/path")).thenReturn(config); ForApiBuilder builder = new OfflineCredentials.ForApiBuilder( configurationHelper, OfflineCredentials.Api.AD_MANAGER, oAuth2Helper); thrown.expect(ValidationException.class); thrown.expectMessage( "A refresh token must be set as api.admanager.refreshToken in /home/user/path." + "\nIt is required for offline credentials. If you need to create one, " + "see the GetRefreshToken example."); builder.fromFile("/home/user/path").build(); }
Example 7
Source File: SecureEmbeddedServerTestBase.java From incubator-atlas with Apache License 2.0 | 6 votes |
/** * Runs the existing webapp test cases, this time against the initiated secure server instance. * @throws Exception */ @Test public void runOtherSuitesAgainstSecureServer() throws Exception { final PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl); // setup the credential provider setupCredentials(); try { secureEmbeddedServer = new SecureEmbeddedServer(securePort, TestUtils.getWarPath()) { @Override protected PropertiesConfiguration getConfiguration() { return configuration; } }; secureEmbeddedServer.server.start(); TestListenerAdapter tla = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[]{AdminJerseyResourceIT.class, EntityJerseyResourceIT.class, MetadataDiscoveryJerseyResourceIT.class, TypesJerseyResourceIT.class}); testng.addListener(tla); testng.run(); } finally { secureEmbeddedServer.server.stop(); } }
Example 8
Source File: TestDbSetup.java From cloudstack with Apache License 2.0 | 6 votes |
public static void updateSqlPort(int port, String propertyFileOverride) throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(propertyFileOverride); System.out.println("File: " + propertyFileOverride + "; old: db.properties port: " + config.getProperty("db.cloud.port") + ", new port: " + port); config.setProperty("db.cloud.port", "" + port); config.setProperty("db.cloud.username", System.getProperty("user.name")); config.setProperty("db.cloud.password", ""); config.setProperty("db.usage.port", "" + port); config.setProperty("db.usage.username", System.getProperty("user.name")); config.setProperty("db.usage.password", ""); config.setProperty("db.simulator.port", "" + port); config.setProperty("db.simulator.username", System.getProperty("user.name")); config.setProperty("db.simulator.password", ""); config.save(); }
Example 9
Source File: SecureEmbeddedServerTestBase.java From atlas with Apache License 2.0 | 6 votes |
@Test public void testMissingEntriesInCredentialProvider() throws Exception { // setup the configuration final PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl); try { secureEmbeddedServer = new SecureEmbeddedServer( EmbeddedServer.ATLAS_DEFAULT_BIND_ADDRESS, securePort, TestUtils.getWarPath()) { @Override protected PropertiesConfiguration getConfiguration() { return configuration; } }; Assert.fail("No entries should generate an exception"); } catch (IOException e) { Assert.assertTrue(e.getMessage().startsWith("No credential entry found for")); } finally { secureEmbeddedServer.server.stop(); } }
Example 10
Source File: NetAggregateTest.java From sqlg with MIT License | 5 votes |
@BeforeClass public static void beforeClass() { URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties"); try { configuration = new PropertiesConfiguration(sqlProperties); configuration.setProperty("cache.vertices", true); if (!configuration.containsKey("jdbc.url")) { throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url")); } } catch (ConfigurationException e) { throw new RuntimeException(e); } }
Example 11
Source File: HBaseGraphConfiguration.java From hgraphdb with Apache License 2.0 | 5 votes |
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { PropertiesConfiguration conf = new PropertiesConfiguration(); int size = stream.readInt(); for (int i = 0; i < size; i++) { conf.setProperty(stream.readUTF(), stream.readObject()); } this.conf = conf; }
Example 12
Source File: OfflineCredentialsTest.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** * Tests that the builder correctly fails on a bad configuration. */ @Test public void testReadPropertiesFromConfiguration_missingClientId() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.clientSecret", "clientSecret"); config.setProperty("api.admanager.refreshToken", "refreshToken"); thrown.expect(ValidationException.class); new OfflineCredentials.Builder() .forApi(OfflineCredentials.Api.AD_MANAGER) .from(config) .build(); }
Example 13
Source File: AdWordsSessionTest.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** Tests that the builder correctly reads properties from a configuration. */ @Test public void testReadPropertiesFromConfiguration() throws ValidationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.adwords.clientCustomerId", "1234567890"); config.setProperty("api.adwords.userAgent", "FooBar"); config.setProperty("api.adwords.developerToken", "devTokendevTokendevTok"); config.setProperty("api.adwords.isPartialFailure", "false"); AdWordsSession session = build(new AdWordsSession.Builder().from(config).withOAuth2Credential(credential)); assertEquals("1234567890", session.getClientCustomerId()); assertEquals("FooBar", session.getUserAgent()); assertEquals("devTokendevTokendevTok", session.getDeveloperToken()); assertFalse(session.isPartialFailure()); ReportingConfiguration reportingConfig = session.getReportingConfiguration(); assertNotNull("reporting configuration is null", reportingConfig); // Verify that the ReportingConfiguration's attributes are set to the expected default value // (null). assertNull( "include zero impressions is not null when no reporting options in config", reportingConfig.isIncludeZeroImpressions()); assertNull( "skip column header is not null, but no reporting options in config", reportingConfig.isSkipColumnHeader()); assertNull( "skip report header is not null, but no reporting options in config", reportingConfig.isSkipReportHeader()); assertNull( "skip report summary is not null, but no reporting options in config", reportingConfig.isSkipReportSummary()); assertNull( "use raw enum values is not null, but no reporting options in config", reportingConfig.isUseRawEnumValues()); assertNull( "download timeout is not null, but no reporting options in config", reportingConfig.getReportDownloadTimeout()); }
Example 14
Source File: ZookeeperConnectorTest.java From secor with Apache License 2.0 | 5 votes |
protected void verify(String zookeeperPath, String expectedOffsetPath) { ZookeeperConnector zookeeperConnector = new ZookeeperConnector(); PropertiesConfiguration properties = new PropertiesConfiguration(); properties.setProperty("kafka.zookeeper.path", zookeeperPath); properties.setProperty("secor.kafka.group", "secor_cg"); SecorConfig secorConfig = new SecorConfig(properties); zookeeperConnector.setConfig(secorConfig); Assert.assertEquals(expectedOffsetPath, zookeeperConnector.getCommittedOffsetGroupPath()); }
Example 15
Source File: OfflineCredentialsTest.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** * Tests that the builder does not fail when missing everything but a service account key. */ @Test public void testReadPropertiesFromConfiguration_onlyKeyFilePath() throws Exception { PropertiesConfiguration config = new PropertiesConfiguration(); config.setProperty("api.admanager.jsonKeyFilePath", "jsonKeyFilePath"); new OfflineCredentials.Builder() .forApi(OfflineCredentials.Api.AD_MANAGER) .from(config) .build(); }
Example 16
Source File: SSLAndKerberosTest.java From atlas with Apache License 2.0 | 4 votes |
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(); 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.trustedproxy", "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(); }
Example 17
Source File: SSLAndKerberosTest.java From incubator-atlas with Apache License 2.0 | 4 votes |
@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(); 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(); }
Example 18
Source File: AccumuloGraphConfiguration.java From AccumuloGraph with Apache License 2.0 | 4 votes |
/** * Default constructor. Will initialize the configuration * with default settings. */ public AccumuloGraphConfiguration() { conf = new PropertiesConfiguration(); conf.setProperty(Keys.GRAPH_CLASS, ACCUMULO_GRAPH_CLASSNAME); setDefaults(); }
Example 19
Source File: SegmentColumnarIndexCreator.java From incubator-pinot with Apache License 2.0 | 4 votes |
public static void addColumnMinMaxValueInfo(PropertiesConfiguration properties, String column, String minValue, String maxValue) { properties.setProperty(getKeyFor(column, MIN_VALUE), minValue); properties.setProperty(getKeyFor(column, MAX_VALUE), maxValue); }
Example 20
Source File: LogicalPlanSerializer.java From Bats with Apache License 2.0 | 4 votes |
public static PropertiesConfiguration convertToProperties(LogicalPlan dag) { PropertiesConfiguration props = new PropertiesConfiguration(); Collection<OperatorMeta> allOperators = dag.getAllOperators(); for (OperatorMeta operatorMeta : allOperators) { String operatorKey = LogicalPlanConfiguration.OPERATOR_PREFIX + operatorMeta.getName(); Operator operator = operatorMeta.getOperator(); props.setProperty(operatorKey + "." + LogicalPlanConfiguration.OPERATOR_CLASSNAME, operator.getClass().getName()); BeanMap operatorProperties = LogicalPlanConfiguration.getObjectProperties(operator); @SuppressWarnings("rawtypes") Iterator entryIterator = operatorProperties.entryIterator(); while (entryIterator.hasNext()) { try { @SuppressWarnings("unchecked") Map.Entry<String, Object> entry = (Map.Entry<String, Object>)entryIterator.next(); if (!entry.getKey().equals("class") && !entry.getKey().equals("name") && entry.getValue() != null) { props.setProperty(operatorKey + "." + entry.getKey(), entry.getValue()); } } catch (Exception ex) { LOG.warn("Error trying to get a property of operator {}", operatorMeta.getName(), ex); } } } Collection<StreamMeta> allStreams = dag.getAllStreams(); for (StreamMeta streamMeta : allStreams) { String streamKey = LogicalPlanConfiguration.STREAM_PREFIX + streamMeta.getName(); OutputPortMeta source = streamMeta.getSource(); Collection<InputPortMeta> sinks = streamMeta.getSinks(); props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SOURCE, source.getOperatorMeta().getName() + "." + source.getPortName()); String sinksValue = ""; for (InputPortMeta sink : sinks) { if (!sinksValue.isEmpty()) { sinksValue += ","; } sinksValue += sink.getOperatorMeta().getName() + "." + sink.getPortName(); } props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SINKS, sinksValue); if (streamMeta.getLocality() != null) { props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_LOCALITY, streamMeta.getLocality().name()); } } // TBD: Attributes return props; }