Package org.apache.directory.api.ldap.model.entry

Examples of org.apache.directory.api.ldap.model.entry.BinaryValue


    @Test
    public void testIsValid() throws LdapInvalidAttributeValueException
    {
        AttributeType attribute = EntryUtils.getBytesAttributeType();

        new BinaryValue( attribute, null );
        new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
        new BinaryValue( attribute, new byte[]
            { 0x01, 0x02 } );

        try
        {
            new BinaryValue( attribute, new byte[]
                { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 } );
            fail();
        }
        catch ( LdapInvalidAttributeValueException liave )
        {
View Full Code Here


     */
    @Test
    public void testHashCode() throws LdapInvalidAttributeValueException
    {
        AttributeType attribute = EntryUtils.getBytesAttributeType();
        BinaryValue v0 = new BinaryValue( attribute, new byte[]
            { 0x01, 0x02 } );
        BinaryValue v1 = new BinaryValue( attribute, new byte[]
            { ( byte ) 0x81, ( byte ) 0x82 } );
        BinaryValue v2 = new BinaryValue( attribute, new byte[]
            { 0x01, 0x02 } );
        assertEquals( v0.hashCode(), v1.hashCode() );
        assertEquals( v1.hashCode(), v2.hashCode() );
        assertEquals( v0.hashCode(), v2.hashCode() );
        assertEquals( v0, v1 );
        assertEquals( v0, v2 );
        assertEquals( v1, v2 );

        BinaryValue v3 = new BinaryValue( attribute, new byte[]
            { 0x01, 0x03 } );
        assertFalse( v3.equals( v0 ) );
        assertFalse( v3.equals( v1 ) );
        assertFalse( v3.equals( v2 ) );
    }
View Full Code Here

     */
    @Test
    public void testInstanceOf() throws LdapException
    {
        AttributeType attribute = EntryUtils.getBytesAttributeType();
        BinaryValue sbv = new BinaryValue( attribute );

        assertTrue( sbv.isInstanceOf( attribute ) );

        attribute = EntryUtils.getIA5StringAttributeType();

        assertFalse( sbv.isInstanceOf( attribute ) );
    }
View Full Code Here

     */
    @Test
    public void testNormalize() throws LdapException
    {
        AttributeType attribute = EntryUtils.getBytesAttributeType();
        BinaryValue bv = new BinaryValue( attribute );

        bv.apply( at );
        assertEquals( null, bv.getNormValue() );

        bv = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
        bv.apply( at );
        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );

        bv = new BinaryValue( attribute, BYTES2 );
        bv.apply( at );
        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
    }
View Full Code Here

     */
    @Test
    public void testCompareTo() throws LdapInvalidAttributeValueException
    {
        AttributeType at1 = EntryUtils.getBytesAttributeType();
        BinaryValue v0 = new BinaryValue( at1, BYTES1 );
        BinaryValue v1 = new BinaryValue( at1, BYTES2 );

        assertEquals( 0, v0.compareTo( v1 ) );
        assertEquals( 0, v1.compareTo( v0 ) );

        BinaryValue v2 = new BinaryValue( at1, null );

        assertEquals( 1, v0.compareTo( v2 ) );
        assertEquals( -1, v2.compareTo( v0 ) );
    }
View Full Code Here

    {
        byte[] v1 = Strings.getBytesUtf8( "  Test   Test  " );
        byte[] v1Norm = Strings.getBytesUtf8( "Test   Test" );

        // First check with a value which will be normalized
        BinaryValue sbv = new BinaryValue( at, v1 );

        sbv.apply( at );
        byte[] normalized = sbv.getNormReference();

        assertTrue( Arrays.equals( v1Norm, normalized ) );
        assertTrue( Arrays.equals( v1, sbv.getReference() ) );

        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );

        assertEquals( sbv, sbvSer );
    }
View Full Code Here

    public void testNormalizedBinarySameValueSerialization() throws LdapException, IOException, ClassNotFoundException
    {
        byte[] v1 = Strings.getBytesUtf8( "Test   Test" );

        // First check with a value which will be normalized
        BinaryValue sbv = new BinaryValue( at, v1 );

        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );

        assertEquals( sbv, sbvSer );
    }
View Full Code Here

    {
        byte[] v1 = Strings.getBytesUtf8( "test" );
        byte[] v1Norm = Strings.getBytesUtf8( "test" );

        // First check with a value which will be normalized
        BinaryValue sbv = new BinaryValue( at, v1 );

        sbv.apply( at );
        byte[] normalized = sbv.getNormReference();

        assertTrue( Arrays.equals( v1Norm, normalized ) );
        assertTrue( Arrays.equals( v1, sbv.getBytes() ) );

        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );

        assertEquals( sbv, sbvSer );
    }
View Full Code Here

     */
    @Test
    public void testNullBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException
    {
        // First check with a value which will be normalized
        BinaryValue sbv = new BinaryValue( at );

        sbv.apply( at );
        byte[] normalized = sbv.getNormReference();

        assertEquals( null, normalized );
        assertEquals( null, sbv.getValue() );

        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );

        assertEquals( sbv, sbvSer );
    }
View Full Code Here

     */
    @Test
    public void testEmptyBinaryValueSerialization() throws LdapException, IOException, ClassNotFoundException
    {
        // First check with a value which will be normalized
        BinaryValue sbv = new BinaryValue( at, StringConstants.EMPTY_BYTES );

        sbv.apply( at );
        byte[] normalized = sbv.getNormReference();

        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, normalized ) );
        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, sbv.getBytes() ) );

        BinaryValue sbvSer = deserializeValue( serializeValue( sbv ), at );

        assertEquals( sbv, sbvSer );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.entry.BinaryValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.