當前位置: 首頁>>代碼示例>>Java>>正文


Java IMocksControl類代碼示例

本文整理匯總了Java中org.easymock.IMocksControl的典型用法代碼示例。如果您正苦於以下問題:Java IMocksControl類的具體用法?Java IMocksControl怎麽用?Java IMocksControl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IMocksControl類屬於org.easymock包,在下文中一共展示了IMocksControl類的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: 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();
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:18,代碼來源:TopologyManagerExportTest.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: 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

示例6: 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();
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:22,代碼來源:PublishingEndpointListenerTest.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: testScope

import org.easymock.IMocksControl; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public void testScope() {
    IMocksControl c = EasyMock.createNiceControl();

    BundleContext ctx = c.createMock(BundleContext.class);
    ZooKeeper zk = c.createMock(ZooKeeper.class);
    @SuppressWarnings("rawtypes")
    ServiceRegistration sreg = c.createMock(ServiceRegistration.class);

    PublishingEndpointListenerFactory eplf = new PublishingEndpointListenerFactory(zk, ctx);

    EasyMock.expect(ctx.registerService(EasyMock.eq(EndpointListener.class.getName()), EasyMock.eq(eplf),
                                        (Dictionary<String, String>)EasyMock.anyObject())).andReturn(sreg).once();

    EasyMock.expect(ctx.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("myUUID").anyTimes();

    c.replay();
    eplf.start();
    c.verify();

}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:22,代碼來源:PublishingEndpointListenerFactoryTest.java

示例9: 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();
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:27,代碼來源:InterfaceMonitorTest.java

示例10: 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();
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:27,代碼來源:ZookeeperStarterTest.java

示例11: testDefaults

import org.easymock.IMocksControl; //導入依賴的package包/類
@Test
public void testDefaults() throws ConfigurationException {
    IMocksControl c = EasyMock.createControl();
    BundleContext bctx = c.createMock(BundleContext.class);
    ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
        @Override
        protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
            Assert.assertEquals("localhost", host);
            Assert.assertEquals("2181", port);
            Assert.assertEquals(3000, timeout);
            return null;
        }  
    };
    
    Dictionary<String, Object> configuration = new Hashtable<String, Object>();
    zkd.updated(configuration);
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:18,代碼來源:ZookeeperDiscoveryTest.java

示例12: testConfig

import org.easymock.IMocksControl; //導入依賴的package包/類
@Test
public void testConfig() throws ConfigurationException {
    IMocksControl c = EasyMock.createControl();
    BundleContext bctx = c.createMock(BundleContext.class);
    ZooKeeperDiscovery zkd = new ZooKeeperDiscovery(bctx) {
        @Override
        protected ZooKeeper createZooKeeper(String host, String port, int timeout) {
            Assert.assertEquals("myhost", host);
            Assert.assertEquals("1", port);
            Assert.assertEquals(1000, timeout);
            return null;
        }  
    };
    
    Dictionary<String, Object> configuration = new Hashtable<String, Object>();
    configuration.put("zookeeper.host", "myhost");
    configuration.put("zookeeper.port", "1");
    configuration.put("zookeeper.timeout", "1000");
    zkd.updated(configuration);
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:21,代碼來源:ZookeeperDiscoveryTest.java

示例13: 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

示例14: 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

示例15: doCreateMock

import org.easymock.IMocksControl; //導入依賴的package包/類
private static <T> T doCreateMock(Class<T> type, ConstructorArgs constructorArgs, final IMocksControl control,
                                  Method... methods) {
    T mock;
    MocksControl mocksControl = ((MocksControl) control);
    if (constructorArgs == null) {
        if (methods == null) {
            mock = mocksControl.createMock(type);
        } else {
            mock = mocksControl.createMock(type, methods);
        }
    } else {
        if (methods == null) {
            mock = mocksControl.createMock(type, constructorArgs);
        } else {
            mock = mocksControl.createMock(type, constructorArgs, methods);
        }
    }
    return mock;
}
 
開發者ID:awenblue,項目名稱:powermock,代碼行數:20,代碼來源:PowerMock.java


注:本文中的org.easymock.IMocksControl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。