use of org.jmock.lib.action.ReturnValueAction in project sling by apache.
the class MockFactory method mockComponentContext.
public static ComponentContext mockComponentContext() {
Mockery context = new JUnit4Mockery();
final BundleContext bc = context.mock(BundleContext.class);
context.checking(new Expectations() {
{
allowing(bc).registerService(with(any(String.class)), with(any(Object.class)), with(any(Dictionary.class)));
will(VoidAction.INSTANCE);
allowing(bc).getProperty(with(any(String.class)));
will(new ReturnValueAction("foo"));
}
});
final ComponentContext cc = context.mock(ComponentContext.class);
context.checking(new Expectations() {
{
allowing(cc).getProperties();
will(returnValue(new Properties()));
allowing(cc).getBundleContext();
will(returnValue(bc));
}
});
return cc;
}
Aggregations