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

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


        {
            LOG.debug( "creating the entry for storing replication consumers' details" );
            PROVIDER_LOG
                .debug( "Creating the entry for storing replication consumers' details in {}", REPL_CONSUMER_DN );

            Entry entry = new DefaultEntry( schemaManager, REPL_CONSUMER_DN,
                SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.ORGANIZATIONAL_UNIT_OC,
                SchemaConstants.OU_AT, CONSUMERS );

            adminSession.add( entry );
        }
View Full Code Here


            PROVIDER_LOG.error( message );
            throw new LdapEntryAlreadyExistsException( message );
        }

        // Create the new consumer entry
        Entry entry = new DefaultEntry( schemaManager, consumerDn,
            SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.ADS_REPL_EVENT_LOG,
            SchemaConstants.ADS_DS_REPLICA_ID, String.valueOf( replica.getId() ),
            SchemaConstants.ADS_REPL_ALIAS_DEREF_MODE, replica.getSearchCriteria().getAliasDerefMode().getJndiValue(),
            SchemaConstants.ADS_SEARCH_BASE_DN, replica.getSearchCriteria().getBase().getName(),
            SchemaConstants.ADS_REPL_LAST_SENT_CSN, replica.getLastSentCsn(),
View Full Code Here

     */
    @Test
    public void tesPutAtStringElipsis() throws Exception
    {
        Dn dn = new Dn( schemaManager, "dc=test" );
        DefaultEntry entry = new DefaultEntry( schemaManager, dn );

        // Test an empty AT
        entry.put( atEMail, ( String ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "email", entry.get( atEMail ).getUpId() );
        assertNull( entry.get( atEMail ).get().getValue() );

        // Check that we can't use invalid arguments
        try
        {
            entry.put( ( AttributeType ) null, ( String ) null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        // Add a single value
        entry.put( atEMail, "test" );

        assertEquals( 1, entry.size() );
        assertEquals( "email", entry.get( atEMail ).getUpId() );
        assertEquals( 1, entry.get( atEMail ).size() );
        assertEquals( "test", entry.get( atEMail ).get().getString() );

        // Add more than one value
        entry.put( atEMail, "test1", "test2", "test3" );

        assertEquals( 1, entry.size() );
        assertEquals( "email", entry.get( atEMail ).getUpId() );
        assertEquals( 3, entry.get( atEMail ).size() );
        assertTrue( entry.contains( "email", "test1" ) );
        assertTrue( entry.contains( "email", "test2" ) );
        assertTrue( entry.contains( "email", "test3" ) );

        // Add twice the same value
        Attribute sa = entry.put( atEMail, "test1", "test2", "test1" );

        assertEquals( 3, sa.size() );
        assertTrue( sa.contains( "test1", "test2", "test3" ) );
        assertEquals( 1, entry.size() );
        assertEquals( "email", entry.get( atEMail ).getUpId() );
        assertEquals( 2, entry.get( atEMail ).size() );
        assertTrue( entry.contains( "email", "test1" ) );
        assertTrue( entry.contains( "email", "test2" ) );
    }
View Full Code Here

     */
    @Test
    public void tesPutUpIDAtBytesElipsis() throws Exception
    {
        Dn dn = new Dn( schemaManager, "cn=test" );
        DefaultEntry entry = new DefaultEntry( 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 );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        // Test an empty AT
        entry.put( "userPassword", atPassword, ( byte[] ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertNull( entry.get( atPassword ).get().getValue() );

        // Check that we can use a null AttributeType
        entry.put( "userPassword", ( AttributeType ) null, ( byte[] ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertNull( entry.get( atPassword ).get().getValue() );

        // Test that we can use a null upId
        entry.put( null, atPassword, ( byte[] ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
        assertTrue( entry.containsAttribute( "userPassword" ) );
        assertNull( entry.get( atPassword ).get().getValue() );

        // Test that if we use an upId which is not compatible
        // with the AT, it is changed to the AT default name
        try
        {
            entry.put( "sn", atPassword, ( byte[] ) null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        assertEquals( "2.5.4.35", entry.get( atPassword ).getId() );

        // Test that we can add some new attributes with values
        byte[] test1 = Strings.getBytesUtf8( "test1" );
        byte[] test2 = Strings.getBytesUtf8( "test2" );
        byte[] test3 = Strings.getBytesUtf8( "test3" );

        Attribute result = entry.put( "UserPassword", atPassword, test1, test2, test3 );
        assertNotNull( result );
        assertEquals( "userPassword", result.getUpId() );
        assertEquals( 1, entry.size() );
        assertEquals( "UserPassword", entry.get( atPassword ).getUpId() );
        assertNotNull( entry.get( atPassword ).get() );
        assertEquals( 3, entry.get( atPassword ).size() );
        assertTrue( entry.contains( "UserPassword", test1 ) );
        assertTrue( entry.contains( "userPassword", test2 ) );
        assertTrue( entry.contains( "2.5.4.35", test3 ) );
    }
View Full Code Here

     */
    @Test
    public void tesPutUpIDAtSVElipsis() throws Exception
    {
        Dn dn = new Dn( schemaManager, "cn=test" );
        DefaultEntry entry = new DefaultEntry( schemaManager, dn );

        // Test that we get an error when the ID or AT are null
        try
        {
            entry.put( null, ( AttributeType ) null, ( Value<?> ) null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        // Test an empty AT
        entry.put( "domainComponent", atDC, ( Value<?> ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "domainComponent", entry.get( atDC ).getUpId() );
        assertTrue( entry.containsAttribute( "dc" ) );
        assertNull( entry.get( atDC ).get().getValue() );

        // Check that we can use a null AttributeType
        entry.put( "domainComponent", ( AttributeType ) null, ( Value<?> ) null );

        assertEquals( 1, entry.size() );
        assertEquals( "domainComponent", entry.get( atDC ).getUpId() );
        assertTrue( entry.containsAttribute( "dc" ) );
        assertNull( entry.get( atDC ).get().getValue() );

        // Test that we can use a null upId
        entry.put( null, atDC, ( Value<?> ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "dc", entry.get( atDC ).getUpId() );
        assertTrue( entry.containsAttribute( "dc" ) );
        assertNull( entry.get( atDC ).get().getValue() );

        // Test that we can't use an upId which is not compatible
        // with the AT
        try
        {
            entry.put( "sn", atDC, ( Value<?> ) null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        // Test that we can add some new attributes with values
        Value<String> test1 = new StringValue( atDC, "test1" );
        Value<String> test2 = new StringValue( atDC, "test2" );
        Value<String> test3 = new StringValue( atDC, "test3" );

        Attribute result = entry.put( "DC", atDC, test1, test2, test3 );
        assertNotNull( result );
        assertEquals( "dc", result.getUpId() );
        assertEquals( 1, entry.size() );
        assertEquals( "DC", entry.get( atDC ).getUpId() );
        assertNotNull( entry.get( atDC ).get() );
        assertTrue( entry.contains( "dc", "test1" ) );
        assertTrue( entry.contains( "DC", "test2" ) );
        assertTrue( entry.contains( "domainComponent", "test3" ) );
    }
View Full Code Here

     */
    @Test
    public void tesPutUpIDSVElipsis() throws Exception
    {
        Dn dn = new Dn( schemaManager, "cn=test" );
        DefaultEntry entry = new DefaultEntry( schemaManager, dn );

        // Test that we get an error when the ID or AT are null
        try
        {
            entry.put( ( String ) null, ( Value<?> ) null );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }

        // Test an null valued AT
        entry.put( "domainComponent", ( Value<?> ) null );
        assertEquals( 1, entry.size() );
        assertEquals( "domainComponent", entry.get( atDC ).getUpId() );
        assertTrue( entry.containsAttribute( "dc" ) );
        assertNull( entry.get( atDC ).get().getValue() );

        // Test that we can add some new attributes with values
        Value<String> test1 = new StringValue( atDC, "test1" );
        Value<String> test2 = new StringValue( atDC, "test2" );
        Value<String> test3 = new StringValue( atDC, "test3" );

        Attribute result = entry.put( "DC", test1, test2, test3 );
        assertNotNull( result );
        assertEquals( "domainComponent", result.getUpId() );
        assertEquals( 1, entry.size() );
        assertEquals( "DC", entry.get( atDC ).getUpId() );
        assertNotNull( entry.get( atDC ).get() );
        assertTrue( entry.contains( "dc", "test1" ) );
        assertTrue( entry.contains( "DC", "test2" ) );
        assertTrue( entry.contains( "domainComponent", "test3" ) );
    }
View Full Code Here

     * Test method for remove( AttributeType, byte[]... )
     */
    @Test
    public void testRemoveAttributeTypeByteArrayArray() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Attribute attrPWD = new DefaultAttribute( atPwd, BYTES1, ( byte[] ) null, BYTES2 );

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

        entry.add( atPwd, BYTES1, ( byte[] ) null, BYTES2 );
        assertTrue( entry.remove( atPwd, ( byte[] ) null ) );
        assertEquals( 2, entry.get( atPwd ).size() );
        assertFalse( entry.contains( atPwd, ( byte[] ) null ) );
        assertTrue( entry.remove( atPwd, BYTES1, BYTES3 ) );
        assertEquals( 1, entry.get( atPwd ).size() );
        assertTrue( entry.contains( atPwd, BYTES2 ) );
        assertFalse( entry.contains( atPwd, BYTES1 ) );

        assertFalse( entry.remove( atPwd, BYTES3 ) );
        assertFalse( entry.remove( atPwd, new byte[]
            { 0x00 } ) );
    }
View Full Code Here

     * Test method for remove( AttributeType, String... )
     */
    @Test
    public void testRemoveAttributeTypeStringArray() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Attribute attrCN = new DefaultAttribute( atEMail, "test1", ( String ) null, "test2" );

        entry.put( attrCN );
        assertTrue( entry.remove( atEMail, ( String ) null ) );
        assertTrue( entry.remove( atEMail, "test1", "test2" ) );
        assertFalse( entry.containsAttribute( atEMail ) );

        entry.add( atEMail, "test1", ( String ) null, "test2" );
        assertTrue( entry.remove( atEMail, ( String ) null ) );
        assertEquals( 2, entry.get( atEMail ).size() );
        assertFalse( entry.contains( atEMail, ( String ) null ) );
        assertTrue( entry.remove( atEMail, "test1", "test3" ) );
        assertEquals( 1, entry.get( atEMail ).size() );
        assertTrue( entry.contains( atEMail, "test2" ) );
        assertFalse( entry.contains( atEMail, "test1" ) );

        assertFalse( entry.remove( atEMail, "test3" ) );
        assertFalse( entry.remove( atEMail, "test" ) );
    }
View Full Code Here

     * Test method for remove( AttributeType, Value<?>... )
     */
    @Test
    public void testRemoveAttributeTypeValueArray() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Value<String> strValue1 = new StringValue( atEMail, "test1" );
        Value<String> strValue2 = new StringValue( atEMail, "test2" );
        Value<String> strValue3 = new StringValue( atEMail, "test3" );
        Value<String> strNullValue = new StringValue( atEMail, null );

        Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );

        Attribute attrPWD = new DefaultAttribute( atEMail, "test1", ( String ) null, "test2" );

        entry.put( attrPWD );
        assertTrue( entry.remove( atEMail, strNullValue ) );
        assertTrue( entry.remove( atEMail, strValue1, strValue2 ) );
        assertFalse( entry.containsAttribute( atEMail ) );

        entry.add( atEMail, strValue1, strNullValue, strValue2 );
        assertTrue( entry.remove( atEMail, strNullValue ) );
        assertEquals( 2, entry.get( atEMail ).size() );
        assertFalse( entry.contains( atEMail, strNullValue ) );
        assertTrue( entry.remove( atEMail, strValue1, strValue3 ) );
        assertEquals( 1, entry.get( atEMail ).size() );
        assertTrue( entry.contains( atEMail, strValue2 ) );
        assertFalse( entry.contains( atEMail, strValue1 ) );

        assertFalse( entry.remove( atEMail, strValue3 ) );
        assertFalse( entry.remove( atEMail, binValue1 ) );
    }
View Full Code Here

     * Test method for remove( EntryAttribute... )
     */
    @Test
    public void testRemoveEntryAttribute() throws Exception
    {
        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );

        Attribute attrOC = new DefaultAttribute( atOC, "top", "person" );
        Attribute attrCN = new DefaultAttribute( atCN, "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( atSN, "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( atPwd, BYTES1, BYTES2 );

        entry.put( attrOC, attrCN, attrSN, attrPWD );

        List<Attribute> removed = entry.remove( attrSN, attrPWD );

        assertEquals( 2, removed.size() );
        assertEquals( 2, entry.size() );
        assertTrue( removed.contains( attrSN ) );
        assertTrue( removed.contains( attrPWD ) );
        assertTrue( entry.contains( "objectClass", "top", "person" ) );
        assertTrue( entry.contains( "cn", "test1", "test2" ) );
        assertFalse( entry.containsAttribute( atSN ) );
        assertFalse( entry.containsAttribute( "userPassword" ) );

        removed = entry.remove( attrSN, attrPWD );

        assertEquals( 0, removed.size() );
    }
View Full Code Here

TOP

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

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.