Search in sources :

Example 1 with ProviderContext

use of org.apache.sling.spi.resource.provider.ProviderContext in project sling by apache.

the class JcrResourceListenerScalabilityTest method setUp.

@SuppressWarnings("deprecation")
@Before
public void setUp() throws RepositoryException, InvalidSyntaxException {
    ObservationManager observationManager = mock(ObservationManager.class);
    Workspace workspace = mock(Workspace.class);
    when(workspace.getObservationManager()).thenReturn(observationManager);
    Session session = mock(Session.class);
    when(session.getWorkspace()).thenReturn(workspace);
    SlingRepository repository = mock(SlingRepository.class);
    when(repository.loginAdministrative(null)).thenReturn(session);
    final ProviderContext ctx = new SimpleProviderContext();
    this.config = new JcrListenerBaseConfig(ctx.getObservationReporter(), RepositoryUtil.getRepository());
    jcrResourceListener = new JcrResourceListener(this.config, ctx.getObservationReporter().getObserverConfigurations().get(0));
    Event event = mock(MockEvent.class);
    events = mock(EventIterator.class);
    when(events.hasNext()).thenReturn(true);
    when(event.getPath()).thenCallRealMethod();
    when(event.getType()).thenReturn(Event.NODE_ADDED);
    when(events.nextEvent()).thenReturn(event);
}
Also used : SlingRepository(org.apache.sling.jcr.api.SlingRepository) ProviderContext(org.apache.sling.spi.resource.provider.ProviderContext) Event(javax.jcr.observation.Event) ObservationManager(javax.jcr.observation.ObservationManager) EventIterator(javax.jcr.observation.EventIterator) Workspace(javax.jcr.Workspace) Session(javax.jcr.Session) Before(org.junit.Before)

Aggregations

Session (javax.jcr.Session)1 Workspace (javax.jcr.Workspace)1 Event (javax.jcr.observation.Event)1 EventIterator (javax.jcr.observation.EventIterator)1 ObservationManager (javax.jcr.observation.ObservationManager)1 SlingRepository (org.apache.sling.jcr.api.SlingRepository)1 ProviderContext (org.apache.sling.spi.resource.provider.ProviderContext)1 Before (org.junit.Before)1