Search in sources :

Example 11 with Props

use of cn.hutool.setting.dialect.Props in project hutool by looly.

the class PropsTest method toBeanTest.

@Test
public void toBeanTest() {
    Props props = Props.getProp("to_bean_test.properties");
    ConfigProperties cfg = props.toBean(ConfigProperties.class, "mail");
    Assert.assertEquals("mailer@mail.com", cfg.getHost());
    Assert.assertEquals(9000, cfg.getPort());
    Assert.assertEquals("mailer@mail.com", cfg.getFrom());
    Assert.assertEquals("john", cfg.getCredentials().getUsername());
    Assert.assertEquals("password", cfg.getCredentials().getPassword());
    Assert.assertEquals("SHA1", cfg.getCredentials().getAuthMethod());
    Assert.assertEquals("true", cfg.getAdditionalHeaders().get("redelivery"));
    Assert.assertEquals("true", cfg.getAdditionalHeaders().get("secure"));
    Assert.assertEquals("admin@mail.com", cfg.getDefaultRecipients().get(0));
    Assert.assertEquals("owner@mail.com", cfg.getDefaultRecipients().get(1));
}
Also used : Props(cn.hutool.setting.dialect.Props) Test(org.junit.Test)

Example 12 with Props

use of cn.hutool.setting.dialect.Props in project hutool by looly.

the class PropsTest method propTest.

@Test
public void propTest() {
    // noinspection MismatchedQueryAndUpdateOfCollection
    Props props = new Props("test.properties");
    String user = props.getProperty("user");
    Assert.assertEquals(user, "root");
    String driver = props.getStr("driver");
    Assert.assertEquals(driver, "com.mysql.jdbc.Driver");
}
Also used : Props(cn.hutool.setting.dialect.Props) Test(org.junit.Test)

Aggregations

Props (cn.hutool.setting.dialect.Props)12 Test (org.junit.Test)6 Ignore (org.junit.Ignore)2 DbRuntimeException (cn.hutool.db.DbRuntimeException)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 PropertyVetoException (java.beans.PropertyVetoException)1 Properties (java.util.Properties)1 DataSource (org.apache.tomcat.jdbc.pool.DataSource)1 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)1