JmsProducer extends JmsProducerImpl { @SuppressWarnings("unchecked") public <T extends JmsProducer> T withEndpoint(String s) { setEndpoint(s); return (T) this; }  @Override void prepare(); @Override @Deprecated @Removal(version = "4.0") void produce(AdaptrisMessage msg, ProduceDestination dest); @Override @Deprecated @Removal(version = "4.0") AdaptrisMessage request(AdaptrisMessage msg, ProduceDestination dest, long timeout); @Override AdaptrisMessage request(AdaptrisMessage msg, long timeout); @Override void produce(AdaptrisMessage msg); @Override String endpoint(AdaptrisMessage msg); @Override boolean perMessageProperties(); @SuppressWarnings("unchecked") T withEndpoint(String s);  }
@Test public void testNotTransactedNoRollback() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(false); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.rollback(); verify(mockSession, times(0)).rollback(); }
@Test public void testNullMessageAck() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(false); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(null); verify(mockMessage, times(0)).acknowledge(); }
@Test public void testMessageAckNotTransacted() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(false); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(mockMessage); verify(mockMessage).acknowledge(); }
@Test public void testMessageAckTransacted() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(true); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(mockMessage); verify(mockMessage, times(0)).acknowledge(); }
@Test public void testMessageAckTransactedAutoMode() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(true); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setAcknowledgeMode("AUTO_ACKNOWLEDGE"); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(mockMessage); verify(mockMessage, times(0)).acknowledge(); }
@Test public void testMessageAckNonTransactedAutoMode() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(false); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setAcknowledgeMode("AUTO_ACKNOWLEDGE"); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(mockMessage); verify(mockMessage, times(0)).acknowledge(); }
@Test public void testMessageAckNonTransactedClientMode() throws Exception { when(mockSessionFactory.createProducerSession(any(), any())) .thenReturn(mockProducerSession); when(mockProducerSession.getSession()) .thenReturn(mockSession); when(mockSession.getTransacted()) .thenReturn(false); JmsProducer producer = new JmsProducer().withEndpoint("myDestination"); producer.setSessionFactory(mockSessionFactory); producer.setAcknowledgeMode("CLIENT_ACKNOWLEDGE"); producer.setupSession(AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx")); producer.acknowledge(mockMessage); verify(mockMessage).acknowledge(); }