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

Examples of org.apache.directory.shared.ldap.model.entry.Attribute


        assertTrue( entry.isLdifChange() );
        assertTrue( entry.isChangeAdd() );

        assertEquals( 1, entry.getEntry().size() );

        Attribute attr = entry.get( "attr1" );
        assertTrue( attr.contains( "ATTR1" ) );
    }
View Full Code Here


        assertTrue( entry.isLdifChange() );
        assertTrue( entry.isChangeAdd() );

        assertEquals( 1, entry.getEntry().size() );

        Attribute attr = entry.get( "attr1" );
        assertEquals( 2, attr.size() );
        assertTrue( attr.contains( "ATTR1" ) );
        assertTrue( attr.contains( "ATTR2" ) );
    }
View Full Code Here

        assertTrue( entry.isLdifChange() );
        assertTrue( entry.isChangeAdd() );

        assertEquals( 2, entry.getEntry().size() );

        Attribute attr = entry.get( "attr1" );
        assertEquals( 2, attr.size() );
        assertTrue( attr.contains( "ATTR1" ) );
        assertTrue( attr.contains( "ATTR2" ) );

        Attribute attr2 = entry.get( "attr2" );
        assertEquals( 1, attr2.size() );
        assertTrue( attr2.contains( "ATTR1" ) );
    }
View Full Code Here

     * Test method isValid( SyntaxChecker )
     */
    @Test
    public void testIsValidSyntaxChecker() throws LdapException
    {
        Attribute attr = new DefaultAttribute( "test" );

        attr.add( "test", "another test" );

        assertTrue( attr.isValid( atCN ) );

        attr.add( "test an invalid '\uFFFD' char" );
        assertFalse( attr.isValid( atCN ) );
    }
View Full Code Here

     * Test method getBytes()
     */
    @Test
    public void testGetBytes() throws LdapInvalidAttributeValueException
    {
        Attribute attr1 = new DefaultAttribute( atPwd );

        attr1.add( ( byte[] ) null );
        assertNull( attr1.getBytes() );

        Attribute attr2 = new DefaultAttribute( atPwd );

        attr2.add( BYTES1, BYTES2 );
        assertTrue( Arrays.equals( BYTES1, attr2.getBytes() ) );

        Attribute attr3 = new DefaultAttribute( atCN );

        attr3.add( "a", "b" );

        try
        {
            attr3.getBytes();
            fail();
        }
        catch ( LdapInvalidAttributeValueException ivae )
        {
            assertTrue( true );
View Full Code Here

     * Test method getId()
     */
    @Test
    public void testGetId()
    {
        Attribute attr = new DefaultAttribute( atCN );

        assertEquals( "2.5.4.3", attr.getId() );

        attr.setUpId( "  CN  " );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "  CN  ", attr.getUpId() );

        attr.setUpId( "  CommonName  " );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "  CommonName  ", attr.getUpId() );

        attr.setUpId( "  2.5.4.3  " );
        assertEquals( "2.5.4.3", attr.getId() );
    }
View Full Code Here

     * Test method getString()
     */
    @Test
    public void testGetString() throws LdapInvalidAttributeValueException
    {
        Attribute attr1 = new DefaultAttribute( atDC );

        assertEquals( 1, attr1.add( ( String ) null ) );

        Attribute attr2 = new DefaultAttribute( atDC );

        attr2.add( "a" );
        assertEquals( "a", attr2.getString() );

        Attribute attr3 = new DefaultAttribute( atPwd );

        attr3.add( BYTES1, BYTES2 );

        try
        {
            attr3.getString();
            fail();
        }
        catch ( LdapInvalidAttributeValueException ivae )
        {
            assertTrue( true );
View Full Code Here

     * Test method getUpId
     */
    @Test
    public void testGetUpId()
    {
        Attribute attr = new DefaultAttribute( atCN );

        assertNotNull( attr.getUpId() );
        assertEquals( "cn", attr.getUpId() );

        attr.setUpId( "CN" );
        assertEquals( "CN", attr.getUpId() );

        attr.setUpId( "  Cn  " );
        assertEquals( "  Cn  ", attr.getUpId() );

        attr.setUpId( "  2.5.4.3  " );
        assertEquals( "  2.5.4.3  ", attr.getUpId() );
    }
View Full Code Here

     * Test method hashCode()
     */
    @Test
    public void testHashCode() throws LdapException
    {
        Attribute attr1 = new DefaultAttribute( atDC );
        Attribute attr2 = new DefaultAttribute( atSN );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        attr2.apply( atDC );
        assertEquals( attr1.hashCode(), attr2.hashCode() );

        attr1.add( ( String ) null );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        attr1.clear();
        assertEquals( attr1.hashCode(), attr2.hashCode() );

        attr1.add( "a", "b" );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        attr2.add( "a", "b" );
        assertEquals( attr1.hashCode(), attr2.hashCode() );

        // Order matters
        attr2.clear();
        attr2.add( "b", "a" );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        Attribute attr3 = new DefaultAttribute( atPwd );
        Attribute attr4 = new DefaultAttribute( atPwd );
        assertNotSame( attr3.hashCode(), attr4.hashCode() );

        attr3.add( ( byte[] ) null );
        assertNotSame( attr3.hashCode(), attr4.hashCode() );

        attr3.clear();
        assertEquals( attr3.hashCode(), attr4.hashCode() );

        attr3.add( new byte[]
            { 0x01, 0x02 }, new byte[]
            { 0x03, 0x04 } );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        attr4.add( new byte[]
            { 0x01, 0x02 }, new byte[]
            { 0x03, 0x04 } );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );

        // Order matters
        attr4.clear();
        attr4.add( new byte[]
            { 0x03, 0x04 }, new byte[]
            { 0x01, 0x02 } );
        assertNotSame( attr1.hashCode(), attr2.hashCode() );
    }
View Full Code Here

     * Test method SetId(String)
     */
    @Test
    public void testSetId()
    {
        Attribute attr = new DefaultAttribute( atCN );

        attr.setUpId( "Cn" );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "Cn", attr.getUpId() );

        attr.setUpId( " CN " );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( " CN ", attr.getUpId() );

        attr.setUpId( " 2.5.4.3 " );
        assertEquals( " 2.5.4.3 ", attr.getUpId() );
        assertEquals( "2.5.4.3", attr.getId() );

        attr.setUpId( " commonName " );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( " commonName ", attr.getUpId() );

        attr.setUpId( null );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "cn", attr.getUpId() );

        attr.setUpId( "" );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "cn", attr.getUpId() );

        attr.setUpId( "  " );
        assertEquals( "2.5.4.3", attr.getId() );
        assertEquals( "cn", attr.getUpId() );

        try
        {
            attr.setUpId( " SN " );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.entry.Attribute

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.