Example usage for java.util Properties setProperty

List of usage examples for java.util Properties setProperty

Introduction

In this page you can find the example usage for java.util Properties setProperty.

Prototype

public synchronized Object setProperty(String key, String value) 

Source Link

Document

Calls the Hashtable method put .

Usage

From source file:com.cloudera.oryx.kafka.util.ProduceData.java

public void start() throws InterruptedException, IOException {
    KafkaUtils.maybeCreateTopic("localhost", zkPort, topic);
    RandomGenerator random = RandomManager.getRandom();

    Properties producerProps = new Properties();
    producerProps.setProperty("metadata.broker.list", "localhost:" + kafkaPort);
    producerProps.setProperty("serializer.class", "kafka.serializer.StringEncoder");

    Thread.sleep(intervalMsec);/*from  ww  w  . java2  s.c om*/
    Producer<String, String> producer = new Producer<>(new ProducerConfig(producerProps));
    try {
        for (int i = 0; i < howMany; i++) {
            Pair<String, String> datum = datumGenerator.generate(i, random);
            KeyedMessage<String, String> keyedMessage = new KeyedMessage<>(topic, datum.getFirst(),
                    datum.getSecond());
            producer.send(keyedMessage);
            log.debug("Sent datum {} = {}", keyedMessage.key(), keyedMessage.message());
            Thread.sleep(intervalMsec);
        }
    } finally {
        producer.close();
    }
}

From source file:com.petecapra.restconfig.config.AppConfig.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan("com.petecapra.restconfig.domain");
    entityManagerFactoryBean.setPersistenceProvider(new HibernatePersistence());
    Properties jpaProperties = new Properties();
    jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
    entityManagerFactoryBean.setJpaProperties(jpaProperties);
    return entityManagerFactoryBean;
}

From source file:org.camelcookbook.examples.testing.spring.SimpleTransformPropertiesInjectingSpringTest.java

@Override
protected Properties useOverridePropertiesWithPropertiesComponent() {
    Properties properties = new Properties();
    properties.setProperty("start.endpoint", "direct:in");
    properties.setProperty("end.endpoint", "mock:out");
    return properties;
}

From source file:gobblin.data.management.copy.extractor.InputStreamExtractorTest.java

private CopyableFile getTestCopyableFile(String resourcePath) throws IOException {
    String filePath = getClass().getClassLoader().getResource(resourcePath).getFile();
    FileStatus status = new FileStatus(0l, false, 0, 0l, 0l, new Path(filePath));

    Properties properties = new Properties();
    properties.setProperty(ConfigurationKeys.DATA_PUBLISHER_FINAL_DIR, "/publisher");

    return CopyableFile.fromOriginAndDestination(FileSystem.getLocal(new Configuration()), status,
            new Path("/destination"),
            CopyConfiguration.builder(FileSystem.getLocal(new Configuration()), properties)
                    .preserve(PreserveAttributes.fromMnemonicString("")).build())
            .build();/*w w w . ja  v  a 2 s.c o m*/
}

From source file:br.com.alura.casadocodigo.conf.JPAConfiguration.java

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

    LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();

    JpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
    factoryBean.setJpaVendorAdapter(adapter);

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUsername("root");
    dataSource.setPassword("");
    dataSource.setUrl("jdbc:mysql://localhost:3306/casadocodigo");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    factoryBean.setDataSource(dataSource);

    Properties properties = new Properties();
    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    properties.setProperty("hibernate.show_sql", "true");
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    factoryBean.setJpaProperties(properties);

    factoryBean.setPackagesToScan("br.com.alura.casadocodigo.models");

    return factoryBean;
}

From source file:com.urservices.urerp.ecole.config.context.PersistenceJPAConfig.java

Properties additionalProperties() {
    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MYSQL5Dialect");
    return properties;
}

From source file:br.com.projetotcc.conf.JPAConfiguration.java

private Properties additionalProperties() {

    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto", "update");
    properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    properties.setProperty("hibernate.show_sql", "true");

    return properties;
}

From source file:fr.xebia.springframework.security.core.userdetails.memory.ExtendedInMemoryDaoImplTest.java

@Test
public void testSetUserBadProperties() {
    ExtendedInMemoryDaoImpl dao = new ExtendedInMemoryDaoImpl();
    Properties properties = new Properties();
    properties.setProperty("bill", ""); // at least password is mandatory so
                                        // it will fail
    dao.setUserProperties(properties);/*from   ww w  .j a  va  2  s.  c  o m*/
    assertEquals("Unexpected user", 0, dao.getUserMap().getUserCount());
}

From source file:org.spring.data.gemfire.app.main.SpringGemFireServer.java

@Bean
Properties gemfireProperties(@Value("${gemfire.log.level:config}") String logLevel,
        @Value("${gemfire.locator.host-port:localhost[10334]}") String locatorHostPort,
        @Value("${gemfire.manager.port:1099}") String managerPort) {
    Properties gemfireProperties = new Properties();

    gemfireProperties.setProperty("name", SpringGemFireServer.class.getSimpleName());
    gemfireProperties.setProperty("mcast-port", "0");
    gemfireProperties.setProperty("log-level", logLevel);
    gemfireProperties.setProperty("jmx-manager", "true");
    gemfireProperties.setProperty("jmx-manager-port", managerPort);
    gemfireProperties.setProperty("jmx-manager-start", "true");
    gemfireProperties.setProperty("start-locator", locatorHostPort);

    return gemfireProperties;
}

From source file:com.pros.jsontransform.examples.constraints.ValidationTest.java

@Test
public void testConstraints() throws IOException, ObjectTransformerException {
    jsonSource = JunitTools.readFile(pathToJson + "/" + fileNamePrefix + "Source.json");
    jsonTransform = JunitTools.readFile(pathToJson + "/" + fileNamePrefix + "Map.json");
    jsonTarget = JunitTools.readFile(pathToJson + "/" + fileNamePrefix + "Target.json");

    Properties properties = new Properties();
    properties.setProperty("plugin.folder", "c:/temp/plugins");
    ObjectTransformer transformer = new ObjectTransformer(properties, mapper);
    String result = transformer.transform(jsonSource, jsonTransform);

    System.out.println(result);//from   w  w w . ja  v  a2  s  .c  o m

    assertTrue(mapper.readTree(result).equals(mapper.readTree(jsonTarget)));
}