Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockServiceReference


    public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        // just simulate when the bundle context doesn't have right service reference
        if (filter != null && filter.indexOf("name=test") > 0) {
            return null;
        }
        MockServiceReference reference = new MockServiceReference(getBundle(), new String[] {clazz});
        // setup the name property with the class name
        Dictionary properties = new Hashtable();
        properties.put("name", clazz);
        reference.setProperties(properties);
        return new ServiceReference[] {reference};
    }
View Full Code Here


    public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        // just simulate when the bundle context doesn't have right service reference
        if (filter != null && filter.indexOf("name=test") > 0) {
            return null;
        }
        MockServiceReference reference = new MockServiceReference(getBundle(), new String[] {clazz});
        // setup the name property with the class name
        Dictionary properties = new Hashtable();
        properties.put("name", clazz);
        reference.setProperties(properties);
        return new ServiceReference[] {reference};
    }
View Full Code Here

        List<ServiceReference> list = new ArrayList<ServiceReference>();
        try {
            String[] beanNames = applicationContext.getBeanNamesForType(Class.forName(clazz));
            if (beanNames != null && beanNames.length > 0) {
                for (String beanName : beanNames) {
                    list.add(new MockServiceReference(new MockBundle(beanName)));
                }
            }
        } catch (ClassNotFoundException e) {
            log.error("Error loading class name " + clazz + ": ", e);
        }
View Full Code Here

    // initialise registered services
    registeredServices = new ServiceReference[dependent.length];

    for (int i = 0; i < registeredServices.length; i++) {
      registeredServices[i] = new MockServiceReference(DependencyMockBundle.this, createProps(i, serviceRanking,
        serviceId), null) {

        public Bundle[] getUsingBundles() {
          return dependent;
        }
View Full Code Here

      Properties props = new Properties();
     
      props.put(OsgiServicePropertiesResolver.BEAN_NAME_PROPERTY_KEY, new Long(
          System.identityHashCode(dependencyBundle)));
     
      inUseServices[i] = new MockServiceReference() {
        public Bundle getBundle() {
          return dependencyBundle;
        }

        public Bundle[] getUsingBundles() {
View Full Code Here

    BundleContext ctx = (BundleContext) ctxCtrl.getMock();

    MockControl servCtrl = MockControl.createControl(TestRunnerService.class);
    TestRunnerService runner = (TestRunnerService) servCtrl.getMock();

    ServiceReference ref = new MockServiceReference();

    ctxCtrl.expectAndReturn(ctx.getServiceReference(TestRunnerService.class.getName()), ref);
    ctxCtrl.expectAndReturn(ctx.getService(ref), runner);

    ctx.registerService((String) null, null, null);
View Full Code Here

    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

  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

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

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

    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

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.