Package org.easymock.classextension

Examples of org.easymock.classextension.IMocksControl


        Map<String, Object> intents = new HashMap<String, Object>();
        intents.put("A", new AbstractFeature() {});
        final IntentMap intentMap = new IntentMap();
        intentMap.setIntents(intents);
               
        IMocksControl control = EasyMock.createNiceControl();
        BundleContext dswContext = control.createMock(BundleContext.class);
        BundleContext callingContext = control.createMock(BundleContext.class);       
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();

        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext,  handlerProps) {
            @Override
            IntentMap getIntentMap(BundleContext callingContext) {
View Full Code Here


        intents.put("A_alt", feat1);
        intents.put("B", new AbstractFeature() {});
        final IntentMap intentMap = new IntentMap();
        intentMap.setIntents(intents);
       
        IMocksControl control = EasyMock.createNiceControl();
        BundleContext dswContext = control.createMock(BundleContext.class);
        BundleContext callingContext = control.createMock(BundleContext.class);
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();
       
        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext,  handlerProps) {
            @Override
            IntentMap getIntentMap(BundleContext callingContext) {
View Full Code Here

        assertTrue(effectiveIntents.contains("A"));
        assertTrue(effectiveIntents.contains("A_alt"));
    }
   
    public void testDefaultBindingIntent() {       
        IMocksControl control = EasyMock.createNiceControl();

        Map<String, Object> intents = new HashMap<String, Object>();
        BindingConfiguration feat1 = control.createMock(BindingConfiguration.class);
        intents.put("A", new AbstractFeature() {});
        intents.put("SOAP", feat1);
        intents.put("SOAP.1_1", feat1);
        intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class));
        final IntentMap intentMap = new IntentMap();
        intentMap.setIntents(intents);

        BundleContext dswContext = control.createMock(BundleContext.class);
        BundleContext callingContext = control.createMock(BundleContext.class);
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();
       
        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext,  handlerProps) {
            @Override
            IntentMap getIntentMap(BundleContext callingContext) {
View Full Code Here

        assertTrue(effectiveIntents.contains("SOAP"));
        assertTrue(effectiveIntents.contains("SOAP.1_1"));
    }
   
    public void testExplicitBindingIntent() {
        IMocksControl control = EasyMock.createNiceControl();

        Map<String, Object> intents = new HashMap<String, Object>();
        BindingConfiguration feat1 = control.createMock(BindingConfiguration.class);
        intents.put("A", new AbstractFeature() {});
        intents.put("SOAP", feat1);
        intents.put("SOAP.1_1", feat1);
        intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class));
        final IntentMap intentMap = new IntentMap();
        intentMap.setIntents(intents);

        BundleContext dswContext = control.createMock(BundleContext.class);
        BundleContext callingContext = control.createMock(BundleContext.class);
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();
       
        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext,  handlerProps) {
            @Override
            IntentMap getIntentMap(BundleContext callingContext) {
View Full Code Here

        Map<String, Object> appIntents = new HashMap<String, Object>();
        appIntents.put("A", new TestFeature("appFeatureA"));
        final IntentMap appIntentMap = new IntentMap();
        appIntentMap.setIntents(appIntents);

        IMocksControl control = EasyMock.createNiceControl();
        final BundleContext dswContext = control.createMock(BundleContext.class);
        final BundleContext callingContext = control.createMock(BundleContext.class);       
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();

        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put("osgi.remote.requires.intents", requestedIntents);
View Full Code Here

        final IntentMap masterIntentMap = new IntentMap();
        masterIntentMap.setIntents(masterIntents);       
        final IntentMap appIntentMap = new IntentMap();
        appIntentMap.setIntents(new HashMap<String, Object>());

        IMocksControl control = EasyMock.createNiceControl();
        final BundleContext dswContext = control.createMock(BundleContext.class);
        final BundleContext callingContext = control.createMock(BundleContext.class);       
        List<AbstractFeature> features = new ArrayList<AbstractFeature>();
        AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
        control.replay();
       
        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put("osgi.remote.requires.intents", "B A");
View Full Code Here

public class EndpointListenerImplTest extends TestCase {

    public void testEndpointRemovalAdding() throws KeeperException, InterruptedException {

        IMocksControl c = EasyMock.createNiceControl();

        BundleContext ctx = c.createMock(BundleContext.class);
        ZooKeeperDiscovery zkd = c.createMock(ZooKeeperDiscovery.class);

        ZooKeeper zk = c.createMock(ZooKeeper.class);

        EasyMock.expect(zkd.getZookeeper()).andReturn(zk).anyTimes();

       
        String path = "/osgi/service_registry/myClass/google.de#80##test";
        EasyMock.expect(
                        zk.create(EasyMock.eq(path),
                                  (byte[])EasyMock.anyObject(), EasyMock.eq(Ids.OPEN_ACL_UNSAFE), EasyMock
                                      .eq(CreateMode.EPHEMERAL))).andReturn("").once();
       
        zk.delete(EasyMock.eq("/osgi/service_registry/myClass/google.de#80##test"), EasyMock.eq(-1));
        EasyMock.expectLastCall().once();

        c.replay();

        EndpointListenerImpl eli = new EndpointListenerImpl(zkd, ctx);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.OBJECTCLASS, new String[] {
            "myClass"
        });
        props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test");
        props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig");

        EndpointDescription ed = new EndpointDescription(props);

        eli.endpointAdded(ed, null);
        eli.endpointAdded(ed, null)// should do nothing

        eli.endpointRemoved(ed, null);
        eli.endpointRemoved(ed, null); // should do nothing
       
        c.verify();

    }
View Full Code Here

   
   
    public void testClose() throws KeeperException, InterruptedException{
       
       
        IMocksControl c = EasyMock.createNiceControl();

        BundleContext ctx = c.createMock(BundleContext.class);
        ZooKeeperDiscovery zkd = c.createMock(ZooKeeperDiscovery.class);

        ZooKeeper zk = c.createMock(ZooKeeper.class);

        EasyMock.expect(zkd.getZookeeper()).andReturn(zk).anyTimes();

       
        String path = "/osgi/service_registry/myClass/google.de#80##test";
        EasyMock.expect(
                        zk.create(EasyMock.eq(path),
                                  (byte[])EasyMock.anyObject(), EasyMock.eq(Ids.OPEN_ACL_UNSAFE), EasyMock
                                      .eq(CreateMode.EPHEMERAL))).andReturn("").once();
       
        zk.delete(EasyMock.eq("/osgi/service_registry/myClass/google.de#80##test"), EasyMock.eq(-1));
        EasyMock.expectLastCall().once();

        c.replay();

        EndpointListenerImpl eli = new EndpointListenerImpl(zkd, ctx);

        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.OBJECTCLASS, new String[] {
            "myClass"
        });
        props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test");
        props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig");

        EndpointDescription ed = new EndpointDescription(props);

        eli.endpointAdded(ed, null);

        eli.close(); // should result in zk.delete(...)
       
        c.verify();
       
    }
View Full Code Here

public class EndpointListenerTrackerCustomizerTest extends TestCase{
   
    public void testEndpointListenerTrackerCustomizer(){
       
        IMocksControl c = EasyMock.createNiceControl();
       
        BundleContext ctx = c.createMock(BundleContext.class);
        ZooKeeperDiscovery zkd = c.createMock(ZooKeeperDiscovery.class);
       
        ServiceReference sref = c.createMock(ServiceReference.class);
        ServiceReference sref2 = c.createMock(ServiceReference.class);
       
        final Properties p = new Properties();
       
       
        EasyMock.expect(sref.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
            public String[] answer() throws Throwable {
                return p.keySet().toArray(new String[p.keySet().size()]);
            }
        }).anyTimes();
       
        EasyMock.expect(sref.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                String key = (String)(EasyMock.getCurrentArguments()[0]);
                return p.getProperty(key);
            }
        }).anyTimes();
       
        EasyMock.expect(sref2.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
            public String[] answer() throws Throwable {
                return p.keySet().toArray(new String[p.keySet().size()]);
            }
        }).anyTimes();
       
        EasyMock.expect(sref2.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                String key = (String)(EasyMock.getCurrentArguments()[0]);
                return p.getProperty(key);
            }
        }).anyTimes();
       
       
        final ArrayList<IMocksControl> controls = new ArrayList<IMocksControl>();
       
        EndpointListenerTrackerCustomizer eltc = new EndpointListenerTrackerCustomizer(zkd,ctx){
            protected InterfaceMonitor createInterfaceMonitor(String scope, String objClass, Interest interest){
                IMocksControl lc = EasyMock.createNiceControl();
                InterfaceMonitor im = lc.createMock(InterfaceMonitor.class);
                im.start();
                EasyMock.expectLastCall().once();
                im.close();
                EasyMock.expectLastCall().once();
                lc.replay();
                controls.add(lc);
                return im;
            }
        };
       
View Full Code Here

    @Test
    public void testErrorMessage()
    {
        UIViewRoot root = new UIViewRoot();
        MockFacesContext12 facesContext = new MockFacesContext12();
        IMocksControl mocksControl = EasyMock.createControl();
        Application application = mocksControl.createMock(Application.class);
        ViewHandler viewHandler = mocksControl.createMock(ViewHandler.class);
        ELContext elContext = mocksControl.createMock(ELContext.class);
        ExpressionFactory expressionFactory = mocksControl.createMock(ExpressionFactory.class);
        ValueExpression valueExpression = mocksControl.createMock(ValueExpression.class);
        facesContext.setApplication(application);
        facesContext.setViewRoot(root);
        facesContext.setELContext(elContext);
       
        expect(application.getViewHandler()).andReturn(viewHandler);
        expect(viewHandler.calculateLocale(facesContext)).andReturn(Locale.ENGLISH);
        expect(application.getMessageBundle()).andReturn("javax.faces.Messages");
        expect(application.getExpressionFactory()).andReturn(expressionFactory);
        String s = "xxx: Validation Error: Value is greater than allowable maximum of ''xyz''";
        expect(expressionFactory.createValueExpression(elContext,s,String.class)).andReturn(valueExpression);
        expect(valueExpression.getValue(elContext)).andReturn(s);
        mocksControl.replay();

        assertEquals(_MessageUtils.getErrorMessage(facesContext, "javax.faces.validator.DoubleRangeValidator.MAXIMUM",
                new Object[] { "xyz", "xxx" }).getDetail(),
                "xxx: Validation Error: Value is greater than allowable maximum of 'xyz'");
    }
View Full Code Here

TOP

Related Classes of org.easymock.classextension.IMocksControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.