use of org.apache.sling.distribution.trigger.DistributionRequestHandler in project sling by apache.
the class ChainDistributionTriggerTest method testUnregister.
@Test
public void testUnregister() throws Exception {
String pathPrefix = "/prefix";
BundleContext bundleContext = mock(BundleContext.class);
DistributionEventDistributeDistributionTrigger chainDistributeDistributionTrigger = new DistributionEventDistributeDistributionTrigger(pathPrefix, bundleContext);
DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
chainDistributeDistributionTrigger.unregister(handler);
}
use of org.apache.sling.distribution.trigger.DistributionRequestHandler in project sling by apache.
the class ChainDistributionTriggerTest method testRegister.
@Test
public void testRegister() throws Exception {
String pathPrefix = "/prefix";
BundleContext bundleContext = mock(BundleContext.class);
DistributionEventDistributeDistributionTrigger chainDistributeDistributionTrigger = new DistributionEventDistributeDistributionTrigger(pathPrefix, bundleContext);
DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
chainDistributeDistributionTrigger.register(handler);
}
use of org.apache.sling.distribution.trigger.DistributionRequestHandler in project sling by apache.
the class PersistingJcrEventDistributionTriggerTest method testProcessEventWithPrivilegesAndNoNuggetsNode.
@Test
public void testProcessEventWithPrivilegesAndNoNuggetsNode() throws Exception {
String nuggetsPath = "/var/nuggets";
String serviceName = "serviceId";
Session session = mock(Session.class);
// first time it doesn't exist and should be created
when(session.nodeExists("/var/nuggets")).thenReturn(false);
// second time it should exist
when(session.nodeExists("/var/nuggets")).thenReturn(true);
Node rootNode = mock(Node.class);
Node varNode = mock(Node.class);
Node nuggetsNode = mock(Node.class);
when(varNode.addNode("nuggets", "sling:Folder")).thenReturn(nuggetsNode);
when(rootNode.addNode("var", "sling:Folder")).thenReturn(varNode);
when(session.getRootNode()).thenReturn(rootNode);
Workspace workspace = mock(Workspace.class);
ObservationManager observationManager = mock(ObservationManager.class);
when(workspace.getObservationManager()).thenReturn(observationManager);
when(session.getWorkspace()).thenReturn(workspace);
when(session.hasPermission(any(String.class), eq(Session.ACTION_ADD_NODE))).thenReturn(true);
SlingRepository repository = mock(SlingRepository.class);
Scheduler scheduler = mock(Scheduler.class);
ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
when(repository.loginService(serviceName, null)).thenReturn(session);
String path = "/some/path";
PersistedJcrEventDistributionTrigger persistingJcrEventdistributionTrigger = new PersistedJcrEventDistributionTrigger(repository, scheduler, resolverFactory, path, serviceName, nuggetsPath);
DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
persistingJcrEventdistributionTrigger.register(handler);
Node eventNode = mock(Node.class);
when(nuggetsNode.addNode(any(String.class), any(String.class))).thenReturn(eventNode);
when(session.getNode(nuggetsPath)).thenReturn(nuggetsNode);
Event event = mock(Event.class);
when(event.getPath()).thenReturn("/some/path/generating/event");
DistributionRequest distributionRequest = persistingJcrEventdistributionTrigger.processEvent(event);
assertNotNull(distributionRequest);
}
use of org.apache.sling.distribution.trigger.DistributionRequestHandler in project sling by apache.
the class RemoteEventDistributionTriggerTest method testUnregister.
@Test
public void testUnregister() throws Exception {
String endpoint = "";
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
Scheduler scheduler = mock(Scheduler.class);
RemoteEventDistributionTrigger remoteEventdistributionTrigger = new RemoteEventDistributionTrigger(endpoint, distributionTransportSecretProvider, scheduler);
DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
remoteEventdistributionTrigger.unregister(handler);
}
use of org.apache.sling.distribution.trigger.DistributionRequestHandler in project sling by apache.
the class RemoteEventDistributionTriggerTest method testRegister.
@Test
public void testRegister() throws Exception {
DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
String endpoint = "";
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
Scheduler scheduler = mock(Scheduler.class);
ScheduleOptions options = mock(ScheduleOptions.class);
when(options.name(handler.toString())).thenReturn(options);
when(scheduler.NOW()).thenReturn(options);
RemoteEventDistributionTrigger remoteEventdistributionTrigger = new RemoteEventDistributionTrigger(endpoint, distributionTransportSecretProvider, scheduler);
remoteEventdistributionTrigger.register(handler);
}
Aggregations