Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockServiceRegistration


    context.addBundleListener(null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    bundleContextControl.setVoidCallable(2);

    bundleContextControl.expectAndReturn(context.registerService(new String[0], null, new Properties()),
      new MockServiceRegistration(), MockControl.ONE_OR_MORE);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);

    bundleContextControl.replay();

    this.listener.start(context);
View Full Code Here


      }

      public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
        if (service instanceof ManagedService) {
          registrationCounter++;
          return new MockServiceRegistration(clazzes, properties) {

            public void unregister() {
              super.unregister();
              unregistrationCounter++;
            }
View Full Code Here

    RegistrationListener.UNBIND_CALLS = 0;

    CustomRegistrationListener.REG_CALLS = 0;
    CustomRegistrationListener.UNREG_CALLS = 0;

    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() }) };
View Full Code Here

  public void testNotifyListenersOnRegistration() {
    assertEquals(0, SimpleOsgiServiceRegistrationListener.REGISTERED);
    assertEquals(0, SimpleOsgiServiceRegistrationListener.UNREGISTERED);

    exporter.notifyListeners(new Object(), new HashMap(), new MockServiceRegistration());

    assertEquals(1, SimpleOsgiServiceRegistrationListener.REGISTERED);
    assertEquals(0, SimpleOsgiServiceRegistrationListener.UNREGISTERED);
  }
View Full Code Here

  public void testNotifyListenersOnUnregistration() {
    assertEquals(0, SimpleOsgiServiceRegistrationListener.REGISTERED);
    assertEquals(0, SimpleOsgiServiceRegistrationListener.UNREGISTERED);

    ServiceRegistration reg = exporter.notifyListeners(new Object(), new HashMap(), new MockServiceRegistration());
    assertTrue(reg instanceof ServiceRegistrationDecorator);
    reg.unregister();

    assertEquals(1, SimpleOsgiServiceRegistrationListener.REGISTERED);
    assertEquals(1, SimpleOsgiServiceRegistrationListener.UNREGISTERED);
View Full Code Here

    for (int i = 0; i < clazz.length; i++) {
      names[i] = clazz[i].getName();
    }

    final Properties props = new Properties();
    final ServiceRegistration reg = new MockServiceRegistration();

    exporter.setBundleContext(new MockBundleContext() {

      public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
        assertTrue(service instanceof ServiceFactory);
View Full Code Here

    exporter.unregisterService(reg);
    ctrl.verify();
  }

  public void testLazyBeanServiceWithUsualBean() throws Exception {
    final ServiceRegistration reg = new MockServiceRegistration();
    final ServiceFactory[] factory = new ServiceFactory[1];

    Object service = new Object();

    BundleContext ctx = new MockBundleContext() {
View Full Code Here

    assertSame(service, factory[0].getService(null, null));
    beanFactoryControl.verify();
  }

  public void testLazyBeanServiceWithServiceFactoryBean() throws Exception {
    final ServiceRegistration reg = new MockServiceRegistration();
    final ServiceFactory[] factory = new ServiceFactory[1];

    final Object actualService = new Object();
    Object service = new ServiceFactory() {
View Full Code Here

    assertSame(actualService, factory[0].getService(null, null));
    beanFactoryControl.verify();
  }

  public void testLazyBeanServiceWithTargetObjectSet() throws Exception {
    final ServiceRegistration reg = new MockServiceRegistration();
    final ServiceFactory[] factory = new ServiceFactory[1];

    Object service = new Object();

    BundleContext ctx = new MockBundleContext() {
View Full Code Here

    MockBundleContext mCtx = new MockBundleContext() {

      public ServiceRegistration registerService(String clazz[], Object service, Dictionary properties) {
        counters[0]++;
        return new MockServiceRegistration(clazz, properties) {

          public void unregister() {
            counters[1]++;
          }
        };
View Full Code Here

TOP

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

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.