org.easymock.classextension.EasyMock.expect()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.easymock.classextension.EasyMock.expect()方法的一些代码示例,展示了EasyMock.expect()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EasyMock.expect()方法的具体详情如下:
包路径:org.easymock.classextension.EasyMock
类名称:EasyMock
方法名:expect

EasyMock.expect介绍

暂无

代码示例

代码示例来源:origin: geoserver/geoserver

GeoServerDataDirectory createDataDirectoryMock() {
  GeoServerDataDirectory dd = createNiceMock(GeoServerDataDirectory.class);
  expect(dd.root()).andReturn(root).anyTimes();
  return dd;
}

代码示例来源: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: 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

@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 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 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 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

@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 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: geotools/geotools

@Test
public void testDefaultTimeouts() throws Exception {
  reset(conn);
  {
    conn.setConnectTimeout(HTTPURIHandler.DEFAULT_CONNECTION_TIMEOUT);
    expectLastCall();
    conn.setReadTimeout(HTTPURIHandler.DEFAULT_READ_TIMEOUT);
    expectLastCall();
    expect(conn.getInputStream()).andStubReturn(is);
  }
  replay(conn);
  URI uri = URI.createURI("http://example.com");
  handler.createInputStream(uri, Collections.EMPTY_MAP);
}

代码示例来源: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: geotools/geotools

@Test
public void testCustomConnectTimeout() throws Exception {
  final int testValue = 42;
  reset(conn);
  {
    conn.setConnectTimeout(testValue);
    expectLastCall();
    conn.setReadTimeout(HTTPURIHandler.DEFAULT_READ_TIMEOUT);
    expectLastCall();
    expect(conn.getInputStream()).andReturn(is);
  }
  replay(conn);
  handler.setConnectionTimeout(testValue);
  URI uri = URI.createURI("http://example.com");
  handler.createInputStream(uri, Collections.EMPTY_MAP);
}

代码示例来源: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);
  }
}

代码示例来源:origin: geotools/geotools

@Test
public void testCustomReadTimeout() throws Exception {
  final int testValue = 42;
  reset(conn);
  {
    conn.setConnectTimeout(HTTPURIHandler.DEFAULT_CONNECTION_TIMEOUT);
    expectLastCall();
    conn.setReadTimeout(testValue);
    expectLastCall();
    expect(conn.getInputStream()).andStubReturn(is);
  }
  replay(conn);
  handler.setReadTimeout(testValue);
  URI uri = URI.createURI("http://example.com");
  handler.createInputStream(uri, Collections.EMPTY_MAP);
}

代码示例来源:origin: org.geoserver/gs-kml

@Test
public void testAcceptedNames() throws Exception {
  // test a name with non word characters
  Style style = style(featureTypeStyle(rule(Filter.INCLUDE, grayCircle())));
  StyleInfo s = createNiceMock(StyleInfo.class);
  expect(s.getStyle()).andReturn(style);
  Catalog cat = createNiceMock(Catalog.class);
  expect(cat.getStyleByName("foo-bar")).andReturn(s);
  replay(s, cat);
  dispatch("/icon/foo-bar", "0.0.0=", cat);
}

代码示例来源:origin: geotools/geotools

@Test
  public void testTimeout() throws Exception {
    reset(conn);
    {
      conn.setConnectTimeout(anyInt());
      expectLastCall();
      conn.setReadTimeout(anyInt());
      expectLastCall();
      expect(conn.getInputStream()).andThrow(new IOException());
    }
    replay(conn);

    URI uri = URI.createURI("http://example.com");

    exception.expect(IOException.class);
    handler.createInputStream(uri, Collections.EMPTY_MAP);
  }
}

代码示例来源:origin: org.geoserver.script/gs-script-core

@Override
protected void oneTimeSetUp() throws Exception {
  super.oneTimeSetUp();
  scriptMgr = getScriptManager();
  // mock security manager to facilitate the requred admin access
  GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);
  expect(secMgr.checkAuthenticationForAdminRole()).andReturn(true).anyTimes();
  replay(secMgr);
  scriptMgr.setSecurityManager(secMgr);
}

代码示例来源:origin: geotools/geotools

@Before
public void setUp() throws Exception {
  conn = createMock(HttpURLConnection.class);
  is = createMock(InputStream.class);
  conn.setConnectTimeout(anyInt());
  expectLastCall().asStub();
  conn.setReadTimeout(anyInt());
  expectLastCall().asStub();
  expect(conn.getInputStream()).andStubReturn(is);
  handler =
      new HTTPURIHandler() {
        @Override
        protected HttpURLConnection getConnection(URI uri) throws IOException {
          // TODO Auto-generated method stub
          return conn;
        }
      };
  replay(conn, is);
}

代码示例来源:origin: org.geoserver/gs-wms

@Test
  public void testInputStream() throws Exception {
    InputStream stream = createMock(InputStream.class);
    expect(stream.read((byte[]) anyObject())).andReturn(-1).once();
    replay(stream);

    WMSMapContent map = createNiceMock(WMSMapContent.class);
    replay(map);

    new RawMap(map, stream, "text/plain").writeTo(null);
    verify(stream);
  }
}

相关文章