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

Examples of org.apache.directory.shared.ldap.entry.DefaultServerAttribute


        ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );

        assertNull( entry.get( atCN ) );
        assertNull( entry.get( (AttributeType)null ) );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute attrSN = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
       
        entry.add( attrOC, attrCN, attrSN, attrPWD );
       
        assertNotNull( entry.get( atCN ) );
       
View Full Code Here


        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );

        assertNull( entry.get( "cn" ) );
        assertNull( entry.get( "badId" ) );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute attrSN = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
       
        entry.add( attrOC, attrCN, attrSN, attrPWD );
       
        assertNotNull( entry.get( "CN" ) );
        assertNotNull( entry.get( " commonName " ) );
View Full Code Here

       
        entry2.setDn( EXAMPLE_DN );
        assertEquals( entry1.hashCode(), entry2.hashCode() );
       
       
        EntryAttribute attrOC = new DefaultServerAttribute( "objectClass", atOC, "top", "person" );
        EntryAttribute attrCN = new DefaultServerAttribute( "cn", atCN, "test1", "test2" );
        EntryAttribute attrSN = new DefaultServerAttribute( "sn", atSN, "Test1", "Test2" );
        EntryAttribute attrPWD = new DefaultServerAttribute( "userPassword", atPwd, BYTES1, BYTES2 );

        entry1.add( attrOC, attrCN, attrSN, attrPWD );
        entry2.add( attrOC, attrCN, attrSN, attrPWD );

        assertEquals( entry1.hashCode(), entry2.hashCode() );
View Full Code Here

    @Test
    public void testHasObjectClassEntryAttribute() throws Exception
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
       
        assertFalse( entry.contains( attrOC ) );
        assertFalse( entry.hasObjectClass( attrOC ) );
       
        entry.add( attrOC );
       
        assertTrue( entry.hasObjectClass( attrOC ) );

        EntryAttribute attrOC2 = new DefaultServerAttribute( atOC, "person" );
        assertTrue( entry.hasObjectClass( attrOC2 ) );

        EntryAttribute attrOC3 = new DefaultServerAttribute( atOC, "inetOrgPerson" );
        assertFalse( entry.hasObjectClass( attrOC3 ) );
        assertFalse( entry.hasObjectClass( (EntryAttribute)null ) );

        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "top" );
        assertFalse( entry.hasObjectClass( attrCN ) );
    }
View Full Code Here

        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.containsAttribute( "objectClass" ) );
        assertFalse( entry.hasObjectClass( "top" ) );
       
        entry.add( new DefaultServerAttribute( atOC, "top", "person" ) );
       
        assertTrue( entry.hasObjectClass( "top" ) );
        assertTrue( entry.hasObjectClass( "person" ) );
        assertFalse( entry.hasObjectClass( "inetorgperson" ) );
        assertFalse( entry.hasObjectClass( null ) );
View Full Code Here

    @Test
    public void testIterator() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrOC = new DefaultServerAttribute( atOC, "top", "person" );
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute attrSN = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
       
        entry.put( attrOC, attrCN, attrSN, attrPWD );
       
        Iterator<EntryAttribute> iterator = entry.iterator();
       
View Full Code Here

    @Test
    public void testPutEntryAttribute() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute oc = new DefaultServerAttribute( atObjectClass, "top", "person" );
        EntryAttribute cn = new DefaultServerAttribute( atCN, "test1", "test2" );
        EntryAttribute sn = new DefaultServerAttribute( atSN, "Test1", "Test2" );
        EntryAttribute up = new DefaultServerAttribute( atPwd, BYTES1, BYTES2 );
        EntryAttribute c = new DefaultServerAttribute( atC, "FR", "US" );
       
        List<EntryAttribute> removed = entry.put( oc, cn, sn, c );
       
        assertEquals( 4, entry.size() );
        assertEquals( 0, removed.size() );
        assertTrue( entry.containsAttribute( "ObjectClass" ) );
        assertTrue( entry.containsAttribute( "CN" ) );
        assertTrue( entry.containsAttribute( "  sn  " ) );
        assertTrue( entry.containsAttribute( " countryName  " ) );
   
        EntryAttribute attr = entry.get( "objectclass" );
        assertEquals( 2, attr.size() );
       
        EntryAttribute c2 = new DefaultServerAttribute( atC, "UK", "DE" );
        removed = entry.put( c2, up );
        assertEquals( 1, removed.size() );
        assertEquals( c, removed.get( 0 ) );
        assertTrue( removed.get( 0 ).contains( "FR" ) );
        assertTrue( removed.get( 0 ).contains( "US" ) );
       
        assertEquals( 5, entry.size() );
       
        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertTrue( entry.containsAttribute( " countryName " ) );

        EntryAttribute attrC = entry.get( "countryName" );
        assertEquals( 2, attrC.size() );
        assertTrue( attrC.contains( "UK", "DE" ) );

        c2.clear();
        entry.put( c2 );
        assertEquals( 5, entry.size() );
        attrC = entry.get( "countryName" );
        assertEquals( 0, attrC.size() );
    }
View Full Code Here

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

        EntryAttribute sa = new DefaultServerAttribute( atL, "france" );
        entry.put( sa );
       
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "l" ) );
        assertEquals( "france", entry.get( "l" ).get().getString() );
       
        EntryAttribute sb = new DefaultServerAttribute( atC, "countryTest" );
        EntryAttribute sc = new DefaultServerAttribute( atGN, "test" );
        EntryAttribute 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 );
        EntryAttribute 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 testRemoveAttributeTypeByteArrayArray() throws Exception
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, (byte[])null, BYTES2 );

        entry.put( attrPWD );
        assertTrue( entry.remove( atPwd, (byte[])null ) );
        assertTrue( entry.remove( atPwd, BYTES1, BYTES2 ) );
        assertFalse( entry.containsAttribute( atPwd ) );
View Full Code Here

    @Test
    public void testRemoveAttributeTypeStringArray() throws Exception
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", (String)null, "test2" );

        entry.put( attrCN );
        assertTrue( entry.remove( atCN, (String)null ) );
        assertTrue( entry.remove( atCN, "test1", "test2" ) );
        assertFalse( entry.containsAttribute( atCN ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.DefaultServerAttribute

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.