Package org.springframework.osgi.mock

Examples of org.springframework.osgi.mock.MockServiceReference


    assertNotNull(OsgiStringUtils.nullSafeToString((ServiceEvent) null));
  }

  public void testNullSafeToStringServiceEventInvalidType() throws Exception {
    assertEquals("UNKNOWN EVENT TYPE", OsgiStringUtils.nullSafeToString(new ServiceEvent(-123,
      new MockServiceReference())));
  }
View Full Code Here


    MockBundle bundle = new MockBundle(symName);
    Properties props = new Properties();
    String header = "HEADER";
    String value = "VALUE";
    props.put(header, value);
    MockServiceReference ref = new MockServiceReference(bundle, props, null);
    String out = OsgiStringUtils.nullSafeToString(ref);
    assertTrue(out.indexOf(symName) > -1);
    assertTrue(out.indexOf(header) > -1);
    assertTrue(out.indexOf(value) > -1);
  }
View Full Code Here

    assertEquals(0, comparator.compare(null, null));
  }

  public void testNonNullWithNull() throws Exception {
    try {
      comparator.compare(new MockServiceReference(), null);
      fail("should have thrown exception");
    }
    catch (ClassCastException cce) {
    }
  }
View Full Code Here

    Dictionary dict = new Properties();
    dict.put(Constants.SERVICE_ID, id);
    if (ranking != null)
      dict.put(Constants.SERVICE_RANKING, ranking);

    return new MockServiceReference(null, dict, null);
  }
View Full Code Here

  }

  public void testHashCodeBetweenProxyAndTarget() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;

    assertFalse("proxy and service should have different hashcodes", date.hashCode() == proxy.hashCode());
View Full Code Here

  }

  public void testHashCodeBetweenProxies() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;
    Object proxy2 = proxyCreator.createServiceProxy(ref).proxy;
    assertEquals("proxies for the same service should have the same hashcode", proxy.hashCode(), proxy2.hashCode());
View Full Code Here

  }

  public void testEqualsBetweenProxyAndTarget() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;

    assertFalse("proxy and service should not be equal", date.equals(proxy));
View Full Code Here

  }

  public void testEqualsBetweenProxies() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;
    Object proxy2 = proxyCreator.createServiceProxy(ref).proxy;
    assertEquals("proxies for the same target should be equal", proxy, proxy2);
View Full Code Here

  }

  public void testHashCodeBetweenProxyAndItself() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;

    assertEquals("proxy should consistent hashcode", proxy.hashCode(), proxy.hashCode());
View Full Code Here

  }

  public void testEqualsBetweenProxyAndItself() {
    Date date = new Date(123);

    ServiceReference ref = new MockServiceReference(classInterfaces);
    services.put(ref, date);

    Object proxy = proxyCreator.createServiceProxy(ref).proxy;
    assertEquals("proxy should be equal to itself", proxy, proxy);
  }
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.