Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockServiceReference


    classes = new String[] { Object.class.getName(), Cloneable.class.getName(), Serializable.class.getName() };

    // lowest service reference
    Dictionary dict1 = new Hashtable();
    dict1.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
    ref1 = new MockServiceReference(null, dict1, null);

    // neutral service reference
    Dictionary dict2 = new Hashtable();
    dict2.put(Constants.SERVICE_ID, new Long(20));

    ref2 = new MockServiceReference(null, dict2, null);

    // neutral service reference
    Dictionary dict3 = new Hashtable();
    dict3.put(Constants.SERVICE_ID, new Long(30));

    ref3 = new MockServiceReference(null, dict3, null);

    ctrl = MockControl.createStrictControl(BundleContext.class);
    context = (BundleContext) ctrl.getMock();

  }
View Full Code Here


   */
  public void testGetServiceId() {
    long id = 12345;
    Dictionary dict = new Hashtable();
    dict.put(Constants.SERVICE_ID, new Long(id));
    ServiceReference ref = new MockServiceReference(null, dict, null);
    assertEquals(id, OsgiServiceReferenceUtils.getServiceId(ref));
  }
View Full Code Here

   */
  public void testGetServiceRankingAvailable() {
    int ranking = 12345;
    Dictionary dict = new Hashtable();
    dict.put(Constants.SERVICE_RANKING, new Integer(ranking));
    ServiceReference ref = new MockServiceReference(null, dict, null);
    assertEquals(ranking, OsgiServiceReferenceUtils.getServiceRanking(ref));
  }
View Full Code Here

  public void testGetServiceRankingWithInvalidClass() {
    int ranking = 12345;
    Dictionary dict = new Hashtable();
    dict.put(Constants.SERVICE_RANKING, new Long(ranking));
    ServiceReference ref = new MockServiceReference(null, dict, null);
    assertEquals(0, OsgiServiceReferenceUtils.getServiceRanking(ref));
  }
View Full Code Here

          return super.put(key, value);
        return null;
      }
    };

    ServiceReference ref = new MockServiceReference(null, dict, null);

    assertNull(ref.getProperty(Constants.SERVICE_RANKING));
    assertEquals(0, OsgiServiceReferenceUtils.getServiceRanking(ref));
  }
View Full Code Here

  protected void setUp() throws Exception {
    BundleContext bundleContext = new MockBundleContext() {
      // service reference already registered
      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { new MockServiceReference(new String[] { Serializable.class.getName() }) };
      }
    };

    appContext = new GenericApplicationContext();
    appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
View Full Code Here

    ServiceUnavailableException exception = new ServiceUnavailableException((String) null);
    assertNotNull(exception.getMessage());
  }

  public void testServiceUnavailableExceptionServiceReference() {
    ServiceReference sr = new MockServiceReference();
    ServiceUnavailableException exception = new ServiceUnavailableException(sr);
    assertNotNull(exception.getMessage());
  }
View Full Code Here

    super.setUp();
    this.serviceFactoryBean = new OsgiServiceCollectionProxyFactoryBean();
    // this.serviceFactoryBean.setApplicationContext(new
    // GenericApplicationContext());

    ref = new MockServiceReference(new String[] { Serializable.class.getName() });

    bundleContext = new MockBundleContext() {

      private final String filter_Serializable = OsgiFilterUtils.unifyFilter(Serializable.class, null);
View Full Code Here

    this.serviceFactoryBean.setBundleContext(new MockBundleContext());
    this.serviceFactoryBean.setInterfaces(new Class[] { Serializable.class });
    String filter = "(beanName=myBean)";
    this.serviceFactoryBean.setFilter(filter);

    MockServiceReference ref = new MockServiceReference();
    Dictionary dict = new Hashtable();
    dict.put(Constants.OBJECTCLASS, new String[] { Serializable.class.getName() });
    ref.setProperties(dict);

    serviceFactoryBean.setBeanClassLoader(getClass().getClassLoader());
    serviceFactoryBean.afterPropertiesSet();

    Object proxy = serviceFactoryBean.getObject();
View Full Code Here

    DummyListenerServiceSignature2.UNBIND_CALLS = 0;

    BundleContext bundleContext = new MockBundleContext() {
      // service reference already registered
      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
      }
    };

    appContext = new GenericApplicationContext();
    appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
View Full Code Here

TOP

Related Classes of org.springframework.osgi.mock.MockServiceReference

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.