Package org.apache.sling.replication.queue

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


    public void testPackageAdditionWithFailingItemDelivery() throws Exception {
        SingleQueueDistributionStrategy singleQueueDistributionStrategy = new SingleQueueDistributionStrategy();
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        ReplicationQueueItem queueItem = mock(ReplicationQueueItem.class);
        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(queueItem)).thenReturn(true);
        ReplicationQueueItemState state = mock(ReplicationQueueItemState.class);
        when(state.isSuccessful()).thenReturn(false);
        when(queue.getStatus(queueItem)).thenReturn(state);
View Full Code Here


    public void testWithOneOkItemInTheQueue() throws Exception {
        ReplicationQueueHealthCheck replicationQueueHealthCheck = new ReplicationQueueHealthCheck();

        replicationQueueHealthCheck.activate(Collections.<String, Object>emptyMap());
        ReplicationQueue queue = mock(ReplicationQueue.class);
        ReplicationQueueItem item = mock(ReplicationQueueItem.class);
        ReplicationQueueItemState status = mock(ReplicationQueueItemState.class);
        when(status.getAttempts()).thenReturn(1);
        when(queue.getStatus(item)).thenReturn(status);
        when(queue.getHead()).thenReturn(item);
        ReplicationQueueProvider replicationQueueProvider = mock(ReplicationQueueProvider.class);
View Full Code Here

    public void testWithNotOkItemInTheQueue() throws Exception {
        ReplicationQueueHealthCheck replicationQueueHealthCheck = new ReplicationQueueHealthCheck();

        replicationQueueHealthCheck.activate(Collections.<String, Object>emptyMap());
        ReplicationQueue queue = mock(ReplicationQueue.class);
        ReplicationQueueItem item = mock(ReplicationQueueItem.class);
        ReplicationQueueItemState status = mock(ReplicationQueueItemState.class);
        when(status.getAttempts()).thenReturn(10);
        when(queue.getStatus(item)).thenReturn(status);
        when(queue.getHead()).thenReturn(item);
        ReplicationQueueProvider replicationQueueProvider = mock(ReplicationQueueProvider.class);
View Full Code Here

    public void testPackageAdditionWithFailingItemDelivery() throws Exception {
        ErrorAwareQueueDistributionStrategy errorAwareDistributionStrategy = new ErrorAwareQueueDistributionStrategy();
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        ReplicationQueueItem queueItem = mock(ReplicationQueueItem.class);

        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(queueItem)).thenReturn(true);
        ReplicationQueueItemState state = mock(ReplicationQueueItemState.class);
        when(state.isSuccessful()).thenReturn(false);
View Full Code Here

        when(context.getProperties()).thenReturn(properties);
        errorAwareDistributionStrategy.activate(context);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueue queue = mock(ReplicationQueue.class);
        ReplicationQueueItem queueItem = mock(ReplicationQueueItem.class);

        when(queueProvider.getDefaultQueue("agentName")).thenReturn(queue);
        when(queue.add(queueItem)).thenReturn(true);
        when(queue.getHead()).thenReturn(queueItem);
        ReplicationQueue errorQueue = mock(ReplicationQueue.class);
View Full Code Here

        String topic = JobHandlingReplicationQueue.REPLICATION_QUEUE_TOPIC + "/aname";
        when(jobManager.createJob(topic)).thenReturn(builder);
        when(jobManager.findJobs(JobManager.QueryType.ALL, topic, -1)).thenReturn(Collections.<Job>emptySet());
        when(builder.properties(any(Map.class))).thenReturn(builder);
        ReplicationQueue queue = new JobHandlingReplicationQueue("aname", topic, jobManager);
        ReplicationQueueItem pkg = mock(ReplicationQueueItem.class);
        assertTrue(queue.add(pkg));
    }
View Full Code Here

        String topic = JobHandlingReplicationQueue.REPLICATION_QUEUE_TOPIC + "/aname";
        when(jobManager.createJob(topic)).thenReturn(builder);
        when(jobManager.findJobs(JobManager.QueryType.ALL, topic, -1)).thenReturn(Collections.<Job>emptySet());
        when(builder.properties(any(Map.class))).thenReturn(builder);
        ReplicationQueue queue = new JobHandlingReplicationQueue("aname", topic, jobManager);
        ReplicationQueueItem pkg = mock(ReplicationQueueItem.class);
        assertTrue(queue.add(pkg));
        ReplicationQueueItemState status = queue.getStatus(pkg);
        assertNotNull(status);
        assertFalse(status.isSuccessful());
        assertEquals(ItemState.DROPPED, status.getItemState());
View Full Code Here

* Testcase for {@link JobHandlingUtils}
*/
public class JobHandlingUtilsTest {
    @Test
    public void testFullPropertiesFromPackageCreation() throws Exception {
        ReplicationQueueItem replicationQueueItem = mock(ReplicationQueueItem.class);
        when(replicationQueueItem.getAction()).thenReturn("ADD");
        when(replicationQueueItem.getId()).thenReturn("an-id");
        when(replicationQueueItem.getPaths()).thenReturn(new String[]{"/content", "/apps"});
        when(replicationQueueItem.getType()).thenReturn("vlt");
        Map<String, Object> fullPropertiesFromPackage = JobHandlingUtils.createFullProperties(replicationQueueItem);
        assertNotNull(fullPropertiesFromPackage);
        assertEquals(4, fullPropertiesFromPackage.size());
        assertNotNull(fullPropertiesFromPackage.get("replication.package.paths"));
        assertNotNull(fullPropertiesFromPackage.get("replication.package.id"));
View Full Code Here

        assertNotNull(fullPropertiesFromPackage.get("replication.package.action"));
    }

    @Test
    public void testIdPropertiesFromPackageCreation() throws Exception {
        ReplicationQueueItem replicationPackage = mock(ReplicationQueueItem.class);
        when(replicationPackage.getId()).thenReturn("an-id");
        Map<String, Object> idPropertiesFromPackage = JobHandlingUtils.createIdProperties(replicationPackage.getId());
        assertNotNull(idPropertiesFromPackage);
        assertEquals(1, idPropertiesFromPackage.size());
        assertNotNull(idPropertiesFromPackage.get("replication.package.id"));
    }
View Full Code Here

TOP

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

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.