use of org.apache.sling.testing.resourceresolver.MockResourceResolverFactory in project sling by apache.
the class ResourceBuilderImplTest method setup.
@Before
public void setup() throws Exception {
when(mimeTypeService.getMimeType(anyString())).thenReturn("application/javascript");
resourceResolver = new MockResourceResolverFactory().getResourceResolver(null);
testRootPath = "/" + UUID.randomUUID().toString();
A = new ResourceAssertions(testRootPath, resourceResolver);
}
use of org.apache.sling.testing.resourceresolver.MockResourceResolverFactory in project sling by apache.
the class KryoContentSerializerTest method setUp.
@Before
public void setUp() throws Exception {
resourceResolver = new MockResourceResolverFactory().getResourceResolver(null);
MockHelper helper = MockHelper.create(resourceResolver).resource("/libs").p("prop", "value").resource("sub").p("sub", "hello").resource(".sameLevel").resource("/apps").p("foo", "baa");
helper.commit();
}
use of org.apache.sling.testing.resourceresolver.MockResourceResolverFactory in project sling by apache.
the class MergedResourceProviderTestForOverridingPicker method setup.
/*
* Tree is:
* /apps/a/1/a
* /apps/a/1/b
* /apps/a/1/b/1
* /apps/a/1/d
* /apps/a/1/d/1
* /apps/a/1/d/1/a
* /apps/a/1/d/1/b/1
* /apps/a/1/c
* /apps/a/2/c
* /apps/a/3
*
* /apps/a/2 has the super type of /apps/a/1
* /apps/a/3 has the super type of /apps/a/2
*
* /apps/a/4 has the super type of /apps/a/4/b/4
* /apps/x has the super type of x/y
*/
@Before
public void setup() throws Exception {
final MockResourceResolverFactoryOptions options = new MockResourceResolverFactoryOptions();
options.setSearchPaths(new String[] { "/apps", "/libs" });
final ResourceResolverFactory factory = new MockResourceResolverFactory(options);
this.resolver = factory.getAdministrativeResourceResolver(null);
MockHelper.create(this.resolver).resource("/apps").resource("a").resource("1").p("a", "1").p("b", "1").resource("a").p("1", "a").p("2", "b").resource(".b").p("1", "a").p("2", "b").resource("1").resource("/apps/a/1/d").p("a", "1").p("b", "2").resource("1").p("1", "a").p("2", "b").resource("a").resource("/apps/a/1/d/1/b").resource("1").resource("/apps/a/1/c").p("1", "a").p("2", "b").resource("/apps/a/2").p(SUPER_TYPE, "a/1").p("b", "2").p(MergedResourceConstants.PN_HIDE_CHILDREN, new String[] { "b" }).resource("c").p("1", "c").resource("/apps/a/3").p(SUPER_TYPE, "a/2").resource("/apps/a/4").p(SUPER_TYPE, "/apps/a/4/b/4").resource("b").resource("4").resource("d").resource("/apps/x").p(SUPER_TYPE, "x/y").resource("y").resource("z").commit();
this.provider = new MergingResourceProvider("/override", new OverridingResourcePicker(), false, true);
this.ctx = new BasicResolveContext(resolver);
}
use of org.apache.sling.testing.resourceresolver.MockResourceResolverFactory in project sling by apache.
the class CommonMergedResourceProviderTest method setup.
@Before
public void setup() throws LoginException, PersistenceException {
final ResourceResolverFactory factory = new MockResourceResolverFactory();
this.resolver = factory.getResourceResolver(null);
this.ctx = new BasicResolveContext<Void>(resolver);
MockHelper.create(this.resolver).resource("/apps").resource("base").resource("/apps/overlay").commit();
base = this.resolver.getResource("/apps/base");
overlay = this.resolver.getResource("/apps/overlay");
this.provider = new CRUDMergingResourceProvider("/merged", new SimpleMergedResourcePicker(), false);
}
use of org.apache.sling.testing.resourceresolver.MockResourceResolverFactory in project sling by apache.
the class DistributingEventHandlerTest method setup.
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
final BundleContext bc = Mockito.mock(BundleContext.class);
Mockito.when(bc.registerService(Mockito.any(String[].class), Mockito.any(), Mockito.any(Dictionary.class))).thenReturn(null);
final SlingSettingsService otherSettings = Mockito.mock(SlingSettingsService.class);
Mockito.when(otherSettings.getSlingId()).thenReturn(OTHER_APP_ID);
final EventAdmin ea = new EventAdmin() {
@Override
public void sendEvent(final Event event) {
this.postEvent(event);
}
@Override
public void postEvent(final Event event) {
final String topic = event.getTopic();
if (topic.equals(SlingConstants.TOPIC_RESOURCE_ADDED)) {
final ResourceChange change = new ResourceChange(ChangeType.ADDED, (String) event.getProperty(SlingConstants.PROPERTY_PATH), false, null, null, null);
sender.onChange(Collections.singletonList(change));
} else if (topic.startsWith(TOPIC_PREFIX)) {
events.add(event);
}
}
};
final MockResourceResolverFactoryOptions opts = new MockResourceResolverFactoryOptions();
opts.setEventAdmin(ea);
final ResourceResolverFactory factory = new MockResourceResolverFactory(opts);
this.sender = new DistributedEventSender(bc, DistributedEventAdminImpl.DEFAULT_REPOSITORY_PATH, DistributedEventAdminImpl.DEFAULT_REPOSITORY_PATH + "/" + MY_APP_ID, factory, ea);
this.receiver = new DistributedEventReceiver(bc, DistributedEventAdminImpl.DEFAULT_REPOSITORY_PATH, DistributedEventAdminImpl.DEFAULT_REPOSITORY_PATH + "/" + OTHER_APP_ID, 15, factory, otherSettings);
}
Aggregations