本文整理匯總了Java中org.easymock.IMocksControl.verify方法的典型用法代碼示例。如果您正苦於以下問題:Java IMocksControl.verify方法的具體用法?Java IMocksControl.verify怎麽用?Java IMocksControl.verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.easymock.IMocksControl
的用法示例。
在下文中一共展示了IMocksControl.verify方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testExportExisting
import org.easymock.IMocksControl; //導入方法依賴的package包/類
@Test
public void testExportExisting() throws Exception {
IMocksControl c = EasyMock.createControl();
RemoteServiceAdmin rsa = c.createMock(RemoteServiceAdmin.class);
final EndpointListenerNotifier mockEpListenerNotifier = c.createMock(EndpointListenerNotifier.class);
final ServiceReference sref = createUserService(c);
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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: testEndpointRemovalAdding
import org.easymock.IMocksControl; //導入方法依賴的package包/類
public void testEndpointRemovalAdding() throws KeeperException, InterruptedException {
IMocksControl c = EasyMock.createNiceControl();
BundleContext ctx = c.createMock(BundleContext.class);
ZooKeeper zk = c.createMock(ZooKeeper.class);
String path = ENDPOINT_PATH;
expectCreated(zk, path);
expectDeleted(zk, path);
c.replay();
PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx);
EndpointDescription endpoint = createEndpoint();
eli.endpointAdded(endpoint, null);
eli.endpointAdded(endpoint, null); // should do nothing
eli.endpointRemoved(endpoint, null);
eli.endpointRemoved(endpoint, null); // should do nothing
c.verify();
}
示例6: 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();
}
示例7: 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();
}
示例8: testInterfaceMonitor
import org.easymock.IMocksControl; //導入方法依賴的package包/類
public void testInterfaceMonitor() throws KeeperException, InterruptedException {
IMocksControl c = EasyMock.createControl();
ZooKeeper zk = c.createMock(ZooKeeper.class);
expect(zk.getState()).andReturn(ZooKeeper.States.CONNECTED).anyTimes();
String scope = "(myProp=test)";
String interf = "es.schaaf.test";
String node = Utils.getZooKeeperPath(interf);
EndpointListener endpointListener = c.createMock(EndpointListener.class);
InterfaceMonitor im = new InterfaceMonitor(zk, interf, endpointListener, scope);
zk.exists(eq(node), eq(im), eq(im), EasyMock.anyObject());
EasyMock.expectLastCall().once();
expect(zk.exists(eq(node), eq(false))).andReturn(new Stat()).anyTimes();
expect(zk.getChildren(eq(node), eq(false))).andReturn(Collections.<String> emptyList()).once();
expect(zk.getChildren(eq(node), eq(im))).andReturn(Collections.<String> emptyList()).once();
c.replay();
im.start();
// simulate a zk callback
WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.SyncConnected, node);
im.process(we);
c.verify();
}
示例9: testUpdateConfig
import org.easymock.IMocksControl; //導入方法依賴的package包/類
public void testUpdateConfig() throws Exception {
final File tempDir = new File("target");
IMocksControl control = EasyMock.createControl();
BundleContext bc = control.createMock(BundleContext.class);
expect(bc.getDataFile("")).andReturn(tempDir);
final MyZooKeeperServerMain mockServer = control.createMock(MyZooKeeperServerMain.class);
control.replay();
ZookeeperStarter starter = new ZookeeperStarter(bc) {
@Override
protected void startFromConfig(QuorumPeerConfig config) {
assertEquals(1234, config.getClientPortAddress().getPort());
assertTrue(config.getDataDir().contains(tempDir + File.separator + "zkdata"));
assertEquals(2000, config.getTickTime());
assertEquals(10, config.getInitLimit());
assertEquals(5, config.getSyncLimit());
this.main = mockServer;
}
};
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("clientPort", "1234");
starter.updated(props);
assertNotNull(starter.main);
control.verify();
}
示例10: 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();
}
示例11: 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();
}
示例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();
}
示例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();
}
示例14: testAddingWithNullValues
import org.easymock.IMocksControl; //導入方法依賴的package包/類
@Test
public void testAddingWithNullValues() throws InvalidSyntaxException {
IMocksControl c = EasyMock.createControl();
DistributionProvider provider = c.createMock(DistributionProvider.class);
ServiceReference<DistributionProvider> providerRef = c.createMock(ServiceReference.class);
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_INTENTS_SUPPORTED)).andReturn(null);
EasyMock.expect(providerRef.getProperty(RemoteConstants.REMOTE_CONFIGS_SUPPORTED)).andReturn(null);
BundleContext context = c.createMock(BundleContext.class);
String filterSt = String.format("(objectClass=%s)", DistributionProvider.class.getName());
Filter filter = FrameworkUtil.createFilter(filterSt);
EasyMock.expect(context.createFilter(filterSt)).andReturn(filter);
EasyMock.expect(context.getService(providerRef)).andReturn(provider);
ServiceRegistration rsaReg = c.createMock(ServiceRegistration.class);
EasyMock.expect(context.registerService(EasyMock.isA(String.class), EasyMock.isA(ServiceFactory.class),
EasyMock.isA(Dictionary.class)))
.andReturn(rsaReg).atLeastOnce();
context.addServiceListener(EasyMock.isA(ServiceListener.class), EasyMock.isA(String.class));
EasyMock.expectLastCall();
final BundleContext apiContext = c.createMock(BundleContext.class);
c.replay();
DistributionProviderTracker tracker = new DistributionProviderTracker(context) {
protected BundleContext getAPIContext() {
return apiContext;
};
};
tracker.addingService(providerRef);
c.verify();
}
示例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();
}