MessageSenderFactory { public MessageSender create(Subscription subscription) { EndpointAddress endpoint = subscription.getEndpoint(); ProtocolMessageSenderProvider provider = protocolProviders.get(endpoint.getProtocol()); if (provider == null) { throw new EndpointProtocolNotSupportedException(endpoint); } return provider.create(subscription); }  MessageSender create(Subscription subscription); void addSupportedProtocol(String protocol, ProtocolMessageSenderProvider provider); void overrideProtocol(String protocol, ProtocolMessageSenderProvider provider); void startProvider(ProtocolMessageSenderProvider provider); void closeProviders();  }
@Test public void shouldGetProtocolNotSupportedExceptionWhenPassingUnknownUri() { Subscription subscription = subscription("group.topic", "subscription", "unknown: catchException(factory).create(subscription); assertThat(CatchException.<EndpointProtocolNotSupportedException>caughtException()) .isInstanceOf(EndpointProtocolNotSupportedException.class); }