Package org.apache.sling.replication.queue

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


        List<ReplicationPackage> result = new ArrayList<ReplicationPackage>();
        try {
            log.info("getting item from queue {}", queueName);

            ReplicationQueue queue = agent.getQueue(queueName);
            ReplicationQueueItem info = queue.getHead();
            ReplicationPackage replicationPackage;
            if (info != null) {
                replicationPackage = packageBuilder.getPackage(resourceResolver, info.getId());
                queue.remove(info.getId());
                if (replicationPackage != null) {
                    result.add(replicationPackage);
                }
            }
View Full Code Here


    @Test
    public void testRunWithOneEmptyQueue() throws Exception {
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        Collection<ReplicationQueue> queues = new LinkedList<ReplicationQueue>();
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queue.isEmpty()).thenReturn(true);
        queues.add(queue);
        when(queueProvider.getAllQueues()).thenReturn(queues);
        ReplicationQueueProcessor queueProcessor = mock(ReplicationQueueProcessor.class);
        ScheduledReplicationQueueProcessorTask scheduledReplicationQueueProcessorTask = new ScheduledReplicationQueueProcessorTask(
                queueProvider, queueProcessor);
View Full Code Here

    @Test
    public void testRunWithOneNonEmptyQueue() throws Exception {
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        Collection<ReplicationQueue> queues = new LinkedList<ReplicationQueue>();
        ReplicationQueue queue = mock(ReplicationQueue.class);
        when(queue.isEmpty()).thenReturn(false).thenReturn(true);
        ReplicationQueueItem item = mock(ReplicationQueueItem.class);
        when(queue.getHead()).thenReturn(item);

        queues.add(queue);
        when(queueProvider.getAllQueues()).thenReturn(queues);
        ReplicationQueueProcessor queueProcessor = mock(ReplicationQueueProcessor.class);
        ScheduledReplicationQueueProcessorTask scheduledReplicationQueueProcessorTask = new ScheduledReplicationQueueProcessorTask(
View Full Code Here

*/
public class SimpleReplicationQueueTest {

    @Test
    public void testPackageAddition() throws Exception {
        ReplicationQueue queue = new SimpleReplicationQueue("agentName", "default");
        ReplicationQueueItem pkg = mock(ReplicationQueueItem.class);
        assertTrue(queue.add(pkg));
        assertFalse(queue.isEmpty());
    }
View Full Code Here

        assertFalse(queue.isEmpty());
    }

    @Test
    public void testPackageAdditionAndRemoval() throws Exception {
        ReplicationQueue queue = new SimpleReplicationQueue("agentName", "default");
        ReplicationQueueItem pkg = mock(ReplicationQueueItem.class);
        when(pkg.getId()).thenReturn("id");
        assertTrue(queue.add(pkg));
        assertFalse(queue.isEmpty());
        queue.remove(pkg.getId());
        assertTrue(queue.isEmpty());
        ReplicationQueueItemState status = queue.getStatus(pkg);
        assertNotNull(status);
        assertTrue(status.isSuccessful());
    }
View Full Code Here

        assertTrue(status.isSuccessful());
    }

    @Test
    public void testPackageAdditionRetrievalAndRemoval() throws Exception {
        ReplicationQueue queue = new SimpleReplicationQueue("agentName", "default");
        ReplicationQueueItem pkg = mock(ReplicationQueueItem.class);
        when(pkg.getId()).thenReturn("id");
        assertTrue(queue.add(pkg));
        assertFalse(queue.isEmpty());
        assertEquals(pkg, queue.getHead());
        assertFalse(queue.isEmpty());
        queue.remove(pkg.getId());
        assertTrue(queue.isEmpty());
        ReplicationQueueItemState status = queue.getStatus(pkg);
        assertNotNull(status);
        assertTrue(status.isSuccessful());
        assertEquals(1, status.getAttempts());
    }
View Full Code Here

public class SimpleReplicationQueueProviderTest {

    @Test
    public void testGetOrCreateQueue() throws Exception {
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider();
        ReplicationQueue queue = simpleReplicationQueueProvider.getInternalQueue("dummy-agent", "default");
        assertNotNull(queue);
    }
View Full Code Here

    }

    @Test
    public void testDeleteQueue() throws Exception {
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider();
        ReplicationQueue queue = mock(ReplicationQueue.class);
        simpleReplicationQueueProvider.deleteQueue(queue);
    }
View Full Code Here

        ReplicationAgent agent = request.getResource().adaptTo(ReplicationAgent.class);

        if (agent != null) {
            try {
                ReplicationQueue queue = agent.getQueue(queueName);
                response.getWriter().write(toJSoN(queue)); // TODO : use json writer
                response.setStatus(200);
            } catch (Exception e) {
                response.setStatus(400);
                response.getWriter().write("{\"status\" : \"error\",\"message\":\"error reading from the queue\",\"reason\":\""
View Full Code Here


    @Override
    protected void doDelete(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws ServletException, IOException {
        ReplicationQueue queue = request.getResource().adaptTo(ReplicationQueue.class);

        while (!queue.isEmpty()) {
            ReplicationQueueItem queueItem = queue.getHead();
            queue.remove(queueItem.getId());
        }
    }
View Full Code Here

TOP

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

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.