@Test
public void testRetrieveBinaryAttibute() throws Exception
{
// test with a local connection using a local BinaryAttributeDetector
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( "localhost" );
config.setLdapPort( ldapServer.getPort() );
config.setName( ServerDNConstants.ADMIN_SYSTEM_DN );
config.setCredentials( "secret" );
config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
LdapConnection myConnection = new LdapNetworkConnection( config );
// Remove the UserPassword from the list
( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
removeBinaryAttribute( "userPassword" );
myConnection.bind( "uid=admin,ou=system", "secret" );
Entry entry = myConnection.lookup( "uid=admin,ou=system" );
assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
// Now, load a new binary Attribute
( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
addBinaryAttribute( "userPassword" );
entry = myConnection.lookup( "uid=admin,ou=system" );
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
// Now, test using the scerver's schema