Package org.apache.sling.replication.queue

Examples of org.apache.sling.replication.queue.ReplicationQueueProvider


        when(properties.get("priority.paths")).thenReturn(new String[]{"/content", "/apps"});
        when(context.getProperties()).thenReturn(properties);
        priorityPathDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/etc"});
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(any(ReplicationQueueItem.class))).thenReturn(true);

        boolean returnedState = priorityPathDistributionStrategy.add("agentName", replicationPackage, queueProvider);
        assertTrue(returnedState);
    }
View Full Code Here


    public void testReplicationWithWorkingDistributionStrategy() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "subServiceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider,
                distributionHandler, replicationEventFactory, resolverFactory, null);
        ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                ReplicationActionType.ADD, "/");
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);

        when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
        when(distributionHandler.add(any(String.class), any(ReplicationPackage.class), eq(queueProvider))).thenReturn(true);
        when(packageExporter.exportPackages(any(ResourceResolver.class), any(ReplicationRequest.class)))
                .thenReturn(Arrays.asList(replicationPackage));
        when(queueProvider.getDefaultQueue(name)).thenReturn(
                new SimpleReplicationQueue(name, "name"));
        ReplicationResponse response = agent.execute(resourceResolver, request);
        assertNotNull(response);
        assertEquals("QUEUED", response.getStatus());
    }
View Full Code Here

        when(properties.get("priority.paths")).thenReturn(new String[]{"/content", "/apps"});
        when(context.getProperties()).thenReturn(properties);
        priorityPathDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/content/sample2"});
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);

        when(queueProvider.getQueue("agentName", "/content")).thenReturn(queue);
        when(queue.add(any(ReplicationQueueItem.class))).thenReturn(true);

        boolean returnedState = priorityPathDistributionStrategy.add("agentName", replicationPackage, queueProvider);
        assertTrue(returnedState);
    }
View Full Code Here

    public void testReplication() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory, null);
        ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                ReplicationActionType.ADD, "/");
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);

        when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
        when(packageExporter.exportPackages(resourceResolver, request)).thenReturn(Arrays.asList(replicationPackage));
        when(queueProvider.getDefaultQueue(name)).thenReturn(
                new SimpleReplicationQueue(name, "name"));

        agent.execute(resourceResolver, request);
    }
View Full Code Here

        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory, null);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queueProvider.getDefaultQueue(name)).thenReturn(queue);
        assertNotNull(agent.getQueue(null));
    }
View Full Code Here

        when(properties.get("priority.paths")).thenReturn(new String[]{"/content", "/apps"});
        when(context.getProperties()).thenReturn(properties);
        priorityPathDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/etc"});
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);

        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(any(ReplicationQueueItem.class))).thenReturn(true);
        boolean returnedState = priorityPathDistributionStrategy.add("agentName", replicationPackage, queueProvider);
        assertTrue(returnedState);
    }
View Full Code Here

        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory, null);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queueProvider.getQueue(name, "priority")).thenReturn(queue);
        assertNotNull(agent.getQueue("priority"));
    }
View Full Code Here

        when(properties.get("priority.paths")).thenReturn(new String[]{"/content", "/apps"});
        when(context.getProperties()).thenReturn(properties);
        priorityPathDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/apps/some/stuff"});
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);

        when(queueProvider.getQueue("agentName", "/apps")).thenReturn(queue);
        when(queue.add(any(ReplicationQueueItem.class))).thenReturn(true);
        boolean returnedState = priorityPathDistributionStrategy.add("agentName", replicationPackage, queueProvider);
        assertTrue(returnedState);
    }
View Full Code Here

        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory, null);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queueProvider.getQueue(name, "priority")).thenReturn(queue);
        assertNull(agent.getQueue("weird"));
    }
View Full Code Here

        when(properties.get("priority.paths")).thenReturn(new String[]{"/content", "/apps"});
        when(context.getProperties()).thenReturn(properties);
        priorityPathDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/etc"});
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(any(ReplicationQueueItem.class))).thenReturn(true);
        boolean returnedState = priorityPathDistributionStrategy.add("agentName", replicationPackage, queueProvider);
        assertTrue(returnedState);
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.queue.ReplicationQueueProvider

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.