use of com.dtflys.forest.converter.json.ForestJsonConverter in project forest by dromara.
the class TestFastjsonConverter method testConfig.
@Test
public void testConfig() {
ForestJsonConverter jsonConverter = forestConfiguration.getJsonConverter();
assertThat(jsonConverter).isNotNull().isInstanceOf(ForestFastjsonConverter.class);
ForestFastjsonConverter forestFastjsonConverter = (ForestFastjsonConverter) jsonConverter;
assertThat(forestFastjsonConverter.getDateFormat()).isEqualTo("yyyy/MM/dd hh:mm:ss");
}
use of com.dtflys.forest.converter.json.ForestJsonConverter in project forest by dromara.
the class TestGsonConverter method testConfig.
@Test
public void testConfig() {
ForestJsonConverter jsonConverter = forestConfiguration.getJsonConverter();
assertThat(jsonConverter).isNotNull().isInstanceOf(ForestGsonConverter.class);
ForestGsonConverter forestGsonConverter = (ForestGsonConverter) jsonConverter;
assertThat(forestGsonConverter.getDateFormat()).isEqualTo("yyyy/MM/dd hh:mm:ss");
}
use of com.dtflys.forest.converter.json.ForestJsonConverter in project forest by dromara.
the class TestJacksonConverter method testConfig.
@Test
public void testConfig() {
ForestJsonConverter jsonConverter = forestConfiguration.getJsonConverter();
assertThat(jsonConverter).isNotNull().isInstanceOf(ForestJacksonConverter.class);
ForestJacksonConverter forestJacksonConverter = (ForestJacksonConverter) jsonConverter;
assertThat(forestJacksonConverter.getDateFormat()).isEqualTo("yyyy/MM/dd hh:mm:ss");
}
use of com.dtflys.forest.converter.json.ForestJsonConverter 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());
}
use of com.dtflys.forest.converter.json.ForestJsonConverter in project forest by dromara.
the class TestForestConfiguration method testJSONConverterSelect.
@Test
public void testJSONConverterSelect() throws Throwable {
JSONConverterSelector jsonConverterSelector = new JSONConverterSelector();
JSONConverterSelector spy = Mockito.spy(jsonConverterSelector);
Mockito.when(spy.checkFastJSONClass()).thenThrow(new ClassNotFoundException("com.alibaba.fastjson.JSON"));
ForestJsonConverter jsonConverter = spy.select();
assertNotNull(jsonConverter);
assertTrue(jsonConverter instanceof ForestJacksonConverter);
jsonConverterSelector = new JSONConverterSelector();
spy = Mockito.spy(jsonConverterSelector);
Mockito.when(spy.checkFastJSONClass()).thenThrow(new ClassNotFoundException("com.alibaba.fastjson.JSON"));
Mockito.when(spy.checkJacsonClass()).thenThrow(new ClassNotFoundException("com.fasterxml.jackson.databind.ObjectMapper"));
jsonConverter = spy.select();
assertNotNull(jsonConverter);
assertTrue(jsonConverter instanceof ForestGsonConverter);
jsonConverterSelector = new JSONConverterSelector();
spy = Mockito.spy(jsonConverterSelector);
Mockito.when(spy.checkFastJSONClass()).thenThrow(new ClassNotFoundException("com.alibaba.fastjson.JSON"));
Mockito.when(spy.checkJacsonClass()).thenThrow(new ClassNotFoundException("com.fasterxml.jackson.databind.ObjectMapper"));
Mockito.when(spy.checkGsonClass()).thenThrow(new ClassNotFoundException("com.google.gson.JsonParser"));
jsonConverter = spy.select();
assertNull(jsonConverter);
}
Aggregations