use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestPostClient method testPostJsonMapWithoutLog.
@Test
public void testPostJsonMapWithoutLog() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
Map<String, Object> userMap = new HashMap<>();
userMap.put("username", "foo");
assertThat(postClient.postJsonMapWithoutLog(userMap)).isNotNull().isEqualTo(EXPECTED);
Mockito.verify(logger, Mockito.never()).info("[Forest] Request (" + configuration.getBackend().getName() + "): \n" + "\tPOST http://localhost:" + server.getPort() + "/json HTTP\n" + "\tHeaders: \n" + "\t\tContent-Type: application/json\n" + "\tBody: {\"username\":\"foo\"}");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestPostClient method testPostJsonObjectWithoutLog.
@Test
public void testPostJsonObjectWithoutLog() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
assertThat(postClient.postJsonObjectWithoutLog(user)).isNotNull().isEqualTo(EXPECTED);
Mockito.verify(logger, Mockito.never()).info("[Forest] Request (" + configuration.getBackend().getName() + "): \n" + "\tPOST http://localhost:" + server.getPort() + "/json HTTP\n" + "\tHeaders: \n" + "\t\tContent-Type: application/json\n" + "\tBody: {\"username\":\"foo\"}");
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestPostClient method testPostJsonObjectWithLog_content_noStatus.
@Test
public void testPostJsonObjectWithLog_content_noStatus() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
assertThat(postClient.postJsonObjectWithLog_content_noStatus(user)).isNotNull().isEqualTo(EXPECTED);
Mockito.verify(logger).info("[Forest] Request (" + configuration.getBackend().getName() + "): \n" + "\tPOST http://localhost:" + server.getPort() + "/json HTTP\n" + "\tHeaders: \n" + "\t\tAccept-Encoding: UTF-8\n" + "\t\tContent-Type: application/json\n" + "\tBody: {\"username\":\"foo\"}");
Mockito.verify(logger).info("[Forest] Response Content:\n\t" + EXPECTED);
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestPostClient method testPostJsonObjectWithLog_content_noStatus2.
@Test
public void testPostJsonObjectWithLog_content_noStatus2() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogHandler logHandler = configuration.getLogHandler();
ForestLogger logger = Mockito.mock(ForestLogger.class);
logHandler.setLogger(logger);
JsonTestUser2 user = new JsonTestUser2();
user.setUsername("foo");
assertThat(postClient.postJsonObjectWithLog_content_noStatus(user)).isNotNull().isEqualTo(EXPECTED);
Mockito.verify(logger).info("[Forest] Response Content:\n\t" + EXPECTED);
}
use of com.dtflys.forest.logging.ForestLogger in project forest by dromara.
the class TestPostClient method testSimplePostWithProxy.
@Test
public void testSimplePostWithProxy() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
assertThat(postClient.simplePostWithProxy(server.getPort(), "text/plain", "xxxyyy")).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertRequestLineEquals("POST http://localhost:" + server.getPort() + "/hello HTTP/1.1").assertPathEquals("/").assertHeaderEquals("Accept", "text/plain").assertBodyEquals("username=foo&password=123456");
Mockito.verify(logger).info("[Forest] Request (" + configuration.getBackendName() + "): \n" + "\t[Proxy]: host: 127.0.0.1, port: " + server.getPort() + "\n" + "\tPOST http://localhost:" + server.getPort() + "/hello HTTP\n" + "\tHeaders: \n" + "\t\tAccept: text/plain\n" + "\t\tContent-Type: application/json\n" + "\tBody: username=foo&password=123456");
}
Aggregations