Search in sources :

Example 1 with TestLogHandler

use of com.dtflys.spring.test.logging.TestLogHandler in project forest by dromara.

the class ConfigurationTest method testConfiguration.

public void testConfiguration() {
    applicationContext = new ClassPathXmlApplicationContext(new String[] { "classpath:configuration-test.xml" });
    ForestConfiguration forestConfiguration = (ForestConfiguration) applicationContext.getBean("forestConfiguration2");
    assertNotNull(forestConfiguration);
    assertNotNull(forestConfiguration.getBackend());
    assertEquals(forestConfiguration.getTimeout(), new Integer(30000));
    assertEquals(forestConfiguration.getConnectTimeout(), new Integer(10000));
    assertEquals(forestConfiguration.getMaxConnections(), new Integer(500));
    assertEquals(forestConfiguration.getMaxRouteConnections(), new Integer(500));
    assertEquals(forestConfiguration.getSslProtocol(), "SSLv3");
    assertEquals(forestConfiguration.getVariableValue("baseUrl"), "http://www.thebeastshop.com");
    assertEquals(forestConfiguration.getVariableValue("x"), "0");
    assertEquals(forestConfiguration.getVariableValue("y"), "1");
    assertEquals(forestConfiguration.getBackend().getName(), "httpclient");
    assertEquals("GBK", forestConfiguration.getCharset());
    assertEquals(Boolean.TRUE, Boolean.valueOf(forestConfiguration.isLogEnabled()));
    assertEquals(Boolean.FALSE, Boolean.valueOf(forestConfiguration.isLogResponseStatus()));
    assertEquals(Boolean.TRUE, Boolean.valueOf(forestConfiguration.isLogResponseContent()));
    assertEquals(NoneRetryer.class, forestConfiguration.getRetryer());
    assertTrue(forestConfiguration.getLogHandler() instanceof TestLogHandler);
    ForestJsonConverter jsonConverter = forestConfiguration.getJsonConverter();
    assertNotNull(jsonConverter);
    assertTrue(jsonConverter instanceof ForestGsonConverter);
    assertEquals("yyyy/MM/dd hh:mm:ss", jsonConverter.getDateFormat());
}
Also used : ForestConfiguration(com.dtflys.forest.config.ForestConfiguration) ForestJsonConverter(com.dtflys.forest.converter.json.ForestJsonConverter) TestLogHandler(com.dtflys.spring.test.logging.TestLogHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ForestGsonConverter(com.dtflys.forest.converter.json.ForestGsonConverter)

Aggregations

ForestConfiguration (com.dtflys.forest.config.ForestConfiguration)1 ForestGsonConverter (com.dtflys.forest.converter.json.ForestGsonConverter)1 ForestJsonConverter (com.dtflys.forest.converter.json.ForestJsonConverter)1 TestLogHandler (com.dtflys.spring.test.logging.TestLogHandler)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1