本文整理了Java中org.easymock.classextension.EasyMock.createNiceMock()
方法的一些代码示例,展示了EasyMock.createNiceMock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.createNiceMock()
方法的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
方法名:createNiceMock
暂无
代码示例来源:origin: geoserver/geoserver
public MockCatalogBuilder(Catalog catalog, File dataDirRoot) {
this.catalog = catalog;
this.dataDirRoot = dataDirRoot;
this.callback = createNiceMock(Callback.class);
}
代码示例来源: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
GeoServerDataDirectory createDataDirectoryMock() {
GeoServerDataDirectory dd = createNiceMock(GeoServerDataDirectory.class);
expect(dd.root()).andReturn(root).anyTimes();
return dd;
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testCreateInWorkspace() throws Exception {
ResourcePool rp = createNiceMock(ResourcePool.class);
Catalog cat = createNiceMock(Catalog.class);
expect(cat.getFactory()).andReturn(new CatalogFactoryImpl(null)).anyTimes();
expect(cat.getResourcePool()).andReturn(rp).anyTimes();
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class);
expect(ft.getName()).andReturn("foo").anyTimes();
replay(rp, ft, ws, cat);
StyleGenerator gen = new StyleGenerator(cat);
gen.setWorkspace(ws);
SimpleFeatureType schema = DataUtilities.createType("foo", "geom:Point");
StyleInfo style = gen.createStyle(new SLDHandler(), ft, schema);
assertNotNull(style);
assertNotNull(style.getWorkspace());
}
代码示例来源:origin: geoserver/geoserver
protected GeoServerRoleStore createRoleStore(
String name, GeoServerSecurityManager secMgr, String... roleNames) throws IOException {
GeoServerRoleStore roleStore = createNiceMock(GeoServerRoleStore.class);
expect(roleStore.getSecurityManager()).andReturn(secMgr).anyTimes();
expect(roleStore.getName()).andReturn(name).anyTimes();
for (String roleName : roleNames) {
expect(roleStore.getRoleByName(roleName))
.andReturn(new GeoServerRole(roleName))
.anyTimes();
}
for (GeoServerRole role : GeoServerRole.SystemRoles) {
String roleName = role.getAuthority();
expect(roleStore.createRoleObject(roleName))
.andReturn(new GeoServerRole(roleName))
.anyTimes();
}
expect(secMgr.loadRoleService(name)).andReturn(roleStore).anyTimes();
return roleStore;
}
代码示例来源: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 testGlobal() throws IOException {
GeoServerDataDirectory dd = createDataDirectoryMock();
DataStoreInfo s = createNiceMock(DataStoreInfo.class);
FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class);
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
expect(ft.getStore()).andReturn(s).anyTimes();
expect(s.getWorkspace()).andReturn(ws).anyTimes();
replay(ft, s, ws, dd);
GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd);
tl.setResource(ft);
assertNull(tl.findTemplateSource("dummy.ftl"));
reset(dd);
expect(dd.findSuppWorkspacesFile(ws, "dummy.ftl")).andReturn(new File("foo")).once();
replay(dd);
assertNotNull(tl.findTemplateSource("dummy.ftl"));
verify(dd);
}
代码示例来源: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
@Test
public void testRelativeToWorkspace() throws IOException {
GeoServerDataDirectory dd = createDataDirectoryMock();
DataStoreInfo s = createNiceMock(DataStoreInfo.class);
FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class);
WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
expect(ft.getStore()).andReturn(s).anyTimes();
expect(s.getWorkspace()).andReturn(ws).anyTimes();
replay(ft, s, ws, dd);
GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd);
tl.setFeatureType(ft);
Object source = tl.findTemplateSource("dummy.ftl");
assertNull(source);
reset(dd);
expect(dd.findSuppWorkspaceFile(ws, "dummy.ftl")).andReturn(new File("foo")).once();
replay(dd);
assertNotNull(tl.findTemplateSource("dummy.ftl"));
verify(dd);
}
代码示例来源:origin: geoserver/geoserver
Version version = SLDHandler.VERSION_10;
final StyleInfo s = createNiceMock(StyleInfo.class);
styles.add(s);
代码示例来源:origin: geoserver/geoserver
StyleInfo s = styles.peekLast();
final LayerInfo l = createNiceMock(LayerInfo.class);
layers.add(l);
代码示例来源:origin: geoserver/geoserver
String nsId = newId();
final WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class);
workspaces.add(ws);
expect(ws.getId()).andReturn(wsId).anyTimes();
expect(catalog.getWorkspaceByName(name)).andReturn(ws).anyTimes();
final NamespaceInfo ns = createNiceMock(NamespaceInfo.class);
namespaces.add(ns);
代码示例来源: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 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
final NamespaceInfo ns = namespaces.peekLast();
final DataStoreInfo ds = createNiceMock(DataStoreInfo.class);
dataStores.add(ds);
代码示例来源:origin: geoserver/geoserver
@Test
public void testRasterStyle() throws Exception {
ResourcePool rp = createNiceMock(ResourcePool.class);
rp.writeStyle((StyleInfo) anyObject(), (InputStream) anyObject());
expectLastCall()
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();
代码示例来源:origin: geoserver/geoserver
NamespaceInfo ns = namespaces.peekLast();
final CoverageStoreInfo cs = createNiceMock(CoverageStoreInfo.class);
coverageStores.add(cs);
代码示例来源:origin: geoserver/geoserver
@Test
public void testRelativeToStore() throws IOException {
GeoServerDataDirectory dd = createDataDirectoryMock();
replay(dd);
GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd);
Object source = tl.findTemplateSource("dummy.ftl");
assertNull(source);
reset(dd);
DataStoreInfo s = createNiceMock(DataStoreInfo.class);
FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class);
expect(ft.getStore()).andReturn(s).anyTimes();
tl.setFeatureType(ft);
replay(ft, s, dd);
assertNull(tl.findTemplateSource("dummy.ftl"));
reset(dd);
expect(dd.findSuppStoreFile(s, "dummy.ftl")).andReturn(new File("foo")).once();
replay(dd);
assertNotNull(tl.findTemplateSource("dummy.ftl"));
verify(dd);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testRemoteType() throws Exception {
SimpleFeatureType ft =
DataUtilities.createType(
"remoteType", "the_geom:MultiPolygon,FID:String,ADDRESS:String");
GeoServerDataDirectory dd = createDataDirectoryMock();
Catalog cat = createNiceMock(Catalog.class);
expect(cat.getFeatureTypeByName(ft.getName())).andReturn(null).once();
replay(dd, cat);
GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd);
tl.setCatalog(cat);
tl.setFeatureType(ft);
tl.findTemplateSource("header.ftl");
verify(cat);
}
}
内容来源于网络,如有侵权,请联系作者删除!