當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。