当前位置: 首页>>代码示例>>Java>>正文


Java IMocksControl.replay方法代码示例

本文整理汇总了Java中org.easymock.IMocksControl.replay方法的典型用法代码示例。如果您正苦于以下问题:Java IMocksControl.replay方法的具体用法?Java IMocksControl.replay怎么用?Java IMocksControl.replay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.easymock.IMocksControl的用法示例。


在下文中一共展示了IMocksControl.replay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.easymock.IMocksControl; //导入方法依赖的package包/类
public void setUp() throws Exception
{
    super.setUp();
    migrationRunnerStrategy = new OrderedMigrationRunnerStrategy();
    allMigrationTasks = new ArrayList<MigrationTask>();
    IMocksControl mockControl = createControl();
    currentPatchInfoStore = mockControl.createMock(PatchInfoStore.class);
    allMigrationTasks.add(new TestRollbackableTask1());
    allMigrationTasks.add(new TestRollbackableTask2());
    allMigrationTasks.add(new TestRollbackableTask3());
    allMigrationTasks.add(new TestRollbackableTask4());
    allMigrationTasks.add(new TestRollbackableTask5());
    expect(currentPatchInfoStore.getPatchLevel()).andReturn(12);
    mockControl.replay();

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:OrderedMigrationRunnerStrategyTest.java

示例2: testStartStop

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@SuppressWarnings({
 "rawtypes", "unchecked"
})
@Test
public void testStartStop() throws Exception {
    IMocksControl c = EasyMock.createControl();
    BundleContext context = c.createMock(BundleContext.class);
    ServiceRegistration sreg = c.createMock(ServiceRegistration.class);
    expect(context.registerService(EasyMock.eq(DistributionProvider.class), EasyMock.anyObject(DistributionProvider.class), EasyMock.anyObject(Dictionary.class))).andReturn(sreg );
    
    c.replay();
    Activator activator = new Activator();
    activator.start(context);
    activator.stop(context);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:17,代码来源:ActivatorTest.java

示例3: testExportExistingMultipleInterfaces

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testExportExistingMultipleInterfaces() throws Exception {
    IMocksControl c = EasyMock.createControl();
    RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
    final EndpointListenerNotifier mockEpListenerNotifier = c.createMock(EndpointListenerNotifier.class);
    List<String> exportedInterfaces = Arrays.asList("a.b.C","foo.Bar");
    final ServiceReference sref = createUserService(c, exportedInterfaces);
    expectServiceExported(c, rsa, mockEpListenerNotifier, sref, createEndpoint());
    c.replay();

    EndpointRepository endpointRepo = new EndpointRepository();
    endpointRepo.setNotifier(mockEpListenerNotifier);
    ExportPolicy policy = new DefaultExportPolicy();
    TopologyManagerExport exportManager = new TopologyManagerExport(endpointRepo, syncExecutor(), policy);
    exportManager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sref));
    exportManager.add(rsa);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:19,代码来源:TopologyManagerExportTest.java

示例4: testExportExistingNoExportedInterfaces

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testExportExistingNoExportedInterfaces() throws Exception {
    IMocksControl c = EasyMock.createControl();
    RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
    final EndpointListenerNotifier mockEpListenerNotifier = c.createMock(EndpointListenerNotifier.class);
    String exportedInterfaces = "";
    final ServiceReference sref = createUserService(c, exportedInterfaces);
    c.replay();

    EndpointRepository endpointRepo = new EndpointRepository();
    endpointRepo.setNotifier(mockEpListenerNotifier);
    ExportPolicy policy = new DefaultExportPolicy();
    TopologyManagerExport exportManager = new TopologyManagerExport(endpointRepo, syncExecutor(), policy);
    exportManager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sref));
    exportManager.add(rsa);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:18,代码来源:TopologyManagerExportTest.java

示例5: testGetService

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@SuppressWarnings({
 "rawtypes"
})
public void testGetService() throws ClassNotFoundException {
    final Object myTestProxyObject = new Object();

    IMocksControl control = EasyMock.createControl();
    EndpointDescription endpoint = createTestEndpointDesc();
    ImportRegistrationImpl iri = new ImportRegistrationImpl(endpoint, null);

    BundleContext consumerContext = control.createMock(BundleContext.class);
    Bundle consumerBundle = control.createMock(Bundle.class);
    BundleWiring bundleWiring = control.createMock(BundleWiring.class);
    EasyMock.expect(bundleWiring.getClassLoader()).andReturn(this.getClass().getClassLoader());
    EasyMock.expect(consumerBundle.adapt(BundleWiring.class)).andReturn(bundleWiring);
    EasyMock.expect(consumerBundle.getBundleContext()).andReturn(consumerContext);
    ServiceRegistration sreg = control.createMock(ServiceRegistration.class);


    DistributionProvider handler = mockDistributionProvider(myTestProxyObject);
    control.replay();

    ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri);
    assertSame(myTestProxyObject, csf.getService(consumerBundle, sreg));
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:26,代码来源:ClientServiceFactoryTest.java

示例6: testAddedRemoved

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testAddedRemoved() throws InvalidSyntaxException {
    IMocksControl c = EasyMock.createControl();
    String filter = "(objectClass=My)";
    BundleContext bc = createBundleContext();
    BundleContext listenerBc = createBundleContext();
    ServiceInterestListener serviceInterestListener = c.createMock(ServiceInterestListener.class);
    ListenerHookImpl listenerHook = new ListenerHookImpl(bc, serviceInterestListener);

    ListenerInfo listener = c.createMock(ListenerInfo.class);
    EasyMock.expect(listener.getBundleContext()).andReturn(listenerBc);
    EasyMock.expect(listener.getFilter()).andReturn(filter).atLeastOnce();
    
    // Main assertions
    serviceInterestListener.addServiceInterest(listenerHook.extendFilter(filter));
    EasyMock.expectLastCall();
    serviceInterestListener.removeServiceInterest(listenerHook.extendFilter(filter));
    EasyMock.expectLastCall();

    Collection<ListenerInfo> listeners = Collections.singletonList(listener);
    
    c.replay();
    listenerHook.added(listeners);
    listenerHook.removed(listeners);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:27,代码来源:ListenerHookImplTest.java

示例7: testClose

import org.easymock.IMocksControl; //导入方法依赖的package包/类
public void testClose() throws KeeperException, InterruptedException {
    IMocksControl c = EasyMock.createNiceControl();
    BundleContext ctx = c.createMock(BundleContext.class);
    ZooKeeper zk = c.createMock(ZooKeeper.class);
    expectCreated(zk, ENDPOINT_PATH);
    expectDeleted(zk, ENDPOINT_PATH);

    c.replay();

    PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx);
    EndpointDescription endpoint = createEndpoint();
    eli.endpointAdded(endpoint, null);
    eli.close(); // should result in zk.delete(...)

    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:17,代码来源:PublishingEndpointListenerTest.java

示例8: testNoSuchEditor

import org.easymock.IMocksControl; //导入方法依赖的package包/类
public void testNoSuchEditor() throws Exception {
  try {
    ProjectContext context = new NoopProjectContext();

    IMocksControl control = EasyMock.createControl();
    RepositoryExpression mockRepoEx = control.createMock(RepositoryExpression.class);
    expect(mockRepoEx.createCodebase(context)).andReturn(null); // Codebase unneeded

    Expression ex =
        new EditExpression(
            mockRepoEx, new Operation(Operator.EDIT, new Term("noSuchEditor", EMPTY_MAP)));

    control.replay();
    ex.createCodebase(context);
    fail();
  } catch (CodebaseCreationError expected) {
    assertEquals("no editor noSuchEditor", expected.getMessage());
  }
}
 
开发者ID:google,项目名称:MOE,代码行数:20,代码来源:ExpressionTest.java

示例9: testSimple

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testSimple() throws Exception {
    IMocksControl testControl = createControl();
    TestFilterChain testFilterChain = new TestFilterChain();
    HttpServletRequest req = testControl.createMock(HttpServletRequest.class);
    HttpServletResponse res = testControl.createMock(HttpServletResponse.class);

    expect(req.getMethod()).andReturn("GET").anyTimes();
    expect(req.getRequestURI()).andReturn("/bar/foo").anyTimes();
    expect(req.getServletPath()).andReturn("/bar/foo").anyTimes();
    expect(req.getContextPath()).andReturn("").anyTimes();

    testControl.replay();

    daggerFilter.doFilter(req, res, testFilterChain);

    assertFalse(testFilterChain.isTriggered());
    assertFalse(fooServlet.isTriggered());
    assertTrue(barServlet.isTriggered());

    testControl.verify();
}
 
开发者ID:johnlcox,项目名称:dagger-servlet,代码行数:23,代码来源:ContextPathTest.java

示例10: testSimple

import org.easymock.IMocksControl; //导入方法依赖的package包/类
public void testSimple() throws Exception {
  IMocksControl testControl = createControl();
  TestFilterChain testFilterChain = new TestFilterChain();
  HttpServletRequest req = testControl.createMock(HttpServletRequest.class);
  HttpServletResponse res = testControl.createMock(HttpServletResponse.class);

  expect(req.getMethod()).andReturn("GET").anyTimes();
  expect(req.getRequestURI()).andReturn("/bar/foo").anyTimes();
  expect(req.getServletPath()).andReturn("/bar/foo").anyTimes();
  expect(req.getContextPath()).andReturn("").anyTimes();

  testControl.replay();

  guiceFilter.doFilter(req, res, testFilterChain);

  assertFalse(testFilterChain.isTriggered());
  assertFalse(fooServlet.isTriggered());
  assertTrue(barServlet.isTriggered());

  testControl.verify();
}
 
开发者ID:google,项目名称:guice,代码行数:22,代码来源:ContextPathTest.java

示例11: setUp

import org.easymock.IMocksControl; //导入方法依赖的package包/类
protected void setUp() throws Exception {
	services = new LinkedHashMap();
	IMocksControl mc = createNiceControl();
	cfg = mc.createMock(Configuration.class);
	expect(cfg.getProperties()).andReturn(new Hashtable<String, Object>());
	mc.replay();
	bundleContext = new MockBundleContext() {

		public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
			services.put(service, properties);
			return super.registerService(clazzes, service, properties);
		}

		public Object getService(ServiceReference reference) {
			String[] clazzes = (String[]) reference.getProperty(Constants.OBJECTCLASS);
			if (clazzes[0].equals(ConfigurationAdmin.class.getName())) {
				return new MockConfigurationAdmin() {

					public Configuration getConfiguration(String pid) throws IOException {
						return cfg;
					}
				};
			}
			else
				return super.getService(reference);
		}

	};

	pid = "Peter Pan";
	cam = new ConfigurationAdminManager(pid, bundleContext);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:33,代码来源:ConfigurationAdminManagerTest.java

示例12: testUnwatchOnException

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testUnwatchOnException() throws Exception {
  IMocksControl control = createControl();

  ZooKeeperClient zkClient = control.createMock(ZooKeeperClient.class);
  Watcher onExpirationWatcher = control.createMock(Watcher.class);

  expect(zkClient.registerExpirationHandler(anyObject(Command.class)))
      .andReturn(onExpirationWatcher);

  expect(zkClient.get()).andThrow(new InterruptedException());  // See interrupted() note below.
  expect(zkClient.unregister(onExpirationWatcher)).andReturn(true);
  control.replay();

  Group group = new Group(zkClient, ZooDefs.Ids.OPEN_ACL_UNSAFE, "/blabla");
  ServerSetImpl serverset = new ServerSetImpl(zkClient, group);

  try {
    serverset.watch(hostSet -> {});
    fail("Expected MonitorException");
  } catch (DynamicHostSet.MonitorException e) {
    // NB: The assert is not important to this test, but the call to `Thread.interrupted()` is.
    // That call both returns the current interrupted status as well as clearing it.  The clearing
    // is crucial depending on the order tests are run in this class.  If this test runs before
    // one of the tests above that uses a `ZooKeeperClient` for example, those tests will fail
    // executing `ZooKeeperClient.get` which internally blocks on s sync-point that takes part in
    // the interruption mechanism and so immediately throws `InterruptedException` based on the
    // un-cleared interrupted bit.
    assertTrue(Thread.interrupted());
  }
  control.verify();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:33,代码来源:ServerSetImplTest.java

示例13: testDoStart

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testDoStart() throws Exception {
    IMocksControl c = createNiceControl();
    BundleContext context = c.createMock(BundleContext.class);
    expect(context.getProperty(Constants.FRAMEWORK_UUID)).andReturn("myid");
    context.addServiceListener(isA(TopologyManagerExport.class));
    expectLastCall();
    final Capture<String> filter = newCapture();
    expect(context.createFilter(EasyMock.capture(filter)))
        .andAnswer(new IAnswer<Filter>() {
            public Filter answer() throws Throwable {
                return FrameworkUtil.createFilter(filter.getValue());
            }
        }).times(2);
    ServiceReference<?> sref = c.createMock(ServiceReference.class);
    Bundle bundle = c.createMock(Bundle.class);
    expect(sref.getBundle()).andReturn(bundle).anyTimes();
    expect(context.getServiceReferences((String)null, Activator.DOSGI_SERVICES))
        .andReturn(new ServiceReference[]{sref});

    c.replay();
    Activator activator = new Activator();
    activator.doStart(context, new DefaultExportPolicy());
    c.verify();
    
    c.reset();
    c.replay();
    activator.doStop(context);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:31,代码来源:ActivatorTest.java

示例14: testServiceExportUnexport

import org.easymock.IMocksControl; //导入方法依赖的package包/类
/**
 * This tests if the topology manager handles a service marked to be exported correctly by exporting it to
 * an available RemoteServiceAdmin and notifying an EndpointListener afterwards.
 *
 * @throws Exception
 */
@Test
public void testServiceExportUnexport() throws Exception {
    IMocksControl c = EasyMock.createControl();
    RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
    final EndpointListener notifier = c.createMock(EndpointListener.class);
    final ServiceReference sref = createUserService(c);
    EndpointDescription epd = createEndpoint();
    expectServiceExported(c, rsa, notifier, sref, epd);

    c.replay();
    EndpointRepository endpointRepo = new EndpointRepository();
    endpointRepo.setNotifier(notifier);
    Executor executor = syncExecutor();
    ExportPolicy policy = new DefaultExportPolicy();
    TopologyManagerExport exportManager = new TopologyManagerExport(endpointRepo, executor, policy);
    exportManager.add(rsa);
    exportManager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sref));
    c.verify();

    c.reset();
    notifier.endpointRemoved(epd, null);
    expectLastCall().once();
    c.replay();
    exportManager.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, sref));
    c.verify();

    c.reset();
    c.replay();
    exportManager.serviceChanged(new ServiceEvent(ServiceEvent.MODIFIED, sref));
    c.verify();

    c.reset();
    c.replay();
    exportManager.remove(rsa);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:43,代码来源:TopologyManagerExportTest.java

示例15: testAddRemove

import org.easymock.IMocksControl; //导入方法依赖的package包/类
@Test
public void testAddRemove() throws InvalidSyntaxException {
    EndpointDescription ep1 = createEndpoint("my");
    
    IMocksControl c = EasyMock.createControl();
    ServiceReference<?> sref = createService(c);
    RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
    EndpointListener notifier = c.createMock(EndpointListener.class);
    
    notifier.endpointAdded(ep1, null);
    EasyMock.expectLastCall();
    
    c.replay();
    EndpointRepository repo = new EndpointRepository();
    repo.setNotifier(notifier);
    List<EndpointDescription> endpoints = Arrays.asList(ep1);
    repo.addEndpoints(sref, rsa, endpoints);
    c.verify();

    c.reset();
    notifier.endpointRemoved(ep1, null);
    EasyMock.expectLastCall();

    c.replay();
    repo.removeRemoteServiceAdmin(rsa);
    c.verify();
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:28,代码来源:EndpointRepositoryTest.java


注:本文中的org.easymock.IMocksControl.replay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。