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

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


     * Test method for put( String, Value<?>... )
     */
    @Test
    public void testPutStringValueArray()
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
        Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
        Value<String> strValue3 = new ServerStringValue( atCN, "test3" );
        Value<String> strNullValue = new ServerStringValue( atCN, null);

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

        try
        {
            entry.put( (String)null, strValue1 );
            fail();
        }
        catch ( IllegalArgumentException iae)
        {
            assertTrue( true );
        }
       
        try
        {
            entry.put( "   ", strValue1 );
            fail();
        }
        catch ( IllegalArgumentException iae)
        {
            assertTrue( true );
        }
       
        try
        {
            entry.put( "cnn", strValue1 );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            assertTrue( true );
        }
       
        EntryAttribute replaced = entry.put( "description", strNullValue );
        assertNull( replaced );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "description" ) );
        assertEquals( 1, entry.get( "description" ).size() );
        assertNotNull( entry.get( "description" ).get() );
        assertNull( entry.get( "description" ).get().get() );
       
        replaced = entry.put( "CN", strValue3 );
        assertNull( replaced );
        assertEquals( 2, entry.size() );
        assertNotNull( entry.get( "cn" ) );
        assertEquals( 1, entry.get( "cn" ).size() );
        assertNotNull( entry.get( "cn" ).get().get() );
        assertTrue( entry.get( "cn" ).contains( strValue3 ) );
       
        replaced = entry.put"cN", strValue1, strValue2, strValue1 );
        assertNotNull( replaced );
        assertEquals( strValue3, replaced.get() );
       
        assertEquals( 2, entry.size() );
        assertNotNull( entry.get( "cn" ) );
        assertEquals( 2, entry.get( "CN" ).size() );
       
        EntryAttribute attribute = entry.get( "cn" );
        assertTrue( attribute.contains( strValue1 ) );
        assertTrue( attribute.contains( strValue2 ) );
        assertEquals( "cn", attribute.getId() );
        assertEquals( "cN", attribute.getUpId() );
       
        // Bin values are not allowed, so the new CN will be empty
        entry.put( "cn", binValue1 );
        assertNull( entry.get( "cn" ).get() );
    }
View Full Code Here


     * Test method for removeAttributes( String... )
     */
    @Test
    public void testRemoveAttributesStringArray() 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 );
       
        entry.removeAttributes( "CN", "SN" );
       
        assertFalse( entry.containsAttribute( "cn", "sn" ) );
        assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );
       
        List<EntryAttribute> removed = entry.removeAttributes( "badId" );
        assertNull( removed );
       
        removed = entry.removeAttributes( "l" );
        assertNull( removed );
       
        removed = entry.removeAttributes( (String )null );
        assertNull( removed );
    }
View Full Code Here

     * Test method for set( String... )
     */
    @Test
    public void testSetStringArray() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );

        entry.add( "ObjectClass", "top", "person" );
        entry.add( "cn", "test1", "test2" );
        entry.add( "sn", "Test" );
       
        List<EntryAttribute> removed = entry.set( "objectClass", "CN", "givenName" );
       
        assertEquals( 4, entry.size() );
        assertNotNull( entry.get( "objectclass" ) );
        assertNotNull( entry.get( "cn" ) );
        assertNotNull( entry.get( "givenname" ) );
        assertNotNull( entry.get( "sn" ) );
       
        assertNull( entry.get( "objectclass" ).get() );
        assertNull( entry.get( "cn" ).get() );
        assertNull( entry.get( "givenname" ).get() );
        assertNotNull( entry.get( "sn" ).get() );
       
        assertNotNull( removed );
        assertEquals( 2, removed.size() );
    }
View Full Code Here

        ModifyResponse resp = con.modify( modReq );
        assertEquals( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, resp.getLdapResult().getResultCode() );

        // Check whether entry is unmodified, i.e. no description
        Entry entry = ( ( SearchResultEntry )con.lookup( DN ) ).getEntry();
        assertEquals( "description exists?", null, entry.get( "description" ) );
    }
View Full Code Here

            "m-oid=" + normalizerDescription.getOid(),
            SchemaConstants.NORMALIZERS_PATH ,
            "cn=" + schemaName,
            SchemaConstants.OU_SCHEMA );
       
        Entry entry = getEntry( dn, normalizerDescription );

        opContext.add( (ServerEntry)entry, BYPASS );
    }
View Full Code Here

            "m-oid=" + syntaxCheckerDescription.getOid(),
            SchemaConstants.SYNTAX_CHECKERS_PATH,
            "cn=" + schemaName,
            SchemaConstants.OU_SCHEMA );
       
        Entry entry = getEntry( dn, syntaxCheckerDescription );
        opContext.add( (ServerEntry)entry, BYPASS );
    }
View Full Code Here

    }


    private Entry getEntry( DN dn, LdapComparatorDescription comparatorDescription )
    {
        Entry entry = new DefaultServerEntry( schemaManager, dn );
       
        entry.put( SchemaConstants.OBJECT_CLASS_AT,
                    SchemaConstants.TOP_OC,
                    MetaSchemaConstants.META_TOP_OC,
                    MetaSchemaConstants.META_COMPARATOR_OC );
       
        entry.put( MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid() );
        entry.put( MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn() );

        if ( comparatorDescription.getBytecode() != null )
        {
            entry.put( MetaSchemaConstants.M_BYTECODE_AT,
                Base64.decode( comparatorDescription.getBytecode().toCharArray() ) );
        }
       
        if ( comparatorDescription.getDescription() != null )
        {
            entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription() );
        }
       
        return entry;
    }
View Full Code Here

     * Test method for clear()
     */
    @Test
    public void testClear() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
        
        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );
        entry.clear();
        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );
        
        entry.add( "ObjectClass", "top", "person" );
        assertEquals( 1, entry.size() );
        assertNotNull( entry.get( "ObjectClass" ) );
       
        entry.clear();
        assertEquals( 0, entry.size() );
        assertNull( entry.get( "ObjectClass" ) );
    }
View Full Code Here

    }


    private Entry getEntry( DN dn, NormalizerDescription normalizerDescription )
    {
        Entry entry = new DefaultServerEntry( schemaManager, dn );

        entry.put( SchemaConstants.OBJECT_CLASS_AT,
            SchemaConstants.TOP_OC,
            MetaSchemaConstants.META_TOP_OC,
            MetaSchemaConstants.META_NORMALIZER_OC );
       
        entry.put( MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid() );
        entry.put( MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn() );

        if ( normalizerDescription.getBytecode() != null )
        {
            entry.put( MetaSchemaConstants.M_BYTECODE_AT,
                Base64.decode( normalizerDescription.getBytecode().toCharArray() ) );
        }
       
        if ( normalizerDescription.getDescription() != null )
        {
            entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription() );
        }
       
        return entry;
    }
View Full Code Here

    }
   
   
    private Entry getEntry( DN dn, SyntaxCheckerDescription syntaxCheckerDescription )
    {
        Entry entry = new DefaultServerEntry( schemaManager, dn );
       
        entry.put( SchemaConstants.OBJECT_CLASS_AT,
            SchemaConstants.TOP_OC,
            MetaSchemaConstants.META_TOP_OC,
            MetaSchemaConstants.META_SYNTAX_CHECKER_OC );

        entry.put( MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid() );
        entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn() );

        if ( syntaxCheckerDescription.getBytecode() != null )
        {
            entry.put( MetaSchemaConstants.M_BYTECODE_AT,
                Base64.decode( syntaxCheckerDescription.getBytecode().toCharArray() ) );
        }
       
        if ( syntaxCheckerDescription.getDescription() != null )
        {
            entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription() );
        }
       
        return entry;
    }
View Full Code Here

TOP

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

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.