JmsTracing { public ConnectionFactory connectionFactory(ConnectionFactory connectionFactory) { if (connectionFactory instanceof XAConnectionFactory) { return (ConnectionFactory) xaConnectionFactory((XAConnectionFactory) connectionFactory); } return TracingConnectionFactory.create(connectionFactory, this); } JmsTracing(Builder builder); static JmsTracing create(Tracing tracing); static JmsTracing create(MessagingTracing messagingTracing); static Builder newBuilder(Tracing tracing); static Builder newBuilder(MessagingTracing messagingTracing); Connection connection(Connection connection); QueueConnection queueConnection(QueueConnection connection); TopicConnection topicConnection(TopicConnection connection); XAConnection xaConnection(XAConnection xaConnection); XAQueueConnection xaQueueConnection(XAQueueConnection connection); XATopicConnection xaTopicConnection(XATopicConnection connection); ConnectionFactory connectionFactory(ConnectionFactory connectionFactory); XAConnectionFactory xaConnectionFactory(XAConnectionFactory xaConnectionFactory); MessageListener messageListener(MessageListener messageListener, boolean addConsumerSpan); Span nextSpan(Message message);  }
@Test public void connectionFactory_wrapsInput() { assertThat(jmsTracing.connectionFactory(mock(ConnectionFactory.class))) .isInstanceOf(TracingConnectionFactory.class); }
@Test public void connectionFactory_doesntDoubleWrap() { ConnectionFactory wrapped = jmsTracing.connectionFactory(mock(ConnectionFactory.class)); assertThat(jmsTracing.connectionFactory(wrapped)) .isSameAs(wrapped); }
@Test public void connectionFactory_wrapsXaInput() { abstract class Both implements XAConnectionFactory, ConnectionFactory { } assertThat(jmsTracing.connectionFactory(mock(Both.class))) .isInstanceOf(XAConnectionFactory.class); }