### Question:
LdapClient { public LdapConnection connect(final String host, final int port) throws LdapException { return connect(host, port, Options.defaultOptions()); } private  LdapClient(); static LdapClient getInstance(); static Options defaultOptions(Context context); Map<String, SearchScope> getScope(); LdapConnection connect(final String host, final int port); LdapConnection connect(final String host, final int port, final Options options); String dn(final String template, final Object... attributeValues); String filter(final String template, final Object... assertionValues); static final Option<TransactionId> TRANSACTIONID_OPTION; }### Answer:
@Test public void shouldBindToLdapServer() throws Exception { LdapConnection connection = client.connect(listener.getHostName(), listener.getPort()); BindResult bindResult = connection.bind("uid=bjensen,ou=people,dc=example,dc=com", "password".toCharArray()); assertThat(bindResult.getResultCode()).isEqualTo(ResultCode.SUCCESS); }
@Test(expectedExceptions = AuthenticationException.class) public void shouldFailToBindBecauseOfInvalidCredentials() throws Exception { LdapConnection connection = client.connect(listener.getHostName(), listener.getPort()); connection.bind("uid=bjensen,ou=people,dc=example,dc=com", "wrong-value".toCharArray()); }