use of org.jmock.integration.junit4.JUnit4Mockery in project intellij-community by JetBrains.
the class TabPostFormatProcessorTest method setUp.
@Before
public void setUp() {
myMockery = new JUnit4Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
myDocument = myMockery.mock(Document.class);
}
use of org.jmock.integration.junit4.JUnit4Mockery in project intellij-community by JetBrains.
the class PathMacroManagerTest method setupApplication.
@Before
public final void setupApplication() throws Exception {
context = new JUnit4Mockery();
context.setImposteriser(ClassImposteriser.INSTANCE);
myApplication = context.mock(ApplicationEx.class, "application");
context.checking(new Expectations() {
{
allowing(myApplication).isUnitTestMode();
will(returnValue(false));
allowing(myApplication).getName();
will(returnValue("IDEA"));
// some tests leave invokeLater()'s after them
allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class)));
allowing(myApplication).runReadAction(with(any(Runnable.class)));
will(new Action() {
@Override
public void describeTo(final Description description) {
description.appendText("runs runnable");
}
@Override
@Nullable
public Object invoke(final Invocation invocation) throws Throwable {
((Runnable) invocation.getParameter(0)).run();
return null;
}
});
}
});
final ExtensionsArea area = Extensions.getRootArea();
final String epName = PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME.getName();
if (!area.hasExtensionPoint(epName)) {
area.registerExtensionPoint(epName, "com.intellij.openapi.application.PathMacroFilter");
Disposer.register(myRootDisposable, new Disposable() {
@Override
public void dispose() {
area.unregisterExtensionPoint(epName);
}
});
}
}
use of org.jmock.integration.junit4.JUnit4Mockery 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;
}
Aggregations