use of org.apache.sling.adapter.mock.MockAdapterFactory in project sling by apache.
the class AdapterManagerTest method createComponentContext.
/**
* Helper method to create a mock component context
*/
protected ComponentContext createComponentContext() throws Exception {
final BundleContext bundleCtx = this.context.mock(BundleContext.class);
final Filter filter = this.context.mock(Filter.class);
final ComponentContext ctx = this.context.mock(ComponentContext.class);
this.context.checking(new Expectations() {
{
allowing(ctx).locateService(with(any(String.class)), with(any(ServiceReference.class)));
will(returnValue(new MockAdapterFactory()));
allowing(ctx).getBundleContext();
will(returnValue(bundleCtx));
allowing(bundleCtx).createFilter(with(any(String.class)));
will(returnValue(filter));
allowing(bundleCtx).addServiceListener(with(any(ServiceListener.class)), with(any(String.class)));
allowing(bundleCtx).getServiceReferences(with(any(String.class)), with(any(String.class)));
will(returnValue(null));
allowing(bundleCtx).removeServiceListener(with(any(ServiceListener.class)));
allowing(bundleCtx).registerService(with(Adaption.class), with(AdaptionImpl.INSTANCE), with(any(Dictionary.class)));
will(returnValue(null));
}
});
return ctx;
}
Aggregations