use of com.ingenico.connect.gateway.sdk.java.domain.services.TestConnection in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testLogRequestOnly.
@Test
public void testLogRequestOnly() throws Exception {
// logging is disabled after the request is logged but before the response is logged
serverBootstrap.registerHandler("/v1/1234/services/testconnection", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
client.enableLogging(logger);
setupRequestHandler(disableLogging(setOKJsonResponse("testConnection.json"), client));
try {
TestConnection response = client.merchant("1234").services().testconnection();
Assert.assertNotNull(response);
Assert.assertEquals("OK", response.getResult());
} finally {
client.close();
}
Assert.assertEquals(1, logger.entries.size());
TestLoggerEntry requestEntry = logger.entries.get(0);
Assert.assertNotNull(requestEntry.message);
Assert.assertNull(requestEntry.thrown);
assertRequest(requestEntry.message, "testConnection");
}
use of com.ingenico.connect.gateway.sdk.java.domain.services.TestConnection in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testLogResponseOnly.
@Test
public void testLogResponseOnly() throws Exception {
// logging is enabled after the request is logged but before the response is logged
serverBootstrap.registerHandler("/v1/1234/services/testconnection", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
setupRequestHandler(enableLogging(setOKJsonResponse("testConnection.json"), client, logger));
try {
TestConnection response = client.merchant("1234").services().testconnection();
Assert.assertNotNull(response);
Assert.assertEquals("OK", response.getResult());
} finally {
client.close();
}
Assert.assertEquals(1, logger.entries.size());
TestLoggerEntry responseEntry = logger.entries.get(0);
Assert.assertNotNull(responseEntry.message);
Assert.assertNull(responseEntry.thrown);
assertResponse(responseEntry.message, "testConnection");
}
use of com.ingenico.connect.gateway.sdk.java.domain.services.TestConnection in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method testLoggingTestConnection.
@Test
public void testLoggingTestConnection() throws Exception {
// GET with no query params
serverBootstrap.registerHandler("/v1/1234/services/testconnection", requestHandler);
HttpHost host = start();
Client client = createClient(host);
TestLogger logger = new TestLogger();
client.enableLogging(logger);
setupRequestHandler(setOKJsonResponse("testConnection.json"));
try {
TestConnection response = client.merchant("1234").services().testconnection();
Assert.assertNotNull(response);
Assert.assertEquals("OK", response.getResult());
} finally {
client.close();
}
Assert.assertEquals(2, logger.entries.size());
TestLoggerEntry requestEntry = logger.entries.get(0);
Assert.assertNotNull(requestEntry.message);
Assert.assertNull(requestEntry.thrown);
TestLoggerEntry responseEntry = logger.entries.get(1);
Assert.assertNotNull(responseEntry.message);
Assert.assertNull(responseEntry.thrown);
assertRequestAndResponse(requestEntry.message, responseEntry.message, "testConnection");
}
Aggregations