Search in sources :

Example 21 with ForestConfiguration

use of com.dtflys.forest.config.ForestConfiguration in project forest by dromara.

the class TestForestConfiguration method testCustomized.

@Test
public void testCustomized() {
    ForestConfiguration configuration = ForestConfiguration.createConfiguration();
    configuration.setMaxRetryCount(3);
    // configuration.setId("config_2");
    // assertEquals("config_2", configuration.getId());
    assertEquals(Integer.valueOf(3), configuration.getMaxRetryCount());
    configuration.setMaxConnections(123);
    assertEquals(Integer.valueOf(123), configuration.getMaxConnections());
    configuration.setMaxRouteConnections(222);
    assertEquals(Integer.valueOf(222), configuration.getMaxRouteConnections());
    configuration.setTimeout(12000);
    assertEquals(Integer.valueOf(12000), configuration.getTimeout());
    configuration.setSslProtocol(SSLUtils.SSL_3);
    configuration.setConnectTimeout(2000);
}
Also used : ForestConfiguration(com.dtflys.forest.config.ForestConfiguration) Test(org.junit.Test)

Example 22 with ForestConfiguration

use of com.dtflys.forest.config.ForestConfiguration in project forest by dromara.

the class TestForestConfiguration method testConverterMap.

@Test
public void testConverterMap() {
    ForestConfiguration configuration = ForestConfiguration.createConfiguration();
    assertNotNull(configuration.getConverterMap());
    Map<ForestDataType, ForestConverter> converterMap = new HashMap<>();
    converterMap.put(ForestDataType.JSON, new ForestFastjsonConverter());
    configuration.setConverterMap(converterMap);
    assertEquals(converterMap, configuration.getConverterMap());
}
Also used : ForestFastjsonConverter(com.dtflys.forest.converter.json.ForestFastjsonConverter) ForestConfiguration(com.dtflys.forest.config.ForestConfiguration) HashMap(java.util.HashMap) ForestConverter(com.dtflys.forest.converter.ForestConverter) ForestDataType(com.dtflys.forest.utils.ForestDataType) Test(org.junit.Test)

Example 23 with ForestConfiguration

use of com.dtflys.forest.config.ForestConfiguration in project forest by dromara.

the class TestObjectConstructor method testRegisterObject.

@Test
public void testRegisterObject() {
    ForestConfiguration configuration = ForestConfiguration.createConfiguration();
    configuration.getForestObjectFactory().registerObject(SuccessWhen.class, new MySuccessWhen2());
    SuccessWhen forestObject = configuration.getForestObject(SuccessWhen.class);
    assertEquals(MySuccessWhen2.class, forestObject.getClass());
}
Also used : ForestConfiguration(com.dtflys.forest.config.ForestConfiguration) SuccessWhen(com.dtflys.forest.callback.SuccessWhen) Test(org.junit.Test)

Aggregations

ForestConfiguration (com.dtflys.forest.config.ForestConfiguration)23 Test (org.junit.Test)12 ForestRuntimeException (com.dtflys.forest.exceptions.ForestRuntimeException)7 HashMap (java.util.HashMap)4 ForestRequest (com.dtflys.forest.http.ForestRequest)3 ForestLogHandler (com.dtflys.forest.logging.ForestLogHandler)3 LogConfiguration (com.dtflys.forest.logging.LogConfiguration)3 SuccessWhen (com.dtflys.forest.callback.SuccessWhen)2 ForestConverter (com.dtflys.forest.converter.ForestConverter)2 MetaRequest (com.dtflys.forest.reflection.MetaRequest)2 RequestNameValue (com.dtflys.forest.utils.RequestNameValue)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 BindingVar (com.dtflys.forest.annotation.BindingVar)1 HttpBackend (com.dtflys.forest.backend.HttpBackend)1 HttpBackendSelector (com.dtflys.forest.backend.HttpBackendSelector)1 DefaultAutoConverter (com.dtflys.forest.converter.auto.DefaultAutoConverter)1 ForestFastjsonConverter (com.dtflys.forest.converter.json.ForestFastjsonConverter)1 ForestGsonConverter (com.dtflys.forest.converter.json.ForestGsonConverter)1