List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:SendMailImpl.java
public void sendMessage(String from, String[] recipients, String subject, String message) throws MessagingException { boolean debug = false; //Set the host smtp address Properties props = new Properties(); props.put("mail.smtp.host", smtpHost); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); session.setDebug(debug);//from w ww .j a va 2 s . c o m // create a message Message msg = new MimeMessage(session); // set the from and to address InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i < recipients.length; i++) { addressTo[i] = new InternetAddress(recipients[i]); } msg.setRecipients(Message.RecipientType.TO, addressTo); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/html"); Transport.send(msg); }
From source file:com.acme.ModuleConfigurationTest.java
@Test public void test() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); Properties properties = new Properties(); properties.put("prefix", "foo"); properties.put("suffix", "bar"); context.getEnvironment().getPropertySources().addLast(new PropertiesPropertySource("options", properties)); context.register(TestConfiguration.class); context.refresh();/*from www .j a va 2 s . c o m*/ MessageChannel input = context.getBean("input", MessageChannel.class); SubscribableChannel output = context.getBean("output", SubscribableChannel.class); final AtomicBoolean handled = new AtomicBoolean(); output.subscribe(new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { handled.set(true); assertEquals("foohellobar", message.getPayload()); } }); input.send(new GenericMessage<String>("hello")); assertTrue(handled.get()); }
From source file:com.badgersoft.eseoprocessor.config.MailConfig.java
@Bean VelocityEngineFactoryBean velocityEngine() { VelocityEngineFactoryBean velocityEngine = new VelocityEngineFactoryBean(); //velocityEngine.setResourceLoaderPath("/velocity"); Properties velocityProperties = new Properties(); velocityProperties.put("input.encoding", "utf-8"); velocityProperties.put("output.encoding", "utf-8"); //velocityProperties.put("file.resource.loader.path", "//velocity"); velocityEngine.setVelocityProperties(velocityProperties); return velocityEngine; }
From source file:com.example.app.config.ProjectDataConfig.java
@Bean @Override/*from w ww . j a v a 2 s. com*/ public Properties sessionFactoryHibernateProperties() { final Properties props = super.sessionFactoryHibernateProperties(); props.put("org.hibernate.envers.default_schema", ProjectConfig.ENVERS_SCHEMA); return props; }
From source file:com.carrotgarden.maven.aws.grv.TestCarrotGroovyRunner.java
@Test public void testFile() throws Exception { final Properties properties = new Properties(); properties.put("prop-key", "prop-value-1"); assertEquals(properties.get("prop-key"), "prop-value-1"); final MavenProject project = mock(MavenProject.class); when(project.getProperties()).thenReturn(properties); final CarrotGroovyRunner runner = new CarrotGroovyRunner(project); final File script = new File("./src/test/resources/script.groovy"); final Object result = runner.execute(script); assertEquals(result, "result"); assertEquals(properties.get("prop-key"), "prop-value-2"); }
From source file:org.trustedanalytics.kafka.adminapi.config.KafkaConfig.java
private ConsumerConfig consumerConfig() { // to be able to read topics many times we need to randomize the consumer group name Random rnd = new Random(); String consumerGroupId = "" + new Date().getTime() + "_" + rnd.nextInt(10000); Properties props = new Properties(); props.put("zookeeper.connect", zookeeperUri); props.put("group.id", consumerGroupId); props.put("consumer.timeout.ms", "1000"); // it will throw ConsumerTimeoutException props.put("auto.offset.reset", "smallest"); // when there is no (valid) offset props.put("zookeeper.session.timeout.ms", "1000"); props.put("zookeeper.sync.time.ms", "200"); props.put("auto.commit.interval.ms", "1000"); return new ConsumerConfig(props); }
From source file:ar.com.zauber.commons.web.proxy.impl.dao.properties.PropertiesChainedRegexURLRequestMapperDAOTest.java
/** test */ public final void testLoadNoStrip() { final Properties p = new Properties(); p.put("0", "^/nexus/(.*)$=http://localhost:9095/nexus/$1"); final PropertiesChainedRegexURLRequestMapperDAO dao = new PropertiesChainedRegexURLRequestMapperDAO( new SimplePropertiesProvider(p), new NullPropertiesPersister()); dao.setStripContextPath(false);//from w w w. ja v a 2s.c om dao.setStripServletPath(false); final ChainedURLRequestMapper c = (ChainedURLRequestMapper) dao.load(); RegexURLRequestMapper r = (RegexURLRequestMapper) c.getChain()[0]; assertFalse(r.isStripServletPath()); }
From source file:com.opencart.config.SpringConfigurations.java
public Properties hibProperties() { Properties properties = new Properties(); properties.put("hibernate.hbm2ddl.auto", "update"); properties.put("hibernate.dialect", "org.hibernate.dialect.OracleDialect"); properties.put("hibernate.show_sql", "true"); return properties; }
From source file:com.orange.spring.cloud.connector.s3.localconfig.LocalConfigConnectorS3ServiceTest.java
@Test public void serviceCreation() { Properties properties = new Properties(); properties.put("spring.cloud.mys3", getS3ServiceUrl()); properties.put("spring.cloud.appId", "mysuperapp"); when(System.getProperties()).thenReturn(properties); when(System.getProperty("spring.cloud.appId", null)).thenReturn("mysuperapp"); assertTrue(this.testCloudConnector.isInMatchingCloud()); List<ServiceInfo> serviceInfos = testCloudConnector.getServiceInfos(); ServiceInfo serviceInfo = getServiceInfo(serviceInfos, "mys3"); assertNotNull(serviceInfo);/* w ww . ja va 2s.c om*/ assertTrue(serviceInfo instanceof S3ServiceInfo); assertS3ServiceInfo((S3ServiceInfo) serviceInfo, hostname, port); }
From source file:gobblin.admin.AdminWebServerTest.java
@BeforeTest public void startServer() { Properties properties = new Properties(); properties.put(ConfigurationKeys.ADMIN_SERVER_PORT_KEY, this.portNumber); this.server = new AdminWebServer(properties, URI.create("http://foobar:3333")); try {/* ww w .j av a 2 s . c o m*/ this.server.startUp(); } catch (Exception e) { fail(String.format("Exception starting server: %s", e.toString())); } }