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

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


     * Test method for clone()
     */
    @Test
    public void testClone() throws Exception
    {
        Entry entry1 = new DefaultServerEntry( schemaManager );
       
        Entry entry2 = entry1.clone();
       
        assertEquals( entry1, entry2 );
        entry2.setDn( EXAMPLE_DN );
       
        assertEquals( DN.EMPTY_DN,entry1.getDn() );
       
        entry1.setDn( EXAMPLE_DN );
        entry2 = entry1.clone();
        assertEquals( entry1, entry2 );
       
        entry1.add( "objectClass", "top", "person" );
        entry1.add( "cn", "test1", "test2" );
       
        entry2 = entry1.clone();
        assertEquals( entry1, entry2 );
       
        entry1.add( "cn", "test3" );
        assertEquals( 2, entry2.get( "cn" ).size() );
        assertFalse( entry2.contains( "cn", "test3" ) );
       
        entry1.add( "sn", (String)null );
        assertFalse( entry2.containsAttribute( "sn" ) );
    }
View Full Code Here


     * Test for method contains( EntryAttribute... )
     */
    @Test
    public void testContainsEntryAttributeArray() 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 );

        assertFalse( entry.contains( attrOC, attrCN ) );
       
        entry.add( attrOC, attrCN );

        assertTrue( entry.contains( attrOC, attrCN ) );
        assertFalse( entry.contains( attrOC, attrCN, attrSN ) );
       
        entry.add( attrSN, attrPWD );

        assertTrue( entry.contains( attrSN, attrPWD ) );
       
        assertFalse( entry.contains( (EntryAttribute)null ) );
        entry.clear();
        assertTrue( entry.contains( (EntryAttribute)null ) );
    }
View Full Code Here

     * Test for method contains( String, byte[]... )
     */
    @Test
    public void testContainsStringByteArrayArray() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.contains( (String)null, BYTES3 ) );
        assertFalse( entry.containsAttribute( "objectClass" ) );
       
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, (byte[])null, BYTES2 );

        entry.add( attrPWD );
       
        assertTrue( entry.contains( "  userPASSWORD  ", BYTES1, BYTES2 ) );
        assertTrue( entry.contains( "  userPASSWORD  ", (byte[])null ) );
       
        assertFalse( entry.contains( "  userPASSWORD  ", "ab", "b" ) );
        assertFalse( entry.contains( "  userPASSWORD  ", BYTES3 ) );
        assertFalse( entry.contains( "  userASSWORD  ", BYTES3 ) );
    }
View Full Code Here

     * Test for method contains( String, String... )
     */
    @Test
    public void testContainsStringStringArray() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.contains( (String)null, "test" ) );
        assertFalse( entry.containsAttribute( "objectClass" ) );
       
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", (String)null, "test2" );

        entry.add( attrCN );
       
        assertTrue( entry.contains( "  CN  ", "test1", "test2" ) );
       
        assertTrue( entry.contains( "  CN  ", (String)null ) );
        assertFalse( entry.contains( "  CN  ", BYTES1, BYTES2 ) );
        assertFalse( entry.contains( "  CN  ", "test3" ) );
        assertFalse( entry.contains( "  CNN  ", "test3" ) );
    }
View Full Code Here

     * Test for method contains( String, Value<?>... )
     */
    @Test
    public void testContainsStringValueArray() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.contains( (String)null, "test" ) );
        assertFalse( entry.containsAttribute( "objectClass" ) );
       
        EntryAttribute attrCN = new DefaultServerAttribute( atCN, "test1", "test2", (String)null );
        EntryAttribute attrPWD = new DefaultServerAttribute( atPwd, BYTES1, BYTES2, (byte[])null );

        entry.add( attrCN, attrPWD );
       
        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 );
        Value<byte[]> binValue2 = new ServerBinaryValue( atPwd, BYTES2 );
        Value<byte[]> binValue3 = new ServerBinaryValue( atPwd, BYTES3 );
        Value<byte[]> binNullValue = new ServerBinaryValue( atPwd, null );

        assertTrue( entry.contains( "CN", strValue1, strValue2 ) );
        assertTrue( entry.contains( "userpassword", binValue1, binValue2, binNullValue ) );
       
        assertFalse( entry.contains( "cn", strValue3 ) );
        assertTrue( entry.contains( "cn", strNullValue ) );
        assertFalse( entry.contains( "UserPassword", binValue3 ) );
    }
View Full Code Here

     * Test method for containsAttribute( String )
     */
    @Test
    public void testContainsAttributeString() throws Exception
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertFalse( entry.containsAttribute( "objectClass" ) );
       
        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 );
       
        assertTrue( entry.containsAttribute( "OBJECTCLASS", " cn ", "Sn", "  userPASSWORD  " ) );
       
        entry.clear();

        assertFalse( entry.containsAttribute( "OBJECTCLASS" ) );
        assertFalse( entry.containsAttribute( " cn " ) );
        assertFalse( entry.containsAttribute( "Sn" ) );
        assertFalse( entry.containsAttribute( "  userPASSWORD  " ) );
        assertFalse( entry.containsAttribute( "  userASSWORD  " ) );
    }
View Full Code Here

     * Test method for equals()
     */
    @Test
    public void testEqualsObject() throws Exception
    {
        Entry entry1 = new DefaultServerEntry( schemaManager );
        Entry entry2 = new DefaultServerEntry( schemaManager );
       
        assertEquals( entry1, entry2 );
       
        entry1.setDn( EXAMPLE_DN );
        assertNotSame( entry1, entry2 );
       
        entry2.setDn( EXAMPLE_DN );
        assertEquals( entry1, entry2 );

        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.put( attrOC, attrCN, attrSN, attrPWD );
        entry2.put( attrOC, attrCN, attrSN );
        assertNotSame( entry1, entry2 );
       
        entry2.put( attrPWD );
        assertEquals( entry1, entry2 );
       
        EntryAttribute attrL1 = new DefaultServerAttribute( "l", atL, "Paris", "New-York" );
        EntryAttribute attrL2 = new DefaultServerAttribute( "l", atL, "Paris", "Tokyo" );
       
        entry1.put( attrL1 );
        entry2.put( attrL1 );
        assertEquals( entry1, entry2 );
       
        entry1.add( "l", "London" );
        assertNotSame( entry1, entry2 );

        entry2.add( attrL2 );
        assertNotSame( entry1, entry2 );

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

     * Test method for get( String )
     */
    @Test
    public void testGetString() throws Exception
    {
        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 " ) );
        assertNotNull( entry.get( "2.5.4.3" ) );
       
        assertEquals( attrCN, entry.get( "2.5.4.3" ) );
        assertEquals( attrOC, entry.get( " OBJECTCLASS" ) );
        assertEquals( attrSN, entry.get( "sn" ) );
        assertEquals( attrPWD, entry.get( "  userPassword  " ) );
    }
View Full Code Here

     * Test method for getDN()
     */
    @Test
    public void testGetDn() throws InvalidNameException
    {
        Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
        
        assertEquals( EXAMPLE_DN, entry.getDn() );
        
        DN testDn = new DN( "cn=test" );
        entry.setDn( testDn );
        
        assertEquals( testDn, entry.getDn() );
    }
View Full Code Here

     * Test method for hashcode()
     */
    @Test
    public void testHashCode() throws InvalidNameException, Exception
    {
        Entry entry1 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
        Entry entry2 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
       
        assertEquals( entry1.hashCode(), entry2.hashCode() );
       
        entry2.setDn( new DN( "ou=system,dc=com" ) );
        assertNotSame( entry1.hashCode(), entry2.hashCode() );
       
        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() );
       
        Entry entry3 = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
        entry3.add( attrOC, attrSN, attrCN, attrPWD );

        assertEquals( entry1.hashCode(), entry3.hashCode() );
    }
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.