Buggy code:
public class StompBrokerRelayMessageHandlerIntegrationTests { @ Rule public final TestName testName = new TestName ( ) ; private static final Log logger = LogFactory . getLog ( StompBrokerRelayMessageHandlerIntegrationTests . class ) ; private static final Charset UTF_8 = Charset . forName ( "UTF-8" ) ; private StompBrokerRelayMessageHandler relay ; private BrokerService activeMQBroker ; private ExecutorSubscribableChannel responseChannel ; private StompBrokerRelayMessageHandlerIntegrationTests . TestMessageHandler responseHandler ; private StompBrokerRelayMessageHandlerIntegrationTests . TestEventPublisher eventPublisher ; private int port ; @ Before public void setUp ( ) throws Exception { } private void startActiveMqBroker ( ) throws Exception { } private void createAndStartRelay ( ) throws InterruptedException { } @ After public void tearDown ( ) throws Exception { } private void stopActiveMqBrokerAndAwait ( ) throws Exception { } @ Test public void publishSubscribe ( ) throws Exception { } @ Test ( expected = MessageDeliveryException . class ) public void messageDeliveryExceptionIfSystemSessionForwardFails ( ) throws Exception { } @ Test public void brokerBecomingUnvailableTriggersErrorFrame ( ) throws Exception { } @ Test public void brokerAvailabilityEventWhenStopped ( ) throws Exception { } @ Test public void relayReconnectsIfBrokerComesBackUp ( ) throws Exception { } @ Test public void disconnectClosesRelaySessionCleanly ( ) throws Exception { } @ Test public void disconnectWithReceipt ( ) throws Exception { } private static class TestEventPublisher implements ApplicationEventPublisher { private final BlockingQueue < BrokerAvailabilityEvent > eventQueue = new LinkedBlockingQueue < > ( ) ; @ Override public void publishEvent ( ApplicationEvent event ) { } public void expectBrokerAvailabilityEvent ( boolean isBrokerAvailable ) throws InterruptedException { <START_BUG> BrokerAvailabilityEvent event = this . eventQueue . poll ( 10000 , TimeUnit . MILLISECONDS ) ; <END_BUG> assertNotNull ( ( ( "Times<seq2seq4repair_space>out<seq2seq4repair_space>waiting<seq2seq4repair_space>for<seq2seq4repair_space>BrokerAvailabilityEvent[" + isBrokerAvailable ) + "]" ) , event ) ; assertEquals ( isBrokerAvailable , event . isBrokerAvailable ( ) ) ; } } private static class TestMessageHandler implements MessageHandler { private final BlockingQueue < Message < ? > > queue = new LinkedBlockingQueue < > ( ) ; @ Override public void handleMessage ( Message < ? > message ) throws MessagingException { } public void expectMessages ( StompBrokerRelayMessageHandlerIntegrationTests . MessageExchange ... messageExchanges ) throws InterruptedException { } private StompBrokerRelayMessageHandlerIntegrationTests . MessageExchange findMatch ( List < StompBrokerRelayMessageHandlerIntegrationTests . MessageExchange > expectedMessages , Message < ? > message ) { } } private static class MessageExchange { private final Message < ? > message ; private final StompBrokerRelayMessageHandlerIntegrationTests . MessageMatcher [ ] expected ; private final Message < ? > [ ] actual ; public MessageExchange ( Message < ? > message , StompBrokerRelayMessageHandlerIntegrationTests . MessageMatcher ... expected ) { } public boolean matchMessage ( Message < ? > message ) { } @ Override public String toString ( ) { } } private static class MessageExchangeBuilder { private final Message < ? > message ; private final StompHeaderAccessor headers ; private final List < StompBrokerRelayMessageHandlerIntegrationTests . MessageMatcher > expected = new ArrayList < > ( ) ; private MessageExchangeBuilder ( Message < ? > message ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder error ( String sessionId ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder connect ( String sessionId ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder connectWithError ( String sessionId ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder subscribeWithReceipt ( String sessionId , String subscriptionId , String destination , String receiptId ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder send ( String destination , String payload ) { } public static StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder disconnectWithReceipt ( String sessionId , String receiptId ) { } public StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder andExpectMessage ( String sessionId , String subscriptionId ) { } public StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder andExpectError ( ) { } public StompBrokerRelayMessageHandlerIntegrationTests . MessageExchangeBuilder andExpectError ( String sessionId ) { } public StompBrokerRelayMessageHandlerIntegrationTests . MessageExchange build ( ) { } } private static interface MessageMatcher { boolean match ( Message < ? > message ) { } } private static class StompFrameMessageMatcher implements StompBrokerRelayMessageHandlerIntegrationTests . MessageMatcher { private final StompCommand command ; private final String sessionId ; public StompFrameMessageMatcher ( StompCommand command , String sessionId ) { } @ Override public final boolean match ( Message < ? > message ) { } protected boolean matchInternal ( StompHeaderAccessor headers , Object payload ) { } @ Override public String toString ( ) { } } private static class StompReceiptFrameMessageMatcher extends StompBrokerRelayMessageHandlerIntegrationTests . StompFrameMessageMatcher { private final String receiptId ; public StompReceiptFrameMessageMatcher ( String sessionId , String receipt ) { } @ Override protected boolean matchInternal ( StompHeaderAccessor headers , Object payload ) { } @ Override public String toString ( ) { } } private static class StompMessageFrameMessageMatcher extends StompBrokerRelayMessageHandlerIntegrationTests . StompFrameMessageMatcher { private final String subscriptionId ; private final String destination ; private final Object payload ; public StompMessageFrameMessageMatcher ( String sessionId , String subscriptionId , String destination , Object payload ) { } @ Override protected boolean matchInternal ( StompHeaderAccessor headers , Object payload ) { } @ Override public String toString ( ) { } protected String getPayloadAsText ( ) { } } private static class StompConnectedFrameMessageMatcher extends StompBrokerRelayMessageHandlerIntegrationTests . StompFrameMessageMatcher { public StompConnectedFrameMessageMatcher ( String sessionId ) { } } }

Fix:
BrokerAvailabilityEvent event = this . eventQueue . poll ( 20000 , TimeUnit . MILLISECONDS ) ;