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

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

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

EasyMock.replay介绍

暂无

代码示例

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

@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

@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

@Override
  public Void answer() throws Throwable {
    verify(log);
    reset(log);
    log.removeHandler(handlerCap.getValue());
    expectLastCall().once();
    log.setLevel(Level.OFF);
    expectLastCall().once();
    replay(log);
    return null;
  }
});

代码示例来源: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 testFindInContext() {
  CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1");
  replay(testCacheProvider1);
  CacheProvider provider = DefaultCacheProvider.findProvider();
  assertThat(provider, sameInstance(testCacheProvider1));
  verify(testCacheProvider1);
}

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

@Override
  public Void answer() throws Throwable {
    verify(log);
    reset(log);
    log.removeHandler(handlerCap.getValue());
    expectLastCall().once();
    log.setLevel(Level.OFF);
    expectLastCall().once();
    handlerCap.getValue().publish(record);
    assertThat(
        ((LoggerRule) handlerCap.getValue()).records(),
        contains(record));
    replay(log);
    return null;
  }
});

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

@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: 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));
    return null;
  }
});

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

代码示例来源: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: 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: 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 testResolveWithProperty() {
  CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1");
  CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2");
  // Test that the bean specified in the property is used
  extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider1");
  replay(testCacheProvider1, testCacheProvider2);
  CacheProvider provider = DefaultCacheProvider.findProvider();
  assertThat(provider, sameInstance(testCacheProvider1));
  verify(testCacheProvider1, testCacheProvider2);
  // Retry with the property changed to ensure we weren't jsut lucky before
  reset(testCacheProvider1, testCacheProvider2);
  extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider2");
  replay(testCacheProvider1, testCacheProvider2);
  provider = DefaultCacheProvider.findProvider();
  assertThat(provider, sameInstance(testCacheProvider2));
  verify(testCacheProvider1, testCacheProvider2);
}

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

@Test
  public void testPropertyPriority() {
    CacheProvider testCacheProvider3 = addMockProvider("testCacheProvider3");
    CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2");

    // Test that the bean specified in the property is used

    extensions.property(
        DefaultCacheProvider.BEAN_NAME_PROPERTY,
        "testCacheProvider1,testCacheProvider2,testCacheProvider3");

    replay(testCacheProvider3, testCacheProvider2);

    CacheProvider provider = DefaultCacheProvider.findProvider();

    assertThat(provider, sameInstance(testCacheProvider2));

    verify(testCacheProvider3, testCacheProvider2);
  }
}

相关文章