Package org.apache.sling.replication.communication

Examples of org.apache.sling.replication.communication.ReplicationRequest


            ByteBuffer buffer = ByteBuffer.allocate(1024);
            decoder.read(buffer);
            log.debug("content {} received {},{}", new Object[]{buffer, decoder, ioctrl});

            // TODO : currently it always triggers poll request on /, should this be configurable?
            ReplicationRequest replicationRequest = new ReplicationRequest(System.currentTimeMillis(), ReplicationActionType.POLL, "/");
            handler.handle(replicationRequest);
            log.info("replication request to agent {} sent ({} {})", new Object[]{
                    handler,
                    replicationRequest.getAction(),
                    replicationRequest.getPaths()});

            super.onContentReceived(decoder, ioctrl);
        }
View Full Code Here


    public static ReplicationRequest fromServletRequest(HttpServletRequest request) {
        String action = request.getParameter(ReplicationParameter.ACTION.toString());
        String[] paths = request.getParameterValues(ReplicationParameter.PATH.toString());

        return new ReplicationRequest(System.currentTimeMillis(),
                ReplicationActionType.fromName(action),
                paths);
    }
View Full Code Here

        VoidReplicationPackage replicationPackage = null;
        if (replicationActionType != null) {
            pathsString = Text.unescape(pathsString);
            String[] paths = pathsString.split(", ");

            ReplicationRequest request = new ReplicationRequest(Long.valueOf(timeString),
                    replicationActionType, paths);
            replicationPackage = new VoidReplicationPackage(request, typeString);
        }

        return replicationPackage;
View Full Code Here

    @Test
    public void testDummyExport() throws Exception {
        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
        LocalReplicationPackageExporter localReplicationPackageExporter = new LocalReplicationPackageExporter(packageBuilder);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);
        ReplicationRequest replicationRequest = mock(ReplicationRequest.class);
        List<ReplicationPackage> replicationPackages = localReplicationPackageExporter.exportPackages(resourceResolver, replicationRequest);
        assertNotNull(replicationPackages);
        assertTrue(replicationPackages.isEmpty());
    }
View Full Code Here

        String[] endpoints = new String[0];
        for (TransportEndpointStrategyType strategy : TransportEndpointStrategyType.values()) {
            RemoteReplicationPackageExporter remoteReplicationPackageExporter = new RemoteReplicationPackageExporter(
                    packageBuilder, authProvider, endpoints, strategy.name(), 1);
            ResourceResolver resourceResolver = mock(ResourceResolver.class);
            ReplicationRequest replicationRequest = mock(ReplicationRequest.class);
            List<ReplicationPackage> replicationPackages = remoteReplicationPackageExporter.exportPackages(resourceResolver, replicationRequest);
            assertNotNull(replicationPackages);
            assertTrue(replicationPackages.isEmpty());
        }
    }
View Full Code Here

    public void testCreatePackage() throws Exception {
        VoidReplicationPackageBuilder voidReplicationPackageBuilder = new VoidReplicationPackageBuilder();
        ResourceResolver resourceResolver = mock(ResourceResolver.class);
        String[] paths = new String[0];
        for (ReplicationActionType action : ReplicationActionType.values()) {
            ReplicationRequest request = mock(ReplicationRequest.class);
            when(request.getAction()).thenReturn(action);
            when(request.getPaths()).thenReturn(paths);
            when(request.getTime()).thenReturn(System.currentTimeMillis());
            ReplicationPackage replicationPackage = voidReplicationPackageBuilder.createPackage(resourceResolver, request);
            assertNotNull(replicationPackage);
        }
    }
View Full Code Here

    @Test
    public void testReadPackageWithValidStream() throws Exception {
        VoidReplicationPackageBuilder voidReplicationPackageBuilder = new VoidReplicationPackageBuilder();
        ResourceResolver resourceResolver = mock(ResourceResolver.class);
        for (ReplicationActionType action : ReplicationActionType.values()) {
            ReplicationRequest request = new ReplicationRequest(action, new String[]{"/"});
            InputStream stream = new VoidReplicationPackage(request).createInputStream();
            ReplicationPackage replicationPackage = voidReplicationPackageBuilder.readPackage(resourceResolver, stream);
            assertNotNull(replicationPackage);
        }
    }
View Full Code Here

    @Test
    public void testGetMatchingIdPackage() throws Exception {
        VoidReplicationPackageBuilder voidReplicationPackageBuilder = new VoidReplicationPackageBuilder();
        ResourceResolver resourceResolver = mock(ResourceResolver.class);
        String id = new VoidReplicationPackage(new ReplicationRequest(ReplicationActionType.DELETE, new String[]{"/"})).getId();
        ReplicationPackage replicationPackage = voidReplicationPackageBuilder.getPackage(resourceResolver, id);
        assertNotNull(replicationPackage);
    }
View Full Code Here

*/
public class VoidReplicationPackageTest {

    @Test
    public void testCreatedAndReadPackagesEquality() throws Exception {
        ReplicationRequest request = new ReplicationRequest(123l, ReplicationActionType.DELETE, "/abc");
        VoidReplicationPackage createdPackage = new VoidReplicationPackage(request);
        VoidReplicationPackage readPackage = VoidReplicationPackage.fromStream(new ByteArrayInputStream("DELETE:/abc:123:VOID".getBytes()));
        assertEquals(createdPackage.getId(), readPackage.getId());
        assertEquals(createdPackage.getAction(), readPackage.getAction());
        assertEquals(createdPackage.getType(), readPackage.getType());
View Full Code Here

        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[]{"/"});
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.communication.ReplicationRequest

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.