use of com.dtflys.forest.backend.HttpBackendSelector in project forest by dromara.
the class TestForestConfiguration method testBackend.
@Test
public void testBackend() {
ForestConfiguration configuration = ForestConfiguration.createConfiguration();
configuration.setBackendName("okhttp3");
assertEquals("okhttp3", configuration.getBackend().getName());
configuration.setBackend(null);
configuration.setBackendName("httpclient");
assertEquals("httpclient", configuration.getBackend().getName());
HttpBackendSelector originSelector = new HttpBackendSelector();
HttpBackendSelector selector = Mockito.spy(originSelector);
configuration.setHttpBackendSelector(selector);
Mockito.when(selector.findOkHttp3BackendInstance()).thenReturn(null);
configuration.setBackendName(null);
configuration.setBackend(null);
Assert.assertEquals("httpclient", configuration.getBackend().getName());
Mockito.when(selector.findHttpclientBackendInstance()).thenReturn(null);
configuration.setBackendName(null);
configuration.setBackend(null);
boolean thrown = false;
try {
HttpBackend backend = configuration.getBackend();
System.out.print(backend);
} catch (ForestRuntimeException e) {
thrown = true;
}
assertTrue(thrown);
}
Aggregations