Examples of TestServiceTypeListener


Examples of org.eclipse.ecf.tests.discovery.listener.TestServiceTypeListener

   */
  public void testAddServiceTypeListener() throws ContainerConnectException {
    IServiceInfo[] services = discoveryLocator.getServices();
    assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);

    final TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
    discoveryLocator.addServiceTypeListener(testTypeListener);

    synchronized (testTypeListener) {
      // register a service which we expect the test listener to get notified of
      registerService();
      try {
        testTypeListener.wait(waitTimeForProvider);
      } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        fail("Some discovery unrelated threading issues?");
      }
    }
   
    discoveryLocator.removeServiceTypeListener(testTypeListener);
   
    IContainerEvent[] event = testTypeListener.getEvent();
    assertNotNull("Test listener didn't receive discovery", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
  }
View Full Code Here

Examples of org.eclipse.ecf.tests.discovery.listener.TestServiceTypeListener

   * @throws ContainerConnectException
   */
  public void testRemoveServiceTypeListener() throws ContainerConnectException {
    assertTrue("No Services must be registerd at this point", discoveryLocator.getServices().length == 0);

    final TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
    discoveryLocator.addServiceTypeListener(testTypeListener);

    synchronized (testTypeListener) {
      // register a service which we expect the test listener to get notified of
      registerService();
      try {
        testTypeListener.wait(waitTimeForProvider);
      } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        fail("Some discovery unrelated threading issues?");
      }
    }
   
    discoveryLocator.removeServiceTypeListener(testTypeListener);
   
    IContainerEvent[] event = testTypeListener.getEvent();
    assertNotNull("Test listener didn't receive any discovery event", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
   
    //TODO reregister and verify the listener doesn't receive any events any longer.
  }
View Full Code Here

Examples of org.eclipse.ecf.tests.discovery.listener.TestServiceTypeListener

 
  public void testAddServiceTypeListenerOSGi() throws ContainerConnectException {
    IServiceInfo[] services = discoveryLocator.getServices();
    assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);

    final TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
    Properties props = new Properties();
    props.put(IDiscoveryLocator.CONTAINER_NAME, containerUnderTest);
    BundleContext ctxt = Activator.getDefault().getContext();
    ServiceRegistration registration = ctxt.registerService(IServiceTypeListener.class.getName(), testTypeListener, props);

    synchronized (testTypeListener) {
      // register a service which we expect the test listener to get notified of
      registerService();
      try {
        testTypeListener.wait(waitTimeForProvider);
      } catch (final InterruptedException e) {
        Thread.currentThread().interrupt();
        fail("Some discovery unrelated threading issues?");
      }
    }
   
    registration.unregister();
   
    IContainerEvent[] event = testTypeListener.getEvent();
    assertNotNull("Test listener didn't receive discovery", event);
    assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.