InterpolatingEndpointAddressResolver implements EndpointAddressResolver { @Override public URI resolve(EndpointAddress address, Message message, EndpointAddressResolverMetadata metadata) throws EndpointAddressResolutionException { try { return interpolator.interpolate(address, message); } catch (InterpolationException ex) { throw new EndpointAddressResolutionException(address, ex); } } @Inject  InterpolatingEndpointAddressResolver(UriInterpolator interpolator); @Override URI resolve(EndpointAddress address, Message message, EndpointAddressResolverMetadata metadata);  }
@Test public void shouldUseInterpolatorToInterpolateURI() throws InterpolationException, EndpointAddressResolutionException { EndpointAddress address = EndpointAddress.of("http: Message message = withTestMessage().withContent("content", StandardCharsets.UTF_8).build(); when(interpolator.interpolate(address, message)).thenReturn(URI.create("http: URI uri = resolver.resolve(EndpointAddress.of("http: withTestMessage().withContent("content", StandardCharsets.UTF_8).build(), metadata); assertThat(uri).isEqualTo(URI.create("http: }
@Test @SuppressWarnings("unchecked") public void shouldThrowResolvingExceptionWhenInterpolationFails() throws EndpointAddressResolutionException, InterpolationException { EndpointAddress address = EndpointAddress.of("http: Message message = withTestMessage().withContent("content", StandardCharsets.UTF_8).build(); when(interpolator.interpolate(address, message)).thenThrow(InterpolationException.class); catchException(resolver).resolve(EndpointAddress.of("http: withTestMessage().withContent("content", StandardCharsets.UTF_8).build(), metadata); assertThat(CatchException.<EndpointAddressResolutionException>caughtException()).isInstanceOf(EndpointAddressResolutionException.class); }