本文整理了Java中org.easymock.classextension.EasyMock
类的一些代码示例,展示了EasyMock
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock
类的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
[英]This class is provided solely to allow an easier transition to EasyMock 3.0. You should now use org.easymock.EasyMock for classes and interfaces mocking.
Note: Since the static methods previously available were removed from this class (and are now in the superclass), no binary compatibility is provided
[中]提供此类只是为了更容易地过渡到EasyMock 3.0。您现在应该使用org。easymock。EasyMock用于类和接口模拟。
注意:由于以前可用的静态方法已从此类中删除(现在在超类中),因此不提供二进制兼容性
代码示例来源: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);
expect(log.getLevel()).andReturn(Level.OFF);
log.setLevel(Level.FINE);
expectLastCall().once();
final Capture<Handler> handlerCap = new Capture<>();
final Exception ex = new IllegalArgumentException();
final LogRecord record = createMock("record1", LogRecord.class);
log.addHandler(capture(handlerCap));
expectLastCall().once();
base.evaluate();
expectLastCall()
replay(log, desc, base);
LoggerRule rule = new LoggerRule(log, Level.FINE);
Statement s = rule.apply(base, desc);
verify(log, desc, base);
代码示例来源:origin: geoserver/geoserver
@Test
public void testRasterStyle() throws Exception {
ResourcePool rp = createNiceMock(ResourcePool.class);
rp.writeStyle((StyleInfo) anyObject(), (InputStream) anyObject());
expectLastCall()
.andAnswer(
new IAnswer<Void>() {
Catalog cat = createNiceMock(Catalog.class);
expect(cat.getFactory()).andReturn(new CatalogFactoryImpl(null)).anyTimes();
expect(cat.getResourcePool()).andReturn(rp).anyTimes();
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
CoverageInfo ci = createNiceMock(CoverageInfo.class);
expect(ci.getName()).andReturn("foo").anyTimes();
replay(rp, ci, 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: BroadleafCommerce/BroadleafCommerce
public void replay() {
EasyMock.expect(offerTimeZoneProcessorMock.getTimeZone(EasyMock.isA(OfferImpl.class))).andReturn(TimeZone.getTimeZone("CST")).anyTimes();
EasyMock.replay(offerDaoMock);
EasyMock.replay(offerTimeZoneProcessorMock);
}
代码示例来源:origin: geoserver/geoserver
@Override
public Void answer() throws Throwable {
verify(log);
reset(log);
log.removeHandler(handlerCap.getValue());
expectLastCall().once();
log.setLevel(Level.OFF);
expectLastCall().once();
replay(log);
throw ex;
}
});
代码示例来源: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: 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: geoserver/geoserver
@SuppressWarnings("unchecked")
@Test
public void testFindTwoInContext() {
CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1");
CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2");
replay(testCacheProvider1, testCacheProvider2);
CacheProvider provider = DefaultCacheProvider.findProvider();
assertThat(
provider,
anyOf(sameInstance(testCacheProvider1), sameInstance(testCacheProvider2)));
String providerName = "testCacheProvider2";
if (provider == testCacheProvider1) {
providerName = "testCacheProvider1";
}
logging.assertLogged(
allOf(
hasProperty("level", is(Level.WARNING)),
hasProperty(
"parameters",
arrayContainingInAnyOrder(
// Name of the provider being used
equalTo(providerName),
// Available providers
anyOf(
equalTo("testCacheProvider1, testCacheProvider2"),
equalTo("testCacheProvider2, testCacheProvider1")),
// The system property to override
equalTo("GEOSERVER_DEFAULT_CACHE_PROVIDER")))));
verify(testCacheProvider1, testCacheProvider2);
}
代码示例来源:origin: geotools/geotools
@Test
public void testRelativeExternalGraphicWithResolver() throws Exception {
String yaml =
"feature-styles:\n"
+ "- name: name\n"
+ " rules:\n"
+ " - symbolizers:\n"
+ " - point:\n"
+ " size: 32\n"
+ " symbols:\n"
+ " - external:\n"
+ " url: smileyface.png\n"
+ " format: image/png\n";
ResourceLocator locator = EasyMock.createMock(ResourceLocator.class);
expect(locator.locateResource("smileyface.png"))
.andReturn(new URL("http://itworked/smileyface.png"));
replay(locator);
StyledLayerDescriptor sld =
Ysld.parse(yaml, Collections.<ZoomContextFinder>emptyList(), locator);
PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
assertThat(p.getGraphic().graphicalSymbols().get(0), instanceOf(ExternalGraphic.class));
ExternalGraphic eg = (ExternalGraphic) p.getGraphic().graphicalSymbols().get(0);
assertThat(eg.getLocation(), equalTo(new URL("http://itworked/smileyface.png")));
assertThat(
eg.getOnlineResource().getLinkage(),
equalTo(new URI("http://itworked/smileyface.png")));
verify(locator);
}
代码示例来源:origin: geotools/geotools
@SuppressWarnings("unchecked")
@Test
public void testNamedWithFinder() throws IOException {
String yaml =
"grid:\n"
+ " name: test\n"
+ "feature-styles: \n"
+ "- name: name\n"
+ " rules:\n"
+ " - zoom: "
+ tuple(0, 0);
ZoomContextFinder finder = createMock(ZoomContextFinder.class);
ZoomContext context = createMock(ZoomContext.class);
expect(finder.get("test")).andReturn(context);
expect(context.getRange(0, 0)).andReturn(new ScaleRange(42, 64));
replay(finder, context);
StyledLayerDescriptor sld = Ysld.parse(yaml, Arrays.asList(finder), (ResourceLocator) null);
FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
fs.rules().get(0).getMaxScaleDenominator();
assertThat(
(Iterable<Rule>) fs.rules(),
hasItems(
allOf(
Matchers.<Rule>hasProperty(
"maxScaleDenominator", Matchers.closeTo(64, 0.0000001d)),
Matchers.<Rule>hasProperty(
"minScaleDenominator", Matchers.closeTo(42, 0.0000001d)))));
verify(finder, context);
}
代码示例来源:origin: geoserver/geoserver
protected GeoServerUserGroupStore createUserGroupStore(
String name, GeoServerSecurityManager secMgr) throws IOException {
GeoServerUserGroupStore ugStore = createNiceMock(GeoServerUserGroupStore.class);
expect(ugStore.getName()).andReturn(name).anyTimes();
expect(secMgr.loadUserGroupService(name)).andReturn(ugStore).anyTimes();
return ugStore;
}
代码示例来源:origin: geoserver/geoserver
@Override
public Void answer() throws Throwable {
verify(log);
reset(log);
log.removeHandler(handlerCap.getValue());
expectLastCall().once();
log.setLevel(Level.OFF);
expectLastCall().once();
replay(log);
handlerCap.getValue().publish(record);
((LoggerRule) handlerCap.getValue())
.assertLogged(sameInstance(record));
((LoggerRule) handlerCap.getValue()).assertLogged(not(anything()));
return null;
}
});
代码示例来源:origin: org.geoserver.security/gs-security-tests
Request request = org.easymock.classextension.EasyMock.createNiceMock(Request.class);
org.easymock.classextension.EasyMock.expect(request.getRequest())
.andReturn("GetFeatures")
.anyTimes();
org.easymock.classextension.EasyMock.replay(request);
Dispatcher.REQUEST.set(request);
request = org.easymock.classextension.EasyMock.createNiceMock(Request.class);
org.easymock.classextension.EasyMock.expect(request.getRequest())
.andReturn("GetCapabilities")
.anyTimes();
org.easymock.classextension.EasyMock.replay(request);
Dispatcher.REQUEST.set(request);
sc.getFeatureTypes(),
sc.list(FeatureTypeInfo.class, Predicates.acceptAll()),
empty());
assertThatBoth(
sc.getCoverages(), sc.list(CoverageInfo.class, Predicates.acceptAll()), empty());
assertThatBoth(
sc.getWorkspaces(), sc.list(WorkspaceInfo.class, Predicates.acceptAll()), empty());
代码示例来源:origin: geoserver/geoserver
String nsId = newId();
final WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
workspaces.add(ws);
expect(ws.getId()).andReturn(wsId).anyTimes();
expect(ws.getName()).andReturn(name).anyTimes();
expect(ws.getMetadata()).andReturn(new MetadataMap()).anyTimes();
expect(catalog.getWorkspace(wsId)).andReturn(ws).anyTimes();
expect(catalog.getWorkspaceByName(name)).andReturn(ws).anyTimes();
final NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
namespaces.add(ns);
expect(ns.getURI()).andReturn(uri).anyTimes();
expect(catalog.getNamespace(nsId)).andReturn(ns).anyTimes();
expect(catalog.getNamespaceByPrefix(name)).andReturn(ns).anyTimes();
expect(catalog.getNamespaceByURI(uri)).andReturn(ns).anyTimes();
replay(ws, ns);
return this;
代码示例来源:origin: geoserver/geoserver
NamespaceInfo ns = namespaces.peekLast();
final FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class);
featureTypes.add(ft);
latLonEnvelope);
expect(ft.getNumDecimals()).andReturn(8);
expect(ft.getFeatureType())
.andAnswer(
new IAnswer<FeatureType>() {
@Override
expect(catalog.getFeatureTypeByName(or(eq(name), eq(ns.getPrefix() + ":" + name))))
.andReturn(ft)
.anyTimes();
.andReturn(ft)
.anyTimes();
expect(catalog.getFeatureTypeByName(ns, name)).andReturn(ft).anyTimes();
expect(catalog.getFeatureTypeByName(ns.getPrefix(), name)).andReturn(ft).anyTimes();
replay(ft, createLayer(ft, name, ns));
return this;
代码示例来源:origin: geoserver/geoserver
final CoverageInfo c = createNiceMock(CoverageInfo.class);
coverages.add(c);
final List<CoverageInfo> coverageList = coverages;
real.getLatLonBoundingBox());
expect(c.getDefaultInterpolationMethod())
.andReturn(real.getDefaultInterpolationMethod())
.anyTimes();
expect(c.getDimensions()).andReturn(real.getDimensions()).anyTimes();
expect(c.getGrid()).andReturn(real.getGrid()).anyTimes();
expect(c.getInterpolationMethods()).andReturn(real.getInterpolationMethods()).anyTimes();
.andReturn(c)
.anyTimes();
expect(catalog.getCoverageByName(ns, name)).andReturn(c).anyTimes();
expect(catalog.getCoverageByName(ns.getPrefix(), name)).andReturn(c).anyTimes();
replay(c, createLayer(c, name, ns));
return this;
代码示例来源:origin: geoserver/geoserver
StyleInfo s = styles.peekLast();
final LayerInfo l = createNiceMock(LayerInfo.class);
layers.add(l);
expect(l.getId()).andReturn(lId).anyTimes();
expect(l.getName()).andReturn(name).anyTimes();
expect(l.getType()).andReturn(PublishedType.VECTOR).anyTimes();
expect(l.getResource()).andReturn(r).anyTimes();
expect(l.getDefaultStyle()).andReturn(s).anyTimes();
expect(l.isAdvertised()).andReturn(true).anyTimes();
expect(catalog.getLayer(lId)).andReturn(l).anyTimes();
expect(catalog.getLayerByName(name)).andReturn(l).anyTimes();
expect(catalog.getLayerByName(ns.getPrefix() + ":" + name)).andReturn(l).anyTimes();
expect(catalog.getLayerByName(new NameImpl(ns.getPrefix(), name))).andReturn(l).anyTimes();
expect(catalog.getLayerByName(new NameImpl(ns.getURI(), name))).andReturn(l).anyTimes();
代码示例来源: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();
catalog.removeListeners((Class) EasyMock.anyObject());
expectLastCall().anyTimes();
代码示例来源:origin: geoserver/geoserver
Version version = SLDHandler.VERSION_10;
final StyleInfo s = createNiceMock(StyleInfo.class);
styles.add(s);
expect(s.getId()).andReturn(sId);
expect(s.getName()).andReturn(name).anyTimes();
expect(s.getFilename()).andReturn(filename).anyTimes();
expect(s.getSLDVersion()).andReturn(version).anyTimes();
try {
expect(catalog.getStyle(sId)).andReturn(s).anyTimes();
expect(catalog.getStyleByName(name)).andReturn(s).anyTimes();
s.accept((CatalogVisitor) anyObject());
replay(s);
return this;
代码示例来源:origin: geotools/geotools
@Test
public void testDocHints() throws Exception {
YamlParseContext ctxt = new YamlParseContext();
YamlParseHandler handler = createMock(YamlParseHandler.class);
YamlObject obj1 = createMock(YamlObject.class);
replay(handler);
ctxt.push(obj1, handler);
assertThat(ctxt.getDocHint("testHint1"), nullValue());
ctxt.setDocHint("testHint1", "th1v1");
assertThat((String) ctxt.getDocHint("testHint1"), is("th1v1"));
ctxt.setDocHint("testHint1", "th1v2");
assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));
assertThat(ctxt.getDocHint("testHint2"), nullValue());
ctxt.setDocHint("testHint2", "th2v1");
assertThat((String) ctxt.getDocHint("testHint2"), is("th2v1"));
assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));
verify(handler);
}
}
内容来源于网络,如有侵权,请联系作者删除!