Java Code Examples for java.util.Properties#setProperty()
The following examples show how to use
java.util.Properties#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: ArrayIT.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testVariableLengthArrayWithNullValue() throws Exception { long ts = nextTimestamp(); String tenantId = getOrganizationId(); createTableWithArray(getUrl(), getDefaultSplits(tenantId), null, ts - 2); initTablesWithArrays(tenantId, null, ts, true, getUrl()); String query = "SELECT a_string_array[2] FROM table_with_array"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 2 Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); String[] strArr = new String[1]; strArr[0] = "XYZWER"; String result = rs.getString(1); assertNull(result); } finally { conn.close(); } }
Example 2
Source File: JDBCInterpreterTest.java From zeppelin with Apache License 2.0 | 6 votes |
@Test public void testIncorrectPrecode() throws IOException, InterpreterException { Properties properties = new Properties(); properties.setProperty("default.driver", "org.h2.Driver"); properties.setProperty("default.url", getJdbcConnection()); properties.setProperty("default.user", ""); properties.setProperty("default.password", ""); properties.setProperty(DEFAULT_PRECODE, "select 1"); properties.setProperty("incorrect.driver", "org.h2.Driver"); properties.setProperty("incorrect.url", getJdbcConnection()); properties.setProperty("incorrect.user", ""); properties.setProperty("incorrect.password", ""); properties.setProperty(String.format(PRECODE_KEY_TEMPLATE, "incorrect"), "incorrect command"); JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(properties); jdbcInterpreter.open(); InterpreterResult interpreterResult = jdbcInterpreter.executePrecode(context); assertEquals(InterpreterResult.Code.ERROR, interpreterResult.code()); assertEquals(InterpreterResult.Type.TEXT, interpreterResult.message().get(0).getType()); }
Example 3
Source File: SiteSettings.java From cuba with Apache License 2.0 | 6 votes |
public Properties getFreeMarkerSettings() { GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class); Map<String, Locale> availableLocales = globalConfig.getAvailableLocales(); if (availableLocales.isEmpty()) { throw new IllegalStateException("Property cuba.availableLocales is not configured"); } Locale locale = availableLocales.values().iterator().next(); FormatStrings formatStrings = formatStringsRegistry.getFormatStrings(locale); final Properties freemarkerSettings = new Properties(); freemarkerSettings.setProperty("number_format", "#"); freemarkerSettings.setProperty("datetime_format", formatStrings.getDateTimeFormat()); freemarkerSettings.setProperty("date_format", formatStrings.getDateFormat()); freemarkerSettings.setProperty("template_exception_handler", "rethrow"); return freemarkerSettings; }
Example 4
Source File: TypedJsonJUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public void testPDXObject() { final Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_ADDRESS_NAME, "239.192.81.10"); DistributedSystem.connect(props); Cache cache = new CacheFactory().create(); PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false); Portfolio p = new Portfolio(2); pf.writeInt("ID", 111); pf.writeString("status", "active"); pf.writeString("secId", "IBM"); pf.writeObject("portfolio", p); PdxInstance pi = pf.create(); TypedJson tJsonObj = new TypedJson(RESULT,pi); System.out.println(tJsonObj); cache.close(); }
Example 5
Source File: JobConfigFileMonitorTest.java From incubator-gobblin with Apache License 2.0 | 6 votes |
@BeforeClass public void setUp() throws Exception { this.jobConfigDir = Files.createTempDirectory(String.format("gobblin-test_%s_job-conf", this.getClass().getSimpleName())) .toString(); FileUtils.forceDeleteOnExit(new File(this.jobConfigDir)); FileUtils.copyDirectory(new File(JOB_CONFIG_FILE_DIR), new File(jobConfigDir)); Properties properties = new Properties(); try (Reader schedulerPropsReader = new FileReader("gobblin-test/resource/gobblin.test.properties")) { properties.load(schedulerPropsReader); } properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY, jobConfigDir); properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, jobConfigDir); properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL_KEY, "1000"); properties.setProperty(ConfigurationKeys.METRICS_ENABLED_KEY, "false"); SchedulerService quartzService = new SchedulerService(new Properties()); this.jobScheduler = new JobScheduler(properties, quartzService); this.serviceManager = new ServiceManager(Lists.newArrayList(quartzService, this.jobScheduler)); this.serviceManager.startAsync().awaitHealthy(10, TimeUnit.SECONDS);; }
Example 6
Source File: ETable.java From netbeans with Apache License 2.0 | 5 votes |
/** * Method allowing to store customization values. * The stored values should be only those that the user has customized, * it does not make sense to store the values that were set using * the initialization code because the initialization code can be run * in the same way after restart. */ public void writeSettings(Properties p, String propertyPrefix) { TableColumnModel tcm = getColumnModel(); if (tcm instanceof ETableColumnModel) { ETableColumnModel etcm = (ETableColumnModel) tcm; etcm.writeSettings(p, propertyPrefix); } if (searchColumn != null) { p.setProperty( propertyPrefix + SEARCH_COLUMN, Integer.toString(searchColumn.getModelIndex())); } }
Example 7
Source File: PeriodicNotificationApplicationIT.java From rya with Apache License 2.0 | 5 votes |
private static Properties getKafkaProperties(final PeriodicNotificationApplicationConfiguration conf) { final Properties kafkaProps = new Properties(); kafkaProps.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); kafkaProps.setProperty(ConsumerConfig.CLIENT_ID_CONFIG, UUID.randomUUID().toString()); kafkaProps.setProperty(ConsumerConfig.GROUP_ID_CONFIG, conf.getNotificationGroupId()); kafkaProps.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); return kafkaProps; }
Example 8
Source File: PersistenceJPAConfig.java From Hands-On-High-Performance-with-Spring-5 with MIT License | 5 votes |
private Properties additionalProperties() { Properties properties = new Properties(); // properties.setProperty("hibernate.hbm2ddl.auto", this.env.getProperty("hibernate.hbm2ddl.auto")); properties.setProperty("javax.persistence.schema-generation.database.action", this.env.getProperty("javax.persistence.schema-generation.database.action")); properties.setProperty("hibernate.dialect", this.env.getProperty("hibernate.dialect")); properties.setProperty("hibernate.generate_statistics", this.env.getProperty("hibernate.generate_statistics")); properties.setProperty("hibernate.show_sql", this.env.getProperty("hibernate.show_sql")); properties.setProperty("hibernate.cache.use_second_level_cache", this.env.getProperty("hibernate.cache.use_second_level_cache")); properties.setProperty("hibernate.cache.use_query_cache", this.env.getProperty("hibernate.cache.use_query_cache")); properties.setProperty("hibernate.cache.region.factory_class", this.env.getProperty("hibernate.cache.region.factory_class")); properties.setProperty("javax.persistence.sql-load-script-source", this.env.getProperty("javax.persistence.sql-load-script-source")); return properties; }
Example 9
Source File: PropertyResolverTest.java From properties-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void validPlaceholderIsResolved() throws MojoFailureException { Properties properties = new Properties(); properties.setProperty( "p1", "${p2}" ); properties.setProperty( "p2", "value" ); String value1 = resolver.getPropertyValue( "p1", properties, new Properties() ); String value2 = resolver.getPropertyValue( "p2", properties, new Properties() ); assertEquals( "value", value1 ); assertEquals( "value", value2 ); }
Example 10
Source File: KinesisConfigUtilTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testThreadingModelInProducerConfiguration() { Properties testConfig = new Properties(); testConfig.setProperty(AWSConfigConstants.AWS_REGION, "us-east-1"); KinesisProducerConfiguration kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig); assertEquals(KinesisProducerConfiguration.ThreadingModel.POOLED, kpc.getThreadingModel()); testConfig.setProperty(KinesisConfigUtil.THREADING_MODEL, "PER_REQUEST"); kpc = KinesisConfigUtil.getValidatedProducerConfiguration(testConfig); assertEquals(KinesisProducerConfiguration.ThreadingModel.PER_REQUEST, kpc.getThreadingModel()); }
Example 11
Source File: SnowflakeKeyGenerateAlgorithmTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void assertSetWorkerIdFailureWhenOutOfRange() { SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm = new SnowflakeKeyGenerateAlgorithm(); Properties props = new Properties(); props.setProperty("worker.id", String.valueOf(Long.MIN_VALUE)); keyGenerateAlgorithm.setProps(props); keyGenerateAlgorithm.init(); keyGenerateAlgorithm.generateKey(); }
Example 12
Source File: NetConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected Properties getConnectionProperties(Properties incomingProps) { final Properties props = new Properties(); if (this.user_ != null) { props.setProperty(ClientAttribute.USERNAME, this.user_); } ClientBaseDataSource.setPassword(props, getDeferredResetPassword()); ClientBaseDataSource.setSecurityMechanism(props, securityMechanism_); switch (this.clientSSLMode_) { case ClientBaseDataSource.SSL_OFF: break; case ClientBaseDataSource.SSL_BASIC: props.setProperty(ClientAttribute.SSL, "basic"); break; case ClientBaseDataSource.SSL_PEER_AUTHENTICATION: props.setProperty(ClientAttribute.SSL, "peerAuthentication"); break; } final Properties connProps = (this.connProps != null ? this.connProps : incomingProps); if (connProps != null) { final java.util.Enumeration incomingPropNames = connProps .propertyNames(); while (incomingPropNames.hasMoreElements()) { final String propName = (String)incomingPropNames.nextElement(); final String propValue = connProps.getProperty(propName); props.setProperty(propName, propValue); } } return props; }
Example 13
Source File: SimpleTransformPropertiesInjectingSpringTest.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@Override protected Properties useOverridePropertiesWithPropertiesComponent() { Properties properties = new Properties(); properties.setProperty("start.endpoint", "direct:in"); properties.setProperty("end.endpoint", "mock:out"); return properties; }
Example 14
Source File: SettingsUtilsTest.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
@Test public void testGetArrayIncludes() throws Exception { Properties props = new Properties(); props.setProperty("es.read.field.as.array.include", "a:4"); PropertiesSettings settings = new PropertiesSettings(props); List<FieldFilter.NumberedInclude> filters = SettingsUtils.getFieldArrayFilterInclude(settings); assertThat(filters.size(), equalTo(1)); assertThat(filters.get(0), equalTo(new FieldFilter.NumberedInclude("a", 4))); }
Example 15
Source File: DerivedSchemaGenerationTest.java From incubator-pinot with Apache License 2.0 | 5 votes |
@BeforeTest public void setup() throws IOException { inputSchema = new Schema.Parser().parse(ClassLoader.getSystemResourceAsStream(AVRO_SCHEMA)); props = new Properties(); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_TABLE_NAME.toString(), "collection"); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_DIMENSION_NAMES.toString(), "d1,d2,d3"); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_DIMENSION_TYPES.toString(), "STRING,LONG,STRING"); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_METRIC_NAMES.toString(), "m1,m2"); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_METRIC_TYPES.toString(), "INT,INT"); props.setProperty(ThirdEyeConfigProperties.THIRDEYE_TIMECOLUMN_NAME.toString(), "hoursSinceEpoch"); }
Example 16
Source File: JMSBookStore.java From cxf with Apache License 2.0 | 5 votes |
private Context getContext() throws Exception { Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory"); props.setProperty(Context.PROVIDER_URL, "tcp://localhost:" + EmbeddedJMSBrokerLauncher.PORT); return new InitialContext(props); }
Example 17
Source File: OrphanViewTool.java From phoenix with Apache License 2.0 | 5 votes |
private void gracefullyDropView(PhoenixConnection phoenixConnection, Configuration configuration, Key key) throws Exception { PhoenixConnection tenantConnection = null; boolean newConn = false; try { if (key.getTenantId() != null) { Properties tenantProps = new Properties(); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, key.getTenantId()); tenantConnection = ConnectionUtil.getInputConnection(configuration, tenantProps). unwrap(PhoenixConnection.class); newConn = true; } else { tenantConnection = phoenixConnection; } MetaDataClient client = new MetaDataClient(tenantConnection); org.apache.phoenix.parse.TableName pTableName = org.apache.phoenix.parse.TableName .create(key.getSchemaName(), key.getTableName()); try { client.dropTable( new DropTableStatement(pTableName, PTableType.VIEW, false, true, true)); } catch (TableNotFoundException e) { LOGGER.info("Ignoring view " + pTableName + " as it has already been dropped"); } } finally { if (newConn) { tryClosingConnection(tenantConnection); } } }
Example 18
Source File: HashJoinCacheIT.java From phoenix with Apache License 2.0 | 5 votes |
@Test(expected = HashJoinCacheNotFoundException.class) public void testExpiredCacheWithInnerJoin() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.MAX_SERVER_CACHE_TIME_TO_LIVE_MS_ATTRIB, "1"); PreparedStatement statement = null; ResultSet rs = null; try (Connection conn = DriverManager.getConnection(getUrl(), props)) { String tableName1 = getTableName(conn, JOIN_SUPPLIER_TABLE_FULL_NAME); String tableName2 = getTableName(conn, JOIN_ITEM_TABLE_FULL_NAME); final String query = "SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + tableName1 + " supp INNER JOIN " + tableName2 + " item ON item.\"supplier_id\" = supp.\"supplier_id\" ORDER BY \"item_id\""; statement = conn.prepareStatement(query); rs = statement.executeQuery(); rs.next(); // should not reach here fail("HashJoinCacheNotFoundException was not thrown as expected"); } finally { if (statement != null) { statement.close(); } if (rs != null) { rs.close(); } } }
Example 19
Source File: HyperParameterTuningArbiterUiExample.java From Java-Deep-Learning-Cookbook with MIT License | 4 votes |
public static void main(String[] args) { ParameterSpace<Double> learningRateParam = new ContinuousParameterSpace(0.0001,0.01); ParameterSpace<Integer> layerSizeParam = new IntegerParameterSpace(5,11); MultiLayerSpace hyperParamaterSpace = new MultiLayerSpace.Builder() .updater(new AdamSpace(learningRateParam)) // .weightInit(WeightInit.DISTRIBUTION).dist(new LogNormalDistribution()) .addLayer(new DenseLayerSpace.Builder() .activation(Activation.RELU) .nIn(11) .nOut(layerSizeParam) .build()) .addLayer(new DenseLayerSpace.Builder() .activation(Activation.RELU) .nIn(layerSizeParam) .nOut(layerSizeParam) .build()) .addLayer(new OutputLayerSpace.Builder() .activation(Activation.SIGMOID) .lossFunction(LossFunctions.LossFunction.XENT) .nOut(1) .build()) .build(); Map<String,Object> dataParams = new HashMap<>(); dataParams.put("batchSize",new Integer(10)); Map<String,Object> commands = new HashMap<>(); commands.put(DataSetIteratorFactoryProvider.FACTORY_KEY, HyperParameterTuningArbiterUiExample.ExampleDataSource.class.getCanonicalName()); CandidateGenerator candidateGenerator = new RandomSearchGenerator(hyperParamaterSpace,dataParams); Properties dataSourceProperties = new Properties(); dataSourceProperties.setProperty("minibatchSize", "64"); ResultSaver modelSaver = new FileModelSaver("resources/"); ScoreFunction scoreFunction = new EvaluationScoreFunction(org.deeplearning4j.eval.Evaluation.Metric.ACCURACY); TerminationCondition[] conditions = { new MaxTimeCondition(120, TimeUnit.MINUTES), new MaxCandidatesCondition(30) }; OptimizationConfiguration optimizationConfiguration = new OptimizationConfiguration.Builder() .candidateGenerator(candidateGenerator) .dataSource(HyperParameterTuningArbiterUiExample.ExampleDataSource.class,dataSourceProperties) .modelSaver(modelSaver) .scoreFunction(scoreFunction) .terminationConditions(conditions) .build(); IOptimizationRunner runner = new LocalOptimizationRunner(optimizationConfiguration,new MultiLayerNetworkTaskCreator()); //Uncomment this if you want to store the model. StatsStorage ss = new FileStatsStorage(new File("HyperParamOptimizationStats.dl4j")); runner.addListeners(new ArbiterStatusListener(ss)); UIServer.getInstance().attach(ss); //runner.addListeners(new LoggingStatusListener()); //new ArbiterStatusListener(ss) runner.execute(); //Print the best hyper params double bestScore = runner.bestScore(); int bestCandidateIndex = runner.bestScoreCandidateIndex(); int numberOfConfigsEvaluated = runner.numCandidatesCompleted(); String s = "Best score: " + bestScore + "\n" + "Index of model with best score: " + bestCandidateIndex + "\n" + "Number of configurations evaluated: " + numberOfConfigsEvaluated + "\n"; System.out.println(s); }
Example 20
Source File: SchedulerFactoryBean.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Load and/or apply Quartz properties to the given SchedulerFactory. * @param schedulerFactory the SchedulerFactory to initialize */ private void initSchedulerFactory(SchedulerFactory schedulerFactory) throws SchedulerException, IOException { if (!(schedulerFactory instanceof StdSchedulerFactory)) { if (this.configLocation != null || this.quartzProperties != null || this.taskExecutor != null || this.dataSource != null) { throw new IllegalArgumentException( "StdSchedulerFactory required for applying Quartz properties: " + schedulerFactory); } // Otherwise assume that no initialization is necessary... return; } Properties mergedProps = new Properties(); if (this.resourceLoader != null) { mergedProps.setProperty(StdSchedulerFactory.PROP_SCHED_CLASS_LOAD_HELPER_CLASS, ResourceLoaderClassLoadHelper.class.getName()); } if (this.taskExecutor != null) { mergedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, LocalTaskExecutorThreadPool.class.getName()); } else { // Set necessary default properties here, as Quartz will not apply // its default configuration when explicitly given properties. mergedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName()); mergedProps.setProperty(PROP_THREAD_COUNT, Integer.toString(DEFAULT_THREAD_COUNT)); } if (this.configLocation != null) { if (logger.isInfoEnabled()) { logger.info("Loading Quartz config from [" + this.configLocation + "]"); } PropertiesLoaderUtils.fillProperties(mergedProps, this.configLocation); } CollectionUtils.mergePropertiesIntoMap(this.quartzProperties, mergedProps); if (this.dataSource != null) { mergedProps.put(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName()); } // Make sure to set the scheduler name as configured in the Spring configuration. if (this.schedulerName != null) { mergedProps.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, this.schedulerName); } ((StdSchedulerFactory) schedulerFactory).initialize(mergedProps); }