本文整理了Java中org.easymock.classextension.EasyMock.createMock()
方法的一些代码示例,展示了EasyMock.createMock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createMock()
方法的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
方法名:createMock
暂无
代码示例来源:origin: geoserver/geoserver
private CacheProvider addMockProvider(String name) {
CacheProvider provider = EasyMock.createMock(name, CacheProvider.class);
extensions.singleton(name, provider, CacheProvider.class);
return provider;
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testDoNothingUntilRun() {
Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
replay(log, desc, base);
LoggerRule rule = new LoggerRule(log, Level.FINE);
rule.apply(base, desc);
verify(log, desc, base);
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
protected void setUp() throws Exception {
offerDaoMock = EasyMock.createMock(OfferDao.class);
offerTimeZoneProcessorMock = EasyMock.createMock(OfferTimeZoneProcessor.class);
orderProcessor = new OrderOfferProcessorImpl();
orderProcessor.setOfferDao(offerDaoMock);
orderProcessor.setOfferTimeZoneProcessor(offerTimeZoneProcessorMock);
orderProcessor.setPromotableItemFactory(new PromotableItemFactoryImpl());
}
代码示例来源:origin: geoserver/geoserver
@Before
public void setUp() {
factory =
new GeoServerPropertyFactoryBean<String>(PROPERTY_NAME) {
@Override
protected String createInstance(String propertyValue) {
if (propertyValue.equals("UNKNOWN")) return null;
return "Bean: " + propertyValue;
}
@Override
public Class<?> getObjectType() {
return String.class;
}
};
ApplicationContext context = EasyMock.createMock(ApplicationContext.class);
EasyMock.replay(context);
factory.setApplicationContext(context);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testRecordsLogs() throws Throwable {
final Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
final Exception ex = new IllegalArgumentException();
final LogRecord record = createMock("record1", LogRecord.class);
代码示例来源:origin: geoserver/geoserver
@Test
public void testAssertPass() throws Throwable {
final Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
final Capture<Handler> handlerCap = new Capture<>();
final LogRecord record = createMock("record1", LogRecord.class);
代码示例来源:origin: geoserver/geoserver
@Test
public void testCleansUp() throws Throwable {
final Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
代码示例来源:origin: geoserver/geoserver
@Test
public void testAdapter() throws Throwable {
final Logger log = createMock("log", LoggerAdapter.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
final Capture<Handler> handlerCap = new Capture<>();
final LogRecord record = createMock("record1", LogRecord.class);
代码示例来源:origin: geoserver/geoserver
public MockCatalogBuilder layerGroup(
String name, List<String> layerNames, List<String> styleNames) {
final LayerGroupInfo lg = createMock(LayerGroupInfo.class);
layerGroups.add(lg);
代码示例来源:origin: geoserver/geoserver
@Test
public void testAssertFail() throws Throwable {
final Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
final Capture<Handler> handlerCap = new Capture<>();
final LogRecord record = createMock("record1", LogRecord.class);
代码示例来源:origin: geoserver/geoserver
@Test
public void testCleansUpAfterException() throws Throwable {
final Logger log = createMock("log", Logger.class);
Description desc = createMock("desc", Description.class);
Statement base = createMock("base", Statement.class);
代码示例来源:origin: geoserver/geoserver
@Test
public void testChangeNamespace() {
Catalog cat = createMock(Catalog.class);
cat.addListener((CatalogListener) anyObject());
expectLastCall();
WorkspaceInfo ws = createMock(WorkspaceInfo.class);
ws.setName("abcd");
expectLastCall();
expect(cat.getWorkspaceByName("gs")).andReturn(ws);
cat.save(ws);
expectLastCall();
NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class);
expect(e.getSource()).andReturn(ns).anyTimes();
expect(e.getPropertyNames()).andReturn(Arrays.asList("prefix"));
expect(e.getOldValues()).andReturn((List) Arrays.asList("gs"));
expect(e.getNewValues()).andReturn((List) Arrays.asList("abcd"));
replay(e, ws, ns, cat);
new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e);
verify(ws, cat);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testChangeWorkspace() {
Catalog cat = createMock(Catalog.class);
cat.addListener((CatalogListener) anyObject());
expectLastCall();
NamespaceInfo ns = createMock(NamespaceInfo.class);
ns.setPrefix("abcd");
expectLastCall();
expect(cat.getNamespaceByPrefix("gs")).andReturn(ns);
cat.save(ns);
expectLastCall();
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class);
expect(e.getSource()).andReturn(ws).anyTimes();
expect(e.getPropertyNames()).andReturn(Arrays.asList("name"));
expect(e.getOldValues()).andReturn((List) Arrays.asList("gs"));
expect(e.getNewValues()).andReturn((List) Arrays.asList("abcd"));
replay(e, ws, ns, cat);
new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e);
verify(ns, cat);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testRelativeToFeatureType() throws IOException {
GeoServerDataDirectory dd = createDataDirectoryMock();
replay(dd);
GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd);
Object source = tl.findTemplateSource("dummy.ftl");
assertNull(source);
reset(dd);
FeatureTypeInfo ft = createMock(FeatureTypeInfo.class);
expect(dd.findSuppResourceFile(ft, "dummy.ftl")).andReturn(new File("foo")).once();
replay(ft, dd);
tl.setFeatureType(ft);
source = tl.findTemplateSource("dummy.ftl");
assertNotNull(source);
verify(ft, dd);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testChangeDefaultWorkspace() {
Catalog cat = createMock(Catalog.class);
cat.addListener((CatalogListener) anyObject());
expectLastCall();
NamespaceInfo def = createNiceMock(NamespaceInfo.class);
expect(cat.getDefaultNamespace()).andReturn(def);
NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
expect(cat.getNamespaceByPrefix("abcd")).andReturn(ns);
cat.setDefaultNamespace(ns);
expectLastCall();
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
expect(ws.getName()).andReturn("abcd");
CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class);
expect(e.getSource()).andReturn(cat).anyTimes();
expect(e.getPropertyNames()).andReturn(Arrays.asList("defaultWorkspace"));
expect(e.getNewValues()).andReturn((List) Arrays.asList(ws));
replay(ns, ws, e, cat);
new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e);
verify(ns, ws, cat);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testChangeDefaultNamespace() {
Catalog cat = createMock(Catalog.class);
cat.addListener((CatalogListener) anyObject());
expectLastCall();
WorkspaceInfo def = createNiceMock(WorkspaceInfo.class);
expect(cat.getDefaultWorkspace()).andReturn(def);
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
expect(cat.getWorkspaceByName("abcd")).andReturn(ws);
cat.setDefaultWorkspace(ws);
expectLastCall();
NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
expect(ns.getPrefix()).andReturn("abcd");
CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class);
expect(e.getSource()).andReturn(cat).anyTimes();
expect(e.getPropertyNames()).andReturn(Arrays.asList("defaultNamespace"));
expect(e.getNewValues()).andReturn((List) Arrays.asList(ns));
replay(ns, ws, e, cat);
new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e);
verify(ns, ws, cat);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testChangeNamespaceURI() {
Catalog cat = createMock(Catalog.class);
cat.addListener((CatalogListener) anyObject());
expectLastCall();
NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
expect(ns.getPrefix()).andReturn("foo");
expect(ns.getURI()).andReturn("http://foo.org");
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
expect(cat.getWorkspaceByName("foo")).andReturn(ws);
DataStoreInfo ds = createNiceMock(DataStoreInfo.class);
expect(cat.getDataStoresByWorkspace(ws)).andReturn(Arrays.asList(ds));
HashMap params = new HashMap();
params.put("namespace", "http://bar.org");
expect(ds.getConnectionParameters()).andReturn(params).anyTimes();
cat.save(hasNamespace("http://foo.org"));
expectLastCall();
CatalogPostModifyEvent e = createNiceMock(CatalogPostModifyEvent.class);
expect(e.getSource()).andReturn(ns).anyTimes();
expect(ns.getPrefix()).andReturn("foo");
expect(cat.getWorkspaceByName("foo")).andReturn(ws);
replay(ds, ws, ns, e, cat);
new NamespaceWorkspaceConsistencyListener(cat).handlePostModifyEvent(e);
verify(cat);
}
代码示例来源:origin: geoserver/geoserver
public Catalog createCatalog(MockTestData testData) throws Exception {
GeoServerResourceLoader loader = createResourceLoader(testData);
final Catalog catalog = createMock(Catalog.class);
expect(catalog.getFactory()).andReturn(new CatalogFactoryImpl(catalog)).anyTimes();
expect(catalog.getResourceLoader()).andReturn(loader).anyTimes();
代码示例来源:origin: geotools/geotools
@Test
public void testExtendedZoomContext() throws Exception {
StringBuilder builder = new StringBuilder();
builder.append("grid:\n" + " name: SIGMA:957\n");
ZoomContextFinder finder = createMock("finder", ZoomContextFinder.class);
ZoomContext zctxt = createMock("zctxt", ZoomContext.class);
expect(finder.get("SIGMA:957")).andStubReturn(zctxt);
replay(finder, zctxt);
List<MarkedYAMLException> errors =
validate(builder.toString(), Collections.singletonList(finder));
assertThat(errors.size(), is(0));
verify(finder, zctxt);
}
代码示例来源:origin: geotools/geotools
@Test
public void testZoomContextEPSG4326IsBad() throws Exception {
StringBuilder builder = new StringBuilder();
builder.append("grid:\n" + " name: EPSG:4326\n");
ZoomContextFinder finder = createMock("finder", ZoomContextFinder.class);
ZoomContext zctxt = createMock("zctxt", ZoomContext.class);
expect(finder.get("EPSG:4326")).andStubReturn(zctxt);
replay(finder, zctxt);
List<MarkedYAMLException> errors =
validate(builder.toString(), Collections.singletonList(finder));
assertThat(errors.size(), is(1));
assertThat(errors.get(0).getProblemMark(), problemOn(2));
verify(finder, zctxt);
}
内容来源于网络,如有侵权,请联系作者删除!