use of org.jmock.Mockery in project sling by apache.
the class ClientAbortExceptionTest method setup.
@Before
public void setup() throws IOException {
context = new Mockery();
final ServletOutputStream sos = new ServletOutputStream() {
@Override
public void write(int b) throws IOException {
throw new IOException("Always fails, on purpose");
}
@Override
public void flush() throws IOException {
throw new IOException("Always fails, on purpose");
}
@Override
public void close() throws IOException {
throw new IOException("Always fails, on purpose");
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setWriteListener(WriteListener writeListener) {
}
};
final HttpServletResponse raw = context.mock(HttpServletResponse.class);
context.checking(new Expectations() {
{
allowing(raw).getOutputStream();
will(returnValue(sos));
}
});
r = new RequestLoggerResponse(raw);
}
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 gocd by gocd.
the class BackgroundEmailSenderTest method setUp.
@Before
public void setUp() {
mockery = new Mockery();
sender = mockery.mock(GoMailSender.class);
}
use of org.jmock.Mockery in project gocd by gocd.
the class AntTaskDetectorTest method setUp.
@Before
public void setUp() {
context = new Mockery();
reporter = context.mock(Reporter.class);
detector = new AntTaskDetector(reporter);
}
use of org.jmock.Mockery in project gocd by gocd.
the class AntTestFailureDetectorTest method setUp.
@Before
public void setUp() {
context = new Mockery();
reporter = context.mock(Reporter.class);
detector = new AntTestFailureDetector(reporter);
}
Aggregations