use of com.unboundid.util.MemoryBasedLogHandler in project ldapsdk by pingidentity.
the class AccessLogRequestHandlerTestCase method createListener.
/**
* Creates a new listener that will write log messages to an in-memory buffer.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void createListener() throws Exception {
logHandler = new MemoryBasedLogHandler();
logHandler.setFormatter(new MinimalLogFormatter());
logHandler.setLevel(Level.INFO);
final CannedResponseRequestHandler successHandler = new CannedResponseRequestHandler();
final LDAPListenerConfig successConfig = new LDAPListenerConfig(0, new AccessLogRequestHandler(logHandler, successHandler));
successListener = new LDAPListener(successConfig);
successListener.startListening();
successPort = successListener.getListenPort();
assertTrue(successPort > 0);
final CannedResponseRequestHandler failureHandler = new CannedResponseRequestHandler(ResultCode.NO_SUCH_OBJECT, "dc=example,dc=com", "The target entry was not found", Arrays.asList("ldap://server1.example.com/dc=example,dc=com", "ldap://server2.example.com/dc=example,dc=com"));
final LDAPListenerConfig failureConfig = new LDAPListenerConfig(0, new AccessLogRequestHandler(logHandler, failureHandler));
failureListener = new LDAPListener(failureConfig);
failureListener.startListening();
failurePort = failureListener.getListenPort();
assertTrue(failurePort > 0);
}
Aggregations