Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockServiceReference


    assertTrue(containsClass(clazzes, SupportedValuesAttribute.class));
  }

  public void testExcludeFinalClass() throws Exception {
    String[] extraClasses = new String[] { Object.class.getName(), Byte.class.getName() };
    MockServiceReference ref = new MockServiceReference(addExtraIntfs(extraClasses));
    Class[] clazzes = proxyCreator.discoverProxyClasses(ref);
    assertEquals(2, clazzes.length);
    assertFalse(containsClass(clazzes, Byte.class));
    assertTrue(containsClass(clazzes, Comparable.class));
    assertTrue(containsClass(clazzes, Serializable.class));
View Full Code Here


  }

  public void testInterfacesOnlyAllowed() throws Exception {
    String[] extraClasses = new String[] { Object.class.getName() };

    MockServiceReference ref = new MockServiceReference(addExtraIntfs(extraClasses));
    Class[] clazzes = proxyCreator.discoverProxyClasses(ref);
    assertEquals(2, clazzes.length);
    assertFalse(containsClass(clazzes, Object.class));
  }
View Full Code Here

    Class[] classes = new Class[] { Serializable.class, Comparable.class, Date.class };
    proxyCreator = createProxyCreator(classes);

    String[] extraClasses = new String[] { LinkedHashMap.class.getName(), Date.class.getName() };

    MockServiceReference ref = new MockServiceReference(addExtraIntfs(extraClasses));
    Class[] clazzes = proxyCreator.discoverProxyClasses(ref);
    assertEquals(2, clazzes.length);
    assertTrue(containsClass(clazzes, LinkedHashMap.class));
    assertTrue(containsClass(clazzes, Date.class));
  }
View Full Code Here

  public void testRemoveParentsWithClassesAndInterfaces() throws Exception {
    Class[] classes = new Class[] { Serializable.class, Comparable.class, Date.class };
    proxyCreator = createProxyCreator(classes);
    String[] extraClasses = new String[] { Time.class.getName(), Cloneable.class.getName() };
    MockServiceReference ref = new MockServiceReference(addExtraIntfs(extraClasses));

    Class[] clazzes = proxyCreator.discoverProxyClasses(ref);
    assertEquals(1, clazzes.length);
    assertTrue(containsClass(clazzes, Time.class));
  }
View Full Code Here

  protected void tearDown() throws Exception {
    proxyCreator = null;
  }

  public void testCreatedProxy() throws Exception {
    MockServiceReference ref = new MockServiceReference();

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;
    assertTrue(proxy instanceof ImportedOsgiServiceProxy);
    assertTrue(proxy instanceof InfrastructureProxy);
  }
View Full Code Here

    assertTrue(proxy instanceof ImportedOsgiServiceProxy);
    assertTrue(proxy instanceof InfrastructureProxy);
  }

  public void testTargetProxy() throws Exception {
    final MockServiceReference ref = new MockServiceReference();
    final Object service = new Object();

    MockBundleContext ctx = new MockBundleContext() {

      public ServiceReference getServiceReference(String clazz) {
        return ref;
      }

      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return new ServiceReference[] { ref };
      }

      public Object getService(ServiceReference reference) {
        return (reference == ref ? service : super.getService(reference));
      }
    };

    proxyCreator = createProxyCreator(ctx, classes);
    InfrastructureProxy proxy = (InfrastructureProxy) proxyCreator.createServiceProxy(ref).proxy;
    assertEquals(service, proxy.getWrappedObject());
    InfrastructureProxy anotherProxy = (InfrastructureProxy) proxyCreator.createServiceProxy(new MockServiceReference()).proxy;
    assertFalse(proxy.equals(anotherProxy));
    assertFalse(anotherProxy.getWrappedObject().equals(proxy.getWrappedObject()));
  }
View Full Code Here


  protected void setUp() throws Exception {
    listener = new SimpleTargetSourceLifecycleListener();

    refs = new ServiceReference[] { new MockServiceReference() };

    bundleContext = new MockBundleContext() {

      public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
        return refs;
View Full Code Here

    Dictionary props = new Hashtable();
    // increase service ranking
    props.put(Constants.SERVICE_RANKING, new Integer(10));

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

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

    assertEquals(1, SimpleTargetSourceLifecycleListener.BIND);
    assertEquals(0, SimpleTargetSourceLifecycleListener.UNBIND);
View Full Code Here

  private ClassLoader classLoader = getClass().getClassLoader();

  protected void setUp() throws Exception {
    service = new Object();

    ServiceReference reference = new MockServiceReference();

    BundleContext ctx = new MockBundleContext() {
      public Object getService(ServiceReference reference) {
        return service;
      }
View Full Code Here

    assertEquals(new Integer(service.hashCode()), interceptor.invoke(invocation));
  }

  public void testInvocationWhenServiceNA() throws Throwable {
    // service n/a
    ServiceReference reference = new MockServiceReference() {
      public Bundle getBundle() {
        return null;
      }
    };
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.