Package org.apache.directory.shared.ldap.schema

Examples of org.apache.directory.shared.ldap.schema.AttributeType


    @Test public void testAddUpIdBytesElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] test1 = StringTools.getBytesUtf8( "test1" );
        byte[] test2 = StringTools.getBytesUtf8( "test2" );
        byte[] test3 = StringTools.getBytesUtf8( "test3" );
       
View Full Code Here


    @Test public void testAddUpIdServerValueElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] b1 = StringTools.getBytesUtf8( "test1" );
        byte[] b2 = StringTools.getBytesUtf8( "test2" );
        byte[] b3 = StringTools.getBytesUtf8( "test3" );
View Full Code Here

    @Test public void testAddUpIdAtBytesElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] test1 = StringTools.getBytesUtf8( "test1" );
        byte[] test2 = StringTools.getBytesUtf8( "test2" );
        byte[] test3 = StringTools.getBytesUtf8( "test3" );
       
View Full Code Here

    @Test public void testAddUpIdAtServerValueElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] b1 = StringTools.getBytesUtf8( "test1" );
        byte[] b2 = StringTools.getBytesUtf8( "test2" );
        byte[] b3 = StringTools.getBytesUtf8( "test3" );
View Full Code Here

       
        while ( iterator.hasNext() )
        {
            EntryAttribute attribute = iterator.next();
           
            AttributeType attributeType = ((ServerAttribute)attribute).getAttributeType();
            assertTrue( expectedIds.contains( attributeType ) );
            expectedIds.remove( attributeType );
        }
       
        assertEquals( 0, expectedIds.size() );
View Full Code Here

            assertTrue( true );
        }
       
        // Adding some serverAttributes
        //AttributeType atCo = registries.lookupAttributeTypeRegistry( "countryName" );
        AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
        AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );

        ServerAttribute sa = new DefaultServerAttribute( atL, "france" );
        entry.put( sa );
       
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "l" ) );
        assertEquals( "france", entry.get( "l" ).get().getString() );
       
        ServerAttribute sb = new DefaultServerAttribute( atC, "countryTest" );
        ServerAttribute sc = new DefaultServerAttribute( atGN, "test" );
        ServerAttribute sd = new DefaultServerAttribute( atStreet, "testStreet" );
        entry.put( sb, sc, sd );

        assertEquals( 4, entry.size() );
        assertNotNull( entry.get( atC ) );
        assertEquals( "countryTest", entry.get( atC ).get().getString() );
        assertNotNull( entry.get( atGN ) );
        assertEquals( "test", entry.get( atGN ).get().getString() );
        assertNotNull( entry.get( atStreet) );
        assertEquals( "testStreet", entry.get( atStreet ).get().getString() );
       
        // Test a replacement
        EntryAttribute sbb = new DefaultServerAttribute( atC, "countryTestTest" );
        EntryAttribute scc = new DefaultServerAttribute( atGN, "testtest" );
        List<EntryAttribute> result = entry.put( sbb, scc );
       
        assertEquals( 2, result.size() );
        assertEquals( "countryTest", result.get(0).get().getString() );
        assertEquals( "test", result.get(1).get().getString() );
        assertEquals( 4, entry.size() );
        assertNotNull( entry.get( atC ) );
        assertEquals( "countryTestTest", entry.get( atC ).get().getString() );
        assertNotNull( entry.get( atGN ) );
        assertEquals( "testtest", entry.get( atGN ).get().getString() );
        assertNotNull( entry.get( atStreet) );
        assertEquals( "testStreet", entry.get( atStreet ).get().getString() );
       
        // test an ObjectClass replacement
        AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
        ServerAttribute oc = new DefaultServerAttribute( "OBJECTCLASS", OBJECT_CLASS_AT, "person", "inetorgperson" );
        List<EntryAttribute> oldOc = entry.put( oc );
       
        assertNotNull( oldOc );
        assertEquals( 0, oldOc.size() );
View Full Code Here

    @Test public void tesPutUpIdBytesElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        // Adding a null value should be possible
        entry.put( "userPassword", (byte[])null );
        assertEquals( 1, entry.size() );
        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
View Full Code Here

    @Test public void tesPutUpIDAtBytesElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        // Test that we get an error when the ID or AT are null
        try
        {
            entry.put( null, (AttributeType)null, (String)null );
View Full Code Here

    @Test public void testRemoveUpIdElipsis() throws Exception
    {
        DN dn = new DN( "cn=test" );
        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
       
        AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
       
        byte[] b1 = StringTools.getBytesUtf8( "test1" );
        byte[] b2 = StringTools.getBytesUtf8( "test2" );

        Value<String> test1 = new ServerStringValue( atCN, "test1" );
        Value<String> test2 = new ServerStringValue( atCN, "test2" );
       
        Value<byte[]> testB1 = new ServerBinaryValue( atPassword, b1 );
        Value<byte[]> testB2 = new ServerBinaryValue( atPassword, b2 );
       
        // test a removal of an non existing attribute
        List<EntryAttribute> removed = entry.removeAttributes( atCN );
        assertNull( removed );
       
        // Test a simple removal
        entry.add( "cN", atCN, test1 );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( atCN ) );
        entry.removeAttributes( "CN" );
        assertEquals( 0, entry.size() );
        assertNull( entry.get( atCN ) );
       
        // Test a removal of many elements
        entry.put( "CN", test1, test2 );
        entry.put( "userPassword", testB1, testB2 );
        assertEquals( 2, entry.size() );
        assertNotNull( entry.get( atCN ) );
        assertNotNull( entry.get( atPassword ) );
       
        AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
       
        entry.removeAttributes( "cN", "UsErPaSsWoRd" );
        assertEquals( 0, entry.size() );
        assertNull( entry.get( atCN ) );
        assertNull( entry.get( atPassword ) );
View Full Code Here

        assertNotNull( sa );
        assertEquals( atSN, ((ServerAttribute)sa).getAttributeType() );
        assertEquals( "sn", ((ServerAttribute)sa).getAttributeType().getName() );
       
        // Add two AT now
        AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
        AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
        result = entry.set( atL, atC, atGN, atStreet );
       
        assertNull( result );

        sa = entry.get( "l" );
        assertNotNull( sa );
        assertEquals( atL, ((ServerAttribute)sa).getAttributeType() );
        assertEquals( "l", ((ServerAttribute)sa).getAttributeType().getName() );

        sa = entry.get( "c" );
        assertNotNull( sa );
        assertEquals( atC, ((ServerAttribute)sa).getAttributeType() );
        assertEquals( "c", ((ServerAttribute)sa).getAttributeType().getName() );

        sa = entry.get( "2.5.4.9" );
        assertNotNull( sa );
        assertEquals( atStreet, ((ServerAttribute)sa).getAttributeType() );
        assertEquals( "street", ((ServerAttribute)sa).getAttributeType().getName() );

        sa = entry.get( "givenName" );
        assertNotNull( sa );
        assertEquals( atGN, ((ServerAttribute)sa).getAttributeType() );
        assertEquals( "givenName", ((ServerAttribute)sa).getAttributeType().getName() );
       
        // Now try to add existing ATs
        // First, set some value to the modified AT
        sa = entry.get( "sn" );
        sa.add( "test" );
       
        // Check that the value has been added to the entry
        assertEquals( "test", entry.get( "sn" ).get().getString() );
       
        // Now add a new SN empty AT : it should replace the existing one.
        AttributeType atSNEmpty = schemaManager.lookupAttributeTypeRegistry( "sn" );
        sa = entry.set( atSNEmpty ).get( 0 );
        assertEquals( "test", sa.get().getString() );
        assertNotNull( entry.get"sn" ) );
        assertNull( entry.get"sn" ).get() );
       
        // Last, not least, put an ObjectClass AT
        AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
       
        entry.set( OBJECT_CLASS_AT );
       
        assertNotNull( entry.get( "objectClass" ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.schema.AttributeType

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.