Examples of MockServiceReference


Examples of org.springframework.osgi.mock.MockServiceReference

    ctxCtrl.verify();
  }

  public void testStop() throws Exception {
    ServiceReference ref = new MockServiceReference();
    MockControl regCtrl = MockControl.createControl(ServiceRegistration.class);
    ServiceRegistration reg = (ServiceRegistration) regCtrl.getMock();

    MockControl ctxCtrl = MockControl.createControl(BundleContext.class);
    BundleContext ctx = (BundleContext) ctxCtrl.getMock();
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

  private Object service1, service2, service3;


  protected void setUp() throws Exception {

    ref1 = new MockServiceReference();
    ref2 = new MockServiceReference();
    ref3 = new MockServiceReference();

    service1 = new Object();
    service2 = new Object();
    service3 = new Object();
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    public Map getServiceProperties() {
      return new HashMap();
    }

    public ServiceReferenceProxy getServiceReference() {
      return new PublicStaticSwappingServiceReferenceProxy(new MockServiceReference());
    }
View Full Code Here

Examples of org.springframework.osgi.mock.MockServiceReference

    registration = new MockServiceRegistration();

    bundleContext = new MockBundleContext() {

      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { new MockServiceReference(new String[] { Cloneable.class.getName() }) };
      }

      public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
        services.add(service);
        return registration;
View Full Code Here

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

Examples of org.springframework.osgi.mock.MockServiceReference

   */
  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

Examples of org.springframework.osgi.mock.MockServiceReference

   */
  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

Examples of org.springframework.osgi.mock.MockServiceReference

  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

Examples of org.springframework.osgi.mock.MockServiceReference

          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

Examples of org.springframework.osgi.mock.MockServiceReference

  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
TOP
Copyright © 2018 www.massapi.com. 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.