use of org.jmock.Mockery in project geode by apache.
the class ClientHttpRequestJUnitTest method setUp.
@Before
public void setUp() {
mockContext = new Mockery();
mockContext.setImposteriser(ClassImposteriser.INSTANCE);
mockContext.setThreadingPolicy(new Synchroniser());
}
use of org.jmock.Mockery in project geode by apache.
the class PidFileJUnitTest method before.
@Before
public void before() {
mockContext = new Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
setThreadingPolicy(new Synchroniser());
}
};
this.futures = Executors.newFixedThreadPool(2);
}
use of org.jmock.Mockery in project geode by apache.
the class GfshCommandJUnitTest method setup.
@Before
public void setup() {
mockContext = new Mockery();
mockContext.setImposteriser(ClassImposteriser.INSTANCE);
mockContext.setThreadingPolicy(new Synchroniser());
defaultGfshCommmand = new DefaultGfshCommmand();
}
use of org.jmock.Mockery in project sling by apache.
the class RepositoryTestHelper method mockResourceResolverFactory.
public static ResourceResolverFactory mockResourceResolverFactory(final SlingRepository repositoryOrNull) throws Exception {
Mockery context = new JUnit4Mockery() {
{
// @see http://www.jmock.org/threading-synchroniser.html
setThreadingPolicy(new Synchroniser());
}
};
final ResourceResolverFactory resourceResolverFactory = context.mock(ResourceResolverFactory.class);
// final ResourceResolver resourceResolver = new MockResourceResolver();
// final ResourceResolver resourceResolver = new
// MockedResourceResolver();
context.checking(new Expectations() {
{
allowing(resourceResolverFactory).getServiceResourceResolver(null);
will(new Action() {
@Override
public Object invoke(Invocation invocation) throws Throwable {
return new MockedResourceResolver(repositoryOrNull);
}
@Override
public void describeTo(Description arg0) {
arg0.appendText("whateva - im going to create a new mockedresourceresolver");
}
});
}
});
return resourceResolverFactory;
}
use of org.jmock.Mockery in project sling by apache.
the class InitResourceTest method setup.
@Before
public void setup() throws Exception {
context = new Mockery();
req = context.mock(HttpServletRequest.class);
resp = context.mock(HttpServletResponse.class);
resourceResolver = context.mock(ResourceResolver.class);
context.checking(new Expectations() {
{
allowing(req).getRequestURL();
will(returnValue(new StringBuffer(requestURL)));
allowing(req).getRequestURI();
allowing(req).getPathInfo();
will(returnValue(pathInfo));
allowing(req).getServletPath();
will(returnValue("/"));
allowing(req).getMethod();
will(returnValue("GET"));
allowing(req).getAttribute(RequestData.REQUEST_RESOURCE_PATH_ATTR);
will(returnValue(null));
allowing(req).setAttribute(with(equal(RequestData.REQUEST_RESOURCE_PATH_ATTR)), with(any(Object.class)));
allowing(req).getAttribute(RequestProgressTracker.class.getName());
will(returnValue(null));
// Verify that the ResourceResolver is called with the expected path
allowing(resourceResolver).resolve(with(any(HttpServletRequest.class)), with(equal(expectedResolvePath)));
}
});
requestData = new RequestData(null, req, resp);
}
Aggregations