本文整理了Java中org.easymock.classextension.EasyMock.createStrictMock()
方法的一些代码示例,展示了EasyMock.createStrictMock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createStrictMock()
方法的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
方法名:createStrictMock
暂无
代码示例来源:origin: org.seasar.container/s2-tiger
public <T> T createStrictMock(final Class<T> clazz) {
return EasyMock.createStrictMock(clazz);
}
代码示例来源:origin: com.googlecode.junice/junice
/**
* {@inheritDoc}
*/
public <T> T createMock(Class<T> cls, MockObjType type) {
switch (type) {
case EASY_MOCK_NICE:
return EasyMock.createNiceMock(cls);
case EASY_MOCK_STRICT:
return EasyMock.createStrictMock(cls);
case EASY_MOCK_NORMAL:
case DEFAULT:
return EasyMock.createMock(cls);
default:
throw new IllegalArgumentException("Unsupported mock type '"
+ type
+ "' for Easy-Mock Framework." );
}
}
代码示例来源:origin: info.magnolia/magnolia-core
final String newVersion = "2.3.4";
final InstallContextImpl ctx = createStrictMock(InstallContextImpl.class);
final ModuleDefinition mod = new ModuleDefinition("foo", Version.parseVersion(newVersion), null, null);
final Content allModulesNode = createStrictMock(Content.class);
final Content moduleNode = createStrictMock(Content.class);
final NodeData versionProp = createStrictMock(NodeData.class);
final Delta d1 = createStrictMock(Delta.class);
final Delta d2 = createStrictMock(Delta.class);
final Task t1 = createStrictMock(Task.class);
final Task t2 = createStrictMock(Task.class);
final Task t3 = createStrictMock(Task.class);
final Task t4 = createStrictMock(Task.class);
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testFailedConditionsPreventsFurtherModulesToBeInstalledOrUpdated() throws TaskExecutionException, ModuleManagementException {
final ModuleDefinitionReader modDefReader = createStrictMock(ModuleDefinitionReader.class);
final InstallContextImpl ctx = createStrictMock(InstallContextImpl.class);
final ModuleVersionHandler mvh1 = createStrictMock(ModuleVersionHandler.class);
final ModuleVersionHandler mvh2 = createStrictMock(ModuleVersionHandler.class);
final Delta d1 = createStrictMock(Delta.class);
final Delta d2 = createStrictMock(Delta.class);
final Condition c1 = createStrictMock(Condition.class);
final Condition c2 = createStrictMock(Condition.class);
final Condition c3 = createStrictMock(Condition.class);
final Task t1 = createStrictMock(Task.class);
final Task t2 = createStrictMock(Task.class);
final ModuleDefinition mod1 = new ModuleDefinition("abc", Version.parseVersion("2.3.4"), null, null);
final ModuleDefinition mod2 = new ModuleDefinition("xyz", Version.parseVersion("2.3.4"), null, null);
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testPerformCantBeCalledTwiceByDifferentThreads() throws Exception {
final ModuleDefinitionReader modDefReader = createStrictMock(ModuleDefinitionReader.class);
final InstallContextImpl ctx = new InstallContextImpl(moduleRegistry);
final ModuleVersionHandler mvh1 = createStrictMock(ModuleVersionHandler.class);
final ModuleVersionHandler mvh2 = createStrictMock(ModuleVersionHandler.class);
final Task t1 = new AbstractTask("sleep", "sleeeeep") {
@Override
final Task t2 = createStrictMock(Task.class);
final Delta d1 = DeltaBuilder.update(Version.parseVersion("1.0"), "", t1);
final Delta d2 = DeltaBuilder.update(Version.parseVersion("2.0"), "", t2);
代码示例来源:origin: info.magnolia/magnolia-core
@Before
public void setUp() throws Exception {
ComponentsTestUtil.setInstance(SystemContext.class, createStrictMock(SystemContext.class));
super.setUp();
moduleRegistry = Components.getComponent(ModuleRegistry.class);
repositoryManager = Components.getComponent(RepositoryManager.class);
ComponentsTestUtil.setInstance(VersionManager.class, new VersionManager(Components.getComponent(SystemContext.class), Components.getComponent(RepositoryManager.class), Components.getComponent(CopyUtil.class)));
moduleDefinitionReader = mock(ModuleDefinitionReader.class);
context = mock(InstallContextImpl.class);
websiteSession = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
given(context.getJCRSession(anyString())).willAnswer(new Answer<Session>() {
@Override
public Session answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[0].toString().equals(RepositoryConstants.WEBSITE) ? websiteSession : mock(Session.class);
}
});
ModuleVersionHandler moduleVersionHandler = mock(ModuleVersionHandler.class);
delta = mock(Delta.class);
Task task = new CreateNodeTask("", "", RepositoryConstants.WEBSITE, "/", "test", NodeTypes.ContentNode.NAME);
given(delta.getTasks()).willReturn(newArrayList(task));
moduleDefinition = new ModuleDefinition("website", Version.parseVersion("2.3.4"), null, null);
moduleVersionHandlers = newHashMap();
moduleVersionHandlers.put("abc", moduleVersionHandler);
TestUtil.shuntLog();
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testTaskExecutionExceptionInterruptsTasksAddsExplicitErrorMessage() throws RepositoryException, TaskExecutionException {
final ModuleDefinition mod = new ModuleDefinition("foo", Version.parseVersion("2.3.4"), null, null);
final InstallContextImpl ctx = createStrictMock(InstallContextImpl.class);
final Delta d1 = createStrictMock(Delta.class);
final Task t1 = createStrictMock(Task.class);
final Task t2 = createStrictMock(Task.class);
ctx.setCurrentModule(mod);
expect(d1.getTasks()).andReturn(Arrays.asList(t1, t2));
t1.execute(ctx);
expectLastCall().andThrow(new TaskExecutionException("boo"));
expect(t1.getName()).andReturn("task#1").anyTimes();
ctx.error(eq("Could not install or update foo module. Task 'task#1' failed. (TaskExecutionException: boo)"), isA(TaskExecutionException.class));
ctx.setCurrentModule(null);
expect(ctx.getJCRSession(anyObject())).andAnswer(new IAnswer<Session>() {
public Session answer() throws Throwable {
return repositoryManager.getSystemSession(getCurrentArguments()[0].toString());
}
}).anyTimes();
replay(ctx, d1, t1, t2);
final ModuleManager.ModuleAndDeltas moduleAndDeltas = new ModuleManager.ModuleAndDeltas(mod, Version.parseVersion("1.2.3"), Arrays.asList(d1));
new ModuleManagerImpl(ctx, Sets.newHashSet(new BetwixtModuleDefinitionReader()), moduleRegistry, new DependencyCheckerImpl(), new Node2BeanProcessorImpl(new TypeMappingImpl(), new Node2BeanTransformerImpl(new PreConfiguredBeanUtils())), repositoryManager).installOrUpdateModule(moduleAndDeltas, ctx);
verify(ctx, d1, t1, t2);
}
代码示例来源:origin: info.magnolia/magnolia-module-templating
public void testSetsJspPageContext() throws Exception {
final ParagraphRendererManager prm = new ParagraphRendererManager();
prm.onRegister(getNode(CONFIGNODE1_RENDERER, "/modules/test/paragraph-renderers"));
final ParagraphRenderingFacade prf = new ParagraphRenderingFacade(prm, null);
final Paragraph tra = new Paragraph();
tra.setName("para-one");
tra.setType("foo");
final StringWriter res = new StringWriter();
PageContext pageContext = createMock(PageContext.class);
WebContext webContext = createStrictMock(WebContext.class);
webContext.setPageContext(pageContext);
replay(pageContext, webContext);
MgnlContext.setInstance(webContext);
prf.render(null, tra, res, pageContext);
verify(pageContext, webContext);
assertEquals("tralala:para-one", res.toString());
}
内容来源于网络,如有侵权,请联系作者删除!