use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class SSLTest method testConfiguration.
@Test
public void testConfiguration() {
ForestLogger logger = Mockito.mock(ForestLogger.class);
assertEquals(Integer.valueOf(300), sslConfig.getMaxConnections());
assertEquals(Integer.valueOf(300), sslConfig.getMaxRouteConnections());
assertEquals(Integer.valueOf(3000), sslConfig.getTimeout());
assertEquals(Integer.valueOf(3000), sslConfig.getConnectTimeout());
assertEquals(Integer.valueOf(2), sslConfig.getMaxRetryCount());
assertEquals(1, sslConfig.getSslKeyStores().size());
SSLKeyStore sslKeyStore = sslConfig.getKeyStore("keystore1");
assertThat(sslKeyStore).isNotNull();
// assertEquals("keystore1", sslKeyStore.getId());
// assertEquals("test.keystore", sslKeyStore.getFilePath());
// assertEquals("123456", sslKeyStore.getKeystorePass());
// assertEquals("123456", sslKeyStore.getCertPass());
// assertEquals(1, sslKeyStore.getProtocols().length);
// assertEquals("SSLv3", sslKeyStore.getProtocols()[0]);
assertThat(sslKeyStore.getSslSocketFactoryBuilder()).isNotNull().isInstanceOf(MySSLSocketFactoryBuilder.class);
ForestRequest<String> request = giteeClient.index2();
assertThat(request).isNotNull();
request.getLogConfiguration().getLogHandler().setLogger(logger);
String result = (String) request.execute();
assertThat(result.startsWith("Global: ")).isTrue();
Mockito.verify(logger).info("[Forest] [Test2] 请求: \n" + "\tGET https://gitee.com/dt_flys HTTPS");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class Test0 method testRetry.
@Test
public void testRetry() {
ForestLogger logger = Mockito.mock(ForestLogger.class);
config0.getLogHandler().setLogger(logger);
try {
beastshopClient.testRetry();
} catch (ForestRuntimeException e) {
}
HttpBackend backend = config0.getBackend();
String backendName = backend.getName();
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" + "\t[Retry]: 1\n" + "\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" + "\t[Retry]: 2\n" + "\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" + "\t[Retry]: 3\n" + "\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" + "\t[Retry]: 4\n" + "\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
Mockito.verify(logger).info("[Forest] Request (" + backendName + "): \n" + "\t[Retry]: 5\n" + "\tGET https://www.thebeastshop.com/autopage/shops.htm HTTPS");
// Mockito.verify(logger).info("[Forest] [Network Error]: connect timed out");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class Test2 method testClient1.
@Test
public void testClient1() {
ForestLogger logger = Mockito.mock(ForestLogger.class);
ForestRequest<String> request = giteeClient.index();
assertThat(request).isNotNull();
request.getLogConfiguration().getLogHandler().setLogger(logger);
String result = (String) request.execute();
assertThat(result.startsWith("Global: ")).isTrue();
Mockito.verify(logger).info("[Forest] [Test1] 请求: \n" + "\tGET https://gitee.com/dt_flys/forest HTTPS");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class Test2 method testClient2.
@Test
public void testClient2() {
ForestLogger logger = Mockito.mock(ForestLogger.class);
ForestRequest<String> request = giteeClient.index2();
assertThat(request).isNotNull();
request.getLogConfiguration().getLogHandler().setLogger(logger);
String result = (String) request.execute();
assertThat(result.startsWith("Global: ")).isTrue();
Mockito.verify(logger).info("[Forest] [Test2] 请求: \n" + "\tGET https://gitee.com/dt_flys HTTPS");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestInterceptor method testSimpleInterceptor.
@Test
public void testSimpleInterceptor() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
assertThat(interceptorClient.simple()).isNotNull().isEqualTo("XX: " + EXPECTED);
Mockito.verify(logger).info("[Forest] Request (" + configuration.getBackend().getName() + "): \n" + "\t[Type Change]: POST -> GET\n" + "\tGET http://localhost:" + server.getPort() + "/hello/user?username=foo&username=foo HTTP\n" + "\tHeaders: \n" + "\t\tAccept: text/plain");
}
Aggregations