### Question:
JMSContinuationProvider implements ContinuationProvider { public Continuation getContinuation() { Message m = inMessage; if (m != null && m.getExchange() != null && m.getExchange().getInMessage() != null) { m = m.getExchange().getInMessage(); } if (m == null || m.getExchange() == null || m.getExchange().isOneWay()) { return null; } JMSContinuation cw = m.get(JMSContinuation.class); if (cw == null) { cw = new JMSContinuation(bus, m, incomingObserver, suspendendContinuations); m.put(JMSContinuation.class, cw); } return cw; } JMSContinuationProvider(Bus b,
                                   Message m,
                                   MessageObserver observer,
                                   Counter suspendendContinuations); void complete(); Continuation getContinuation();  }### Answer:
@Test public void testNoContinuationForOneWay() { Exchange exchange = new ExchangeImpl(); exchange.setOneWay(true); Message m = new MessageImpl(); m.setExchange(exchange); Counter counter = EasyMock.createMock(Counter.class); JMSContinuationProvider provider = new JMSContinuationProvider(null, m, null, counter); assertNull(provider.getContinuation()); }
@Test public void testGetNewContinuation() { Message m = new MessageImpl(); m.setExchange(new ExchangeImpl()); Counter counter = EasyMock.createMock(Counter.class); JMSContinuationProvider provider = new JMSContinuationProvider(bus, m, null, counter); Continuation cw = provider.getContinuation(); assertTrue(cw.isNew()); assertSame(cw, m.get(JMSContinuation.class)); }
@Test public void testGetExistingContinuation() { Message m = new MessageImpl(); m.setExchange(new ExchangeImpl()); Counter counter = EasyMock.createMock(Counter.class); JMSContinuation cw = new JMSContinuation(bus, m, null, counter); m.put(JMSContinuation.class, cw); JMSContinuationProvider provider = new JMSContinuationProvider(null, m, null, counter); assertSame(cw, provider.getContinuation()); assertSame(cw, m.get(JMSContinuation.class)); }