コード例 #1
0
  @SuppressWarnings("unchecked")
  public void test5NoSuitableEndpointFound() throws Exception {
    ServiceResolverRegistry registry =
        OsgiSupport.getReference(bundleContext, ServiceResolverRegistry.class);
    registry.register(resolverMock, resolverProps);

    EndpointDescription endpointMock = createMock(EndpointDescription.class);
    ServiceDescription serviceMock = createMock(ServiceDescription.class);

    List<EndpointDescription> endpoints = new ArrayList<EndpointDescription>();
    endpoints.add(endpointMock);

    expect(resolverMock.getEndpointsFor(service2Interface, null)).andReturn(endpoints).once();
    expect(endpointMock.getServiceName()).andReturn(new QName("dummy", "dummy")).times(2);
    expect(endpointMock.getAddress()).andReturn("non-existing-one").once();
    expect(endpointMock.getName()).andReturn("endpoint-name").once();

    replay(resolverMock);
    replay(endpointMock);
    replay(serviceMock);

    try {
      setExchangeThroughNMR();
      fail("The routing of exchange must fail");
    } catch (RuntimeException e) {
      // expected result
    }

    verify(resolverMock);
    verify(endpointMock);
    verify(serviceMock);
  }
コード例 #2
0
  /** @throws Exception */
  public void test3SuccessfullResolverSequence() throws Exception {
    ServiceResolverRegistry registry =
        OsgiSupport.getReference(bundleContext, ServiceResolverRegistry.class);
    registry.register(resolverMock, resolverProps);

    EndpointDescription endpointMock = createMock(EndpointDescription.class);
    ServiceDescription<?> serviceMock = createMock(ServiceDescription.class);

    List<EndpointDescription> endpoints = new ArrayList<EndpointDescription>();
    endpoints.add(endpointMock);

    expect(resolverMock.getEndpointsFor(service2Interface, null)).andReturn(endpoints).once();
    expect(endpointMock.getMetadata()).andReturn(null);
    expect(endpointMock.getServiceName()).andReturn(service2).once();

    replay(resolverMock);
    replay(endpointMock);
    replay(serviceMock);

    setExchangeThroughNMR();

    verify(resolverMock);
    verify(endpointMock);
    verify(serviceMock);
  }
コード例 #3
0
  public void test7ServiceResolverNoPolicyMatching() throws Exception {
    ServiceResolverRegistry registry =
        OsgiSupport.getReference(bundleContext, ServiceResolverRegistry.class);
    ServiceResolver resolver = registry.getKeys().get(0);
    assertNotNull("Couldn't find the ServiceResolver service", resolver);

    Collection<EndpointDescription> c =
        resolver.getEndpointsFor(
            new QName("http://service.dynamic.samples.swordfish.eclipse.org/", "FlightService"));
    assertNotNull("No endpoints resolved. ", c);
    assertEquals(c.size(), 1);
    assertEquals(
        c.iterator().next().getServiceName(),
        new QName("http://service.dynamic.samples.swordfish.eclipse.org/", "FlightServiceImpl"));
  }
コード例 #4
0
  public void test4FailedNoServiceDescription() throws Exception {
    ServiceResolverRegistry registry =
        OsgiSupport.getReference(bundleContext, ServiceResolverRegistry.class);
    registry.register(resolverMock, resolverProps);

    List<EndpointDescription> endpointsEmpty = new ArrayList<EndpointDescription>();

    expect(resolverMock.getEndpointsFor(service2Interface, null)).andReturn(endpointsEmpty).once();
    replay(resolverMock);

    try {
      setExchangeThroughNMR();
      fail("The routing of exchange must fail");
    } catch (RuntimeException e) {
      // expected result
    }
    verify(resolverMock);
  }
コード例 #5
0
  /**
   * The testcase sends the messageExchange through the nmr. Checks if the serviceResolver was
   * actually invoked inside the nmr
   */
  public void test2SuccessfullResolverUsingStub() throws Exception {
    ServiceDescriptionStub stubDescr = new ServiceDescriptionStub(service2);
    EndpointDescriptionStub stubEndp = new EndpointDescriptionStub(stubDescr);

    List<EndpointDescription> stubEndpoints = new ArrayList<EndpointDescription>();
    stubEndpoints.add(stubEndp);

    ServiceResolverRegistry registry =
        OsgiSupport.getReference(bundleContext, ServiceResolverRegistry.class);
    registry.register(resolverMock, resolverProps);

    expect(resolverMock.getEndpointsFor(service2Interface, null)).andStubReturn(stubEndpoints);
    replay(resolverMock);

    setExchangeThroughNMR();

    verify(resolverMock);
  }