attributes.remove( "krb5Key" ); attributes.put( "krb5Key", "testing a string" );
attributes.remove( "jpegPhoto" ); attributes.put( "jpegPhoto", "testing a string" );
    public void testBinaryExtension() throws NamingException    {        Attributes attributes = new BasicAttributes();        attributes.put( "objectClass", "top" );        attributes.put( "objectClass", "organizationalUnit" );        attributes.put( "objectClass", "extensibleObject" );        attributes.put( "ou", "testing" );        sysRoot.createSubcontext( "ou=test", attributes );        // test without turning on the property        DirContext ctx = ( DirContext ) sysRoot.lookup( "ou=test" ) ;        Attribute ou = ctx.getAttributes( "" ).get( "ou" );        Object value = ou.get();        assertTrue( value instanceof String );        // test with the property now making ou into a binary value        sysRoot.addToEnvironment( BINARY_KEY, "ou" );        ctx = ( DirContext ) sysRoot.lookup( "ou=test" ) ;        ou = ctx.getAttributes( "" ).get( "ou" );        value = ou.get();        assertTrue( value instanceof byte[] );        // try krb5Key which should be binary automatically - use ou as control        byte[] keyValue = new byte[] { 0x45, 0x23, 0x7d, 0x7f };        attributes.put( "krb5Key", keyValue );        sysRoot.createSubcontext( "ou=anothertest", attributes );        ctx = ( DirContext ) sysRoot.lookup( "ou=anothertest" ) ;        ou = ctx.getAttributes( "" ).get( "ou" );        value = ou.get();        assertTrue( value instanceof byte[] );        Attribute krb5Key = ctx.getAttributes( "" ).get( "krb5Key" );        value = krb5Key.get();        assertTrue( value instanceof byte[] );        // try krb5Key which should be binary automatically but use String to        // create so we should still get back a byte[] - use ou as control        attributes.remove( "krb5Key" );        attributes.put( "krb5Key", "testing a string" );        sysRoot.createSubcontext( "ou=yetanothertest", attributes );        ctx = ( DirContext ) sysRoot.lookup( "ou=yetanothertest" ) ;        ou = ctx.getAttributes( "" ).get( "ou" );        value = ou.get();        assertTrue( value instanceof byte[] );        krb5Key = ctx.getAttributes( "" ).get( "krb5Key" );        value = krb5Key.get();        assertTrue( value instanceof byte[] );    }