Package org.apache.directory.server.ldap.replication.consumer

Examples of org.apache.directory.server.ldap.replication.consumer.ReplicationConsumer


    @Test
    public void testInitialRefreshLoad() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshLoad" );

        ReplicationConsumer consumer = createConsumer();

        // We should have 1000 entries plus the base entry = 1001
        assertTrue( waitForSyncReplClient( consumer, 1001 ) );
        consumer.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here


    @Test
    public void testInitialRefreshLoadAndAdd() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshLoadAndAdd" );

        ReplicationConsumer consumer = createConsumer();

        // We should have 1000 entries plus the base entry = 1001
        assertTrue( waitForSyncReplClient( consumer, 1001 ) );

        // Inject a new intry in the producer
        Entry addedEntry = createEntry();
        providerSession.add( addedEntry );

        // Reset the added counter
        ( ( MockSyncReplConsumer ) consumer ).resetNbAdded();

        // Now check that the entry has been copied in the consumer
        assertTrue( waitForSyncReplClient( consumer, 1 ) );

        // Removed the added entry
        providerSession.delete( addedEntry.getDn() );
        consumer.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here

    @Test
    public void testInitialRefreshStopAndGo() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshStopAndGo" );

        ReplicationConsumer consumer = createConsumer();

        // Load but stop after 200 entries have been loaded
        waitUntilLimitSyncReplClient( 200, consumer );

        // Stop the consumer
        consumer.stop();

        // Start it again
        runConsumer( consumer );

        // We should have 1000 entries plus the base entry = 1001
        assertTrue( waitForSyncReplClient( consumer, 1001 ) );
        consumer.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here

    /**
     * Create a replication consumer
     */
    private static ReplicationConsumer createConsumer( CreateConsumer createConsumer )
    {
        ReplicationConsumer consumer = new ReplicationConsumerImpl();

        SyncreplConfiguration config = new SyncreplConfiguration();
        config.setRemoteHost( createConsumer.remoteHost() );
        config.setRemotePort( createConsumer.remotePort() );
        config.setReplUserDn( createConsumer.replUserDn() );
        config.setReplUserPassword( Strings.getBytesUtf8( createConsumer.replUserPassword() ) );
        config.setUseTls( createConsumer.useTls() );
        config.setBaseDn( createConsumer.baseDn() );
        config.setRefreshInterval( createConsumer.refreshInterval() );

        consumer.setConfig( config );

        return consumer;
    }
View Full Code Here

     * @return a running LdapServer instance
     */
    public static ReplicationConsumer createConsumer() throws ClassNotFoundException
    {
        Object instance = AnnotationUtils.getInstance( CreateConsumer.class );
        ReplicationConsumer consumer = null;

        if ( instance != null )
        {
            CreateConsumer createConsumer = ( CreateConsumer ) instance;

View Full Code Here

    @Test
    public void testInitialRefresh4Consumers() throws Exception
    {
        System.out.println( "\n--->Running testInitialRefresh4Consumers" );

        ReplicationConsumer consumer1 = createConsumer();
        ReplicationConsumer consumer2 = createConsumer();
        ReplicationConsumer consumer3 = createConsumer();
        ReplicationConsumer consumer4 = createConsumer();

        // Load but stop after 200 entries have been loaded
        assertTrue( waitUntilLimitSyncReplClient( 1001, consumer1, consumer2, consumer3, consumer4 ) );

        consumer1.stop();
        consumer2.stop();
        consumer3.stop();
        consumer4.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here

    }


    private ReplicationConsumer createConsumer() throws Exception
    {
        final ReplicationConsumer syncreplClient = new MockSyncReplConsumer();
        final SyncReplConfiguration config = new SyncReplConfiguration();
        config.setRemoteHost( "localhost" );
        config.setRemotePort( 16000 );
        config.setReplUserDn( "uid=admin,ou=system" );
        config.setReplUserPassword( "secret".getBytes() );
        config.setUseTls( false );
        config.setBaseDn( "dc=example,dc=com" );
        config.setRefreshInterval( 1000 );

        syncreplClient.setConfig( config );

        assertTrue( true );

        Runnable consumerTask = new Runnable()
        {
            public void run()
            {
                try
                {
                    String baseDn = config.getBaseDn();

                    SearchRequest searchRequest = new SearchRequestImpl();

                    searchRequest.setBase( new Dn( baseDn ) );
                    searchRequest.setFilter( config.getFilter() );
                    searchRequest.setSizeLimit( config.getSearchSizeLimit() );
                    searchRequest.setTimeLimit( config.getSearchTimeout() );

                    searchRequest.setDerefAliases( config.getAliasDerefMode() );
                    searchRequest.setScope( config.getSearchScope() );
                    searchRequest.setTypesOnly( false );

                    searchRequest.addAttributes( config.getAttributes() );

                    DirectoryService directoryService = new MockDirectoryService();
                    directoryService.setSchemaManager( schemaManager );
                    ( ( MockSyncReplConsumer ) syncreplClient ).init( directoryService );
                    syncreplClient.connect( true );
                    syncreplClient.startSync();
                }
                catch ( Exception e )
                {
                    throw new RuntimeException( e );
                }
View Full Code Here

    @Test
    public void testInitialRefreshLoad() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshLoad" );

        ReplicationConsumer consumer = createConsumer();

        // We should have 1000 entries plus the base entry = TOTAL_COUNT
        assertTrue( waitForSyncReplClient( consumer, TOTAL_COUNT ) );
        consumer.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here

    @Test
    public void testInitialRefreshLoadAndAdd() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshLoadAndAdd" );

        ReplicationConsumer consumer = createConsumer();

        // We should have INSERT_COUNT entries plus the base entry = TOTAL_COUNT
        assertTrue( waitForSyncReplClient( consumer, TOTAL_COUNT ) );

        // Reset the added counter
        ( ( MockSyncReplConsumer ) consumer ).resetNbAdded();

        // Inject a new entry in the producer
        Entry addedEntry = createEntry();
        providerSession.add( addedEntry );

        // Now check that the entry has been copied in the consumer
        assertTrue( waitForSyncReplClient( consumer, 1 ) );

        // Removed the added entry
        providerSession.delete( addedEntry.getDn() );
        consumer.stop();

        System.out.println( "\n<-- Done" );
    }
View Full Code Here

    @Test
    public void testInitialRefreshStopAndGo() throws Exception
    {
        System.out.println( "\n---> Running testInitialRefreshStopAndGo" );

        ReplicationConsumer consumer = createConsumer();

        // Load all the entries
        waitUntilLimitSyncReplClient( TOTAL_COUNT, consumer );

        // Stop the consumer
        consumer.stop();

        int additionalCount = 10;
        List<Dn> newEntries = new ArrayList<Dn>();
        for( int i = 0; i < additionalCount; i++ )
        {
            // Inject a new entry in the producer
            Entry addedEntry = createEntry();
            providerSession.add( addedEntry );
            newEntries.add( addedEntry.getDn() );
        }

        // Start it again
        runConsumer( consumer );

        // We should get only the additional values cause consumer sends a cookie now
        assertTrue( waitForSyncReplClient( consumer, additionalCount ) );
        consumer.stop();

        for( Dn dn : newEntries )
        {
            providerSession.delete( dn );
        }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.ldap.replication.consumer.ReplicationConsumer

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.