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

Examples of org.apache.directory.api.ldap.model.name.Ava


     * test a simple AttributeTypeAndValue : a = b
     */
    @Test
    public void testAvaSimple() throws LdapException
    {
        Ava atav = new Ava( schemaManager, "cn", "b" );
        assertEquals( "cn=b", atav.toString() );
        assertEquals( "2.5.4.3=b", atav.getNormName() );
        assertEquals( "cn=b", atav.getName() );
    }
View Full Code Here


     * test a simple AttributeTypeAndValue : a = b
     */
    @Test
    public void testAvaSimpleNorm() throws LdapException
    {
        Ava atav = new Ava( schemaManager, " CommonName ", " This is    a TEST " );
        assertEquals( " CommonName =\\ This is    a TEST\\ ", atav.toString() );
        assertEquals( "2.5.4.3=this is a test", atav.getNormName() );
        assertEquals( " CommonName =\\ This is    a TEST\\ ", atav.getName() );
    }
View Full Code Here

     * Compares two equals atavs
     */
    @Test
    public void testEqualsSameAva() throws LdapException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "b" );
        Ava atav2 = new Ava( schemaManager, "cn", "b" );

        assertTrue( atav1.equals( atav2 ) );
    }
View Full Code Here

     * Compares two equals atavs but with a type in different case
     */
    @Test
    public void testEqualsUpperCaseAT() throws LdapException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "b" );
        Ava atav2 = new Ava( schemaManager, "CN", "b" );

        assertTrue( atav1.equals( atav2 ) );
    }
View Full Code Here

     * Compares two equals atavs but with a type in different case
     */
    @Test
    public void testEqualsSameValues() throws LdapException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "  B  a" );
        Ava atav2 = new Ava( schemaManager, "CN", "b a" );

        assertTrue( atav1.equals( atav2 ) );
    }
View Full Code Here

    @Test
    public void testAvaValuesNoSchema() throws LdapException
    {
        String errors = null;
       
        Ava ava = new Ava( "OU", "Exemple + Rdn\u00E4 " );
       
        if ( !"ou=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.getNormName() ) )
        {
            errors = "\nAva.getNormName fails '" + ava.getNormName() + "'";
        }
       
        if ( !"ou".equals( ava.getNormType() ) )
        {
            errors += "\nAva.getNormType fails '" + ava.getNormType() + "'";
        }
       
        if ( !"Exemple + Rdn\u00E4 ".equals( ava.getNormValue().getString() ) )
        {
            errors += "\nAva.getNormValue fails '" + ava.getNormValue().getString() + "'";
        }
       
        if ( !"OU=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.getName() ) )
        {
            errors += "\nAva.getUpName fails '" + ava.getName() + "'";
        }
       
        if ( !"OU".equals( ava.getType() ) )
        {
            errors += "\nAva.getUpType fails '" + ava.getType() + "'";
        }
       
        if ( !"Exemple + Rdn\u00E4 ".equals( ava.getValue().getString() ) )
        {
            errors += "\nAva.getUpValue fails '" + ava.getValue() .getString() + "'";
        }
       
        if ( !"ou=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.normalize() ) )
        {
            errors += "\nAva.normalize fails '" + ava.normalize() + "'";
        }
       
        if ( !"OU=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.toString() ) )
        {
            errors += "\nAva.toString fails '" + ava.toString() + "'";
        }
       
        assertEquals( null, errors );
    }
View Full Code Here

    @Test
    public void testAvaValuesSchemaAware() throws LdapException
    {
        String errors = null;
       
        Ava ava = new Ava( schemaManager, "OU", "Exemple + Rdn\u00E4 " );
       
        if ( !"2.5.4.11=exemple \\+ rdn\\C3\\A4".equals( ava.getNormName() ) )
        {
            errors = "\nAva.getNormName fails '" + ava.getNormName() + "'";
        }
       
        if ( !"2.5.4.11".equals( ava.getNormType() ) )
        {
            errors += "\nAva.getNormType fails '" + ava.getNormType() + "'";
        }
       
        if ( !"exemple + rdn\u00E4".equals( ava.getNormValue().getString() ) )
        {
            errors += "\nAva.getNormValue fails '" + ava.getNormValue().getString() + "'";
        }
       
        if ( !"OU=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.getName() ) )
        {
            errors += "\nAva.getUpName fails '" + ava.getName() + "'";
        }
       
        if ( !"OU".equals( ava.getType() ) )
        {
            errors += "\nAva.getUpType fails '" + ava.getType() + "'";
        }
       
        if ( !"Exemple + Rdn\u00E4 ".equals( ava.getValue().getString() ) )
        {
            errors += "\nAva.getUpValue fails '" + ava.getValue().getString() + "'";
        }
       
        if ( !"2.5.4.11=exemple \\+ rdn\\C3\\A4".equals( ava.normalize() ) )
        {
            errors += "\nAva.normalize fails '" + ava.normalize() + "'";
        }
       
        if ( !"OU=Exemple \\+ Rdn\\C3\\A4\\ ".equals( ava.toString() ) )
        {
            errors += "\nAva.toString fails '" + ava.toString() + "'";
        }
       
        assertEquals( null, errors );
    }
View Full Code Here

   
   
    @Test
    public void testCompareToSameAva() throws LdapInvalidDnException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "b" );
        Ava atav2 = new Ava( schemaManager, "cn", "b" );
        Ava atav3 = new Ava( schemaManager, "commonName", "b" );
        Ava atav4 = new Ava( schemaManager, "2.5.4.3", "  B  " );

        // 1 with others
        assertEquals( 0, atav1.compareTo( atav1 ) );
        assertEquals( 0, atav1.compareTo( atav2 ) );
        assertEquals( 0, atav1.compareTo( atav3 ) );
        assertEquals( 0, atav1.compareTo( atav4 ) );
       
        // 2 with others
        assertEquals( 0, atav2.compareTo( atav1 ) );
        assertEquals( 0, atav2.compareTo( atav2 ) );
        assertEquals( 0, atav2.compareTo( atav3 ) );
        assertEquals( 0, atav2.compareTo( atav4 ) );
       
        // 3 with others
        assertEquals( 0, atav3.compareTo( atav1 ) );
        assertEquals( 0, atav3.compareTo( atav2 ) );
        assertEquals( 0, atav3.compareTo( atav3 ) );
        assertEquals( 0, atav3.compareTo( atav4 ) );
       
        // 4 with others
        assertEquals( 0, atav4.compareTo( atav1 ) );
        assertEquals( 0, atav4.compareTo( atav2 ) );
        assertEquals( 0, atav4.compareTo( atav3 ) );
        assertEquals( 0, atav4.compareTo( atav4 ) );
    }
View Full Code Here

   
   
    @Test
    public void testCompareAvaOrder() throws LdapInvalidDnException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "  B  " );
        Ava atav2 = new Ava( schemaManager, "sn", "  c" );
       
        // atav1 should be before atav2
        assertEquals( -1, atav1.compareTo( atav2 ) );
        assertEquals( 1, atav2.compareTo( atav1 ) );

        Ava atav3 = new Ava( schemaManager, "2.5.4.3", "A " );
       
        // Atav1 shoud be after atav3
        assertEquals( 1, atav1.compareTo( atav3 ) );
        assertEquals( -1, atav3.compareTo( atav1 ) );
    }
View Full Code Here

   
   
    @Test
    public void testSortAva() throws LdapInvalidDnException
    {
        Ava atav1 = new Ava( schemaManager, "cn", "  B  " );
        Ava atav2 = new Ava( schemaManager, "sn", "  c" );
        Ava atav3 = new Ava( schemaManager, "2.5.4.3", "A " );
        Ava atav4 = new Ava( schemaManager, "2.5.4.11", " C  " );
        Ava atav5 = new Ava( schemaManager, "ou", "B " );
        Ava atav6 = new Ava( schemaManager, "ou", "D " );
        Ava atav7 = new Ava( schemaManager, "CN", " " );

        Ava[] avas = new Ava[] { atav1, atav2, atav3, atav4, atav5, atav6, atav7 };
       
        Arrays.sort( avas );
       
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.name.Ava

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.