use of org.jmock.integration.junit4.JUnit4Mockery in project gradle by gradle.
the class FilterTest method setUp.
protected void setUp() throws Exception {
JUnit4Mockery context = new JUnit4Mockery();
Task subsubCompileTask = TestUtility.createTask(context, "compile", "compile description");
Task subsubLibTask = TestUtility.createTask(context, "lib", "lib description");
Task subsubDocTask = TestUtility.createTask(context, "doc", "doc description");
Project subsubProject = TestUtility.createMockProject(context, "mysubsubproject", "filepath3", 2, null, new Task[] { subsubCompileTask, subsubLibTask, subsubDocTask }, null);
Task subCompileTask1 = TestUtility.createTask(context, "compile", "compile description");
Task subLibTask1 = TestUtility.createTask(context, "lib", "lib description");
Task subDocTask1 = TestUtility.createTask(context, "doc", "doc description");
Project subProject1 = TestUtility.createMockProject(context, "mysubproject1", "filepath2a", 1, new Project[] { subsubProject }, new Task[] { subCompileTask1, subLibTask1, subDocTask1 }, null);
Task subCompileTask2 = TestUtility.createTask(context, "compile", "compile description");
Task subLibTask2 = TestUtility.createTask(context, "lib", "lib description");
Task subDocTask2 = TestUtility.createTask(context, "doc", "doc description");
Project subProject2 = TestUtility.createMockProject(context, "mysubproject2", "filepath2b", 1, null, new Task[] { subCompileTask2, subLibTask2, subDocTask2 }, null);
Project rootProject = TestUtility.createMockProject(context, "myrootproject", "filepath1", 0, new Project[] { subProject1, subProject2 }, null, null);
buildInformation = new BuildInformation(rootProject);
//now get the converted objects to simplify our matching
myRootProject = buildInformation.getProjectFromFullPath("myrootproject");
assertNotNull(myRootProject);
mySubProject1 = buildInformation.getProjectFromFullPath("myrootproject:mysubproject1");
assertNotNull(mySubProject1);
mySubProject1Comple = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:compile");
assertNotNull(mySubProject1Comple);
mySubProject1Lib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:lib");
assertNotNull(mySubProject1Lib);
mySubProject1Doc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:doc");
assertNotNull(mySubProject1Doc);
mySubSubProject = buildInformation.getProjectFromFullPath("myrootproject:mysubproject1:mysubsubproject");
assertNotNull(mySubSubProject);
mySubSubProjectCompile = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:compile");
assertNotNull(mySubSubProjectCompile);
mySubSubProjectLib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:lib");
assertNotNull(mySubSubProjectLib);
mySubSubProjectDoc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject1:mysubsubproject:doc");
assertNotNull(mySubSubProjectDoc);
mySubProject2 = buildInformation.getProjectFromFullPath("myrootproject:mysubproject2");
assertNotNull(mySubProject2);
mySubProject2Compile = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:compile");
assertNotNull(mySubProject2Compile);
mySubProject2Lib = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:lib");
assertNotNull(mySubProject2Lib);
mySubProject2doc = buildInformation.getTaskFromFullPath("myrootproject:mysubproject2:doc");
assertNotNull(mySubProject2doc);
}
use of org.jmock.integration.junit4.JUnit4Mockery in project sling by apache.
the class MockFactory method mockSlingSettingsService.
public static SlingSettingsService mockSlingSettingsService(final String slingId) {
Mockery context = new JUnit4Mockery();
final SlingSettingsService settingsService = context.mock(SlingSettingsService.class);
context.checking(new Expectations() {
{
allowing(settingsService).getSlingId();
will(returnValue(slingId));
allowing(settingsService).getSlingHomePath();
will(returnValue("/n/a"));
}
});
return settingsService;
}
use of org.jmock.integration.junit4.JUnit4Mockery 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;
}
use of org.jmock.integration.junit4.JUnit4Mockery in project sling by apache.
the class VirtualInstance method startJetty.
public synchronized void startJetty() throws Throwable {
if (jettyServer != null) {
return;
}
servletContext = new ServletContextHandler(ServletContextHandler.NO_SECURITY);
servletContext.setContextPath("/");
TopologyConnectorServlet servlet = new TopologyConnectorServlet();
PrivateAccessor.setField(servlet, "config", config);
PrivateAccessor.setField(servlet, "clusterViewService", clusterViewService);
PrivateAccessor.setField(servlet, "announcementRegistry", announcementRegistry);
Mockery context = new JUnit4Mockery();
final HttpService httpService = context.mock(HttpService.class);
context.checking(new Expectations() {
{
allowing(httpService).registerServlet(with(any(String.class)), with(any(Servlet.class)), with(any(Dictionary.class)), with(any(HttpContext.class)));
}
});
PrivateAccessor.setField(servlet, "httpService", httpService);
ComponentContext cc = null;
PrivateAccessor.invoke(servlet, "activate", new Class[] { ComponentContext.class }, new Object[] { cc });
ServletHolder holder = new ServletHolder(servlet);
servletContext.addServlet(holder, "/system/console/topology/*");
jettyServer = new Server();
jettyServer.setHandler(servletContext);
Connector connector = new SelectChannelConnector();
jettyServer.setConnectors(new Connector[] { connector });
jettyServer.start();
}
use of org.jmock.integration.junit4.JUnit4Mockery in project motan by weibocom.
the class MockServiceConfig method setUp.
@Before
@Override
public void setUp() throws Exception {
mockery = new JUnit4Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
InetAddress address = NetUtils.getLocalAddress();
if (address != null) {
localAddress = address.getHostAddress();
}
}
Aggregations