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

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


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

        // Test that we can't inject a null AT
        try
        {
            entry.add( ( AttributeType ) null, "test" );
            fail();
        }
        catch ( IllegalArgumentException iae )
        {
            // Expected
        }

        // Test a simple addition
        entry.add( atEMail, "test1" );
        assertNotNull( entry.get( atEMail ) );
        assertEquals( 1, entry.get( atEMail ).size() );
        assertEquals( "test1", entry.get( atEMail ).get().getString() );

        // Test some more addition
        entry.add( atEMail, "test2", "test3" );
        assertNotNull( entry.get( atEMail ) );
        assertEquals( 3, entry.get( atEMail ).size() );
        assertTrue( entry.contains( atEMail, "test1" ) );
        assertTrue( entry.contains( atEMail, "test2" ) );
        assertTrue( entry.contains( atEMail, "test3" ) );

        // Test some addition of existing values
        entry.add( atEMail, "test2" );
        assertNotNull( entry.get( atEMail ) );
        assertEquals( 3, entry.get( atEMail ).size() );
        assertTrue( entry.contains( atEMail, "test1" ) );
        assertTrue( entry.contains( atEMail, "test2" ) );
        assertTrue( entry.contains( atEMail, "test3" ) );

        // Test the addition of a null value
        entry.add( atEMail, ( String ) null );
        assertNotNull( entry.get( atEMail ) );
        assertEquals( 4, entry.get( atEMail ).size() );
        assertTrue( entry.contains( atEMail, "test1" ) );
        assertTrue( entry.contains( atEMail, "test2" ) );
        assertTrue( entry.contains( atEMail, "test3" ) );
        assertTrue( entry.contains( atEMail, ( String ) null ) );

        entry.clear();

        // Test the addition of a binary value
        byte[] test4 = Strings.getBytesUtf8( "test4" );

        entry.add( atCN, test4 );
        assertFalse( entry.get( atCN ).contains( test4 ) );
    }
View Full Code Here


    @Test
    @Ignore
    public void testAddPerf() throws Exception
    {
        Dn dn = new Dn( "cn=test,ou=system" );
        Entry entry = new DefaultEntry( getService().getSchemaManager(), dn,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn: TEST",
            "cn: test" );

        connection.add( entry );

        int nbIterations = 8000;

        //BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") );

        long t0 = System.currentTimeMillis();
        long t00 = 0L;
        long tt0 = System.currentTimeMillis();

        for ( int i = 0; i < nbIterations; i++ )
        {
            if ( i % 1000 == 0 )
            {
                long tt1 = System.currentTimeMillis();

                System.out.println( i + ", " + ( tt1 - tt0 ) );
                tt0 = tt1;
            }

            if ( i == 500 )
            {
                t00 = System.currentTimeMillis();
            }

            dn = new Dn( "uid=" + i + ",dc=example,dc=com" );
            entry = new DefaultEntry(
                getService().getSchemaManager(),
                dn,
                "objectClass: top",
                "objectClass: person",
                "objectClass: organizationalPerson",
View Full Code Here

    @Test
    public void testModify() throws Exception
    {
        // Add the entry
        Dn dn = new Dn( "uid=1,dc=example,dc=com" );
        Entry entry = new DefaultEntry(
            getService().getSchemaManager(),
            dn,
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
View Full Code Here

    @Test
    public void testModifyReplace() throws LdapException, CursorException, IOException
    {
        // Add the entry
        Dn dn = new Dn( "uid=1,dc=example,dc=com" );
        Entry entry = new DefaultEntry(
            getService().getSchemaManager(),
            dn,
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
View Full Code Here

    @Test
    public void testModifyAdd() throws LdapException, CursorException, IOException
    {
        // Add the entry
        Dn dn = new Dn( "uid=1,dc=example,dc=com" );
        Entry entry = new DefaultEntry(
            getService().getSchemaManager(),
            dn,
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
View Full Code Here

    @Test
    public void testModifyDelete() throws LdapException, CursorException, IOException
    {
        // Add the entry
        Dn dn = new Dn( "uid=1,dc=example,dc=com" );
        Entry entry = new DefaultEntry(
            getService().getSchemaManager(),
            dn,
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
View Full Code Here

    @Test
    public void testSimpleSearch() throws Exception
    {
        // Add an entry in ou=system
        Dn dn1 = new Dn( "cn=test,ou=system" );
        Entry entry1 = new DefaultEntry( getService().getSchemaManager(), dn1,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn: TEST",
            "cn: test" );

        connection.add( entry1 );

        // Add an entry in dc=test
        Dn dn2 = new Dn( "cn=test,dc=test,dc=com" );
        Entry entry2 = new DefaultEntry( getService().getSchemaManager(), dn2,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn: TEST",
            "cn: test" );

        connection.add( entry2 );

        // Add an entry in dc=example
        Dn dn3 = new Dn( "cn=test,dc=example,dc=com" );
        Entry entry3 = new DefaultEntry( getService().getSchemaManager(), dn3,
            "ObjectClass: top",
            "ObjectClass: person",
            "sn: TEST",
            "cn: test" );
View Full Code Here

        store2.setSuffixDn( EXAMPLE_COM );
        store2.initialize();

        // inject context entry
        Dn suffixDn = new Dn( schemaManager, "dc=example,dc=com" );
        Entry entry = new DefaultEntry( schemaManager, suffixDn,
            "objectClass: top",
            "objectClass: domain",
            "dc: example",
            SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString(),
            SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
View Full Code Here

    @Test(expected = LdapNoSuchObjectException.class)
    public void testAddWithoutParentId() throws Exception
    {
        Dn dn = new Dn( schemaManager, "cn=Marting King,ou=Not Present,o=Good Times Co." );
        Entry entry = new DefaultEntry( schemaManager, dn,
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
            "ou: Not Present",
            "cn: Martin King" );
View Full Code Here

    @Test(expected = LdapSchemaViolationException.class)
    public void testAddWithoutObjectClass() throws Exception
    {
        Dn dn = new Dn( schemaManager, "cn=Martin King,ou=Sales,o=Good Times Co." );
        Entry entry = new DefaultEntry( schemaManager, dn,
            "ou: Sales",
            "cn: Martin King" );
        AddOperationContext addContext = new AddOperationContext( null, entry );
        store.add( addContext );
    }
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.