Package org.springframework.osgi.mock

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


    int i = 0;
    for (Iterator iter = intfs.iterator(); iter.hasNext();) {
      clazzez[i++] = ((Class) iter.next()).getName();
    }

    ref = new MockServiceReference(null, properties, null, clazzez);

    event = new ServiceEvent(ServiceEvent.REGISTERED, ref);

    services.put(ref, service);
View Full Code Here

  protected void addService(Object service) {
    addService(service, new Properties());
  }

  protected void removeService(Object service) {
    ServiceReference ref = new MockServiceReference();

    for (Iterator iter = services.entrySet().iterator(); iter.hasNext();) {
      Map.Entry entry = (Map.Entry) iter.next();
      if (entry.getValue().equals(service)) {
        ref = (ServiceReference) entry.getKey();
View Full Code Here

  private ServiceReference ref;


  protected void setUp() throws Exception {
    ref = new MockServiceReference();
    bundleContext = new MockBundleContext() {

      public ServiceReference getServiceReference(String clazz) {
        return ref;
      }
View Full Code Here

    };

    ServiceDynamicInterceptor interceptorA1 = createInterceptorWServiceRequired();
    interceptorA1.setRetryTimeout(10);

    Advice interceptorB1 = new ServiceStaticInterceptor(bundleContext, new MockServiceReference());

    InterfaceWithEquals proxyA = (InterfaceWithEquals) createProxy(target, InterfaceWithEquals.class,
      new Advice[] { interceptorA1 });
    InterfaceWithEquals proxyB = (InterfaceWithEquals) createProxy(target, InterfaceWithEquals.class,
      new Advice[] { interceptorB1 });
View Full Code Here

  }

  public void testSpringInfrastructureProxyOnImportersWithDifferentRefs() throws Exception {
    Object service = new Object();
    BundleContext ctx = createObjectTrackingBundleContext(service);
    ServiceInvoker invokerA = new ServiceStaticInterceptor(ctx, new MockServiceReference());
    ServiceInvoker invokerB = new ServiceStaticInterceptor(ctx, new MockServiceReference());
    InfrastructureProxy proxyA = new InfrastructureOsgiProxyAdvice(invokerA);
    InfrastructureProxy proxyB = new InfrastructureOsgiProxyAdvice(invokerB);

    assertFalse("invokers should not be equal (they have different service references)", invokerA.equals(invokerB));
    assertFalse("proxies should not be equal", proxyA.equals(proxyB));
View Full Code Here

    mc.verify();
    registration = null;
  }

  public void testGetReference() {
    ServiceReference reference = new MockServiceReference();
    mc.expectAndReturn(actualRegistration.getReference(), reference);
    mc.replay();

    assertSame(reference, registration.getReference());
  }
View Full Code Here

    registration.setProperties(props);
  }

  public void testUnregister() {
    ServiceReference reference = new MockServiceReference();
    mc.expectAndReturn(actualRegistration.getReference(), reference);
    actualRegistration.unregister();
    mc.replay();

    registration.unregister();
View Full Code Here

  }

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

    ServiceReference reference = new MockServiceReference();
    mc.expectAndReturn(actualRegistration.getReference(), reference);
    actualRegistration.unregister();
    mc.replay();

    registration.unregister();
View Full Code Here

  public void testNullSafeToStringBundleEventInvalidType() throws Exception {
    assertEquals("UNKNOWN EVENT TYPE", OsgiStringUtils.nullSafeToString(new BundleEvent(-123, bundle)));
  }

  public void testNullSafeToStringServiceEvent() throws Exception {
    ServiceReference ref = new MockServiceReference();
    assertEquals("REGISTERED", OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.REGISTERED, ref)));
    assertEquals("MODIFIED", OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.MODIFIED, ref)));
    assertEquals("UNREGISTERING",
      OsgiStringUtils.nullSafeToString(new ServiceEvent(ServiceEvent.UNREGISTERING, ref)));
  }
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.