@Override public boolean getTransacted() throws JMSException { return next.getTransacted(); }
given(txSession.getTransacted()).willReturn(true); given(con.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE)).willReturn(nonTxSession);
@Override public boolean getTransacted() throws JMSException { return next.getTransacted(); }
/** * @return * @throws JMSException */ public boolean getTransacted() throws JMSException { return next.getTransacted(); }
@Override public boolean getTransacted() throws JMSException { return next.getTransacted(); }
@Override public boolean getTransacted() throws JMSException { return next.getTransacted(); }
/** * Test that the <code>getTransacted()</code> method of a <code>Session</code> returns <code>true</code> * if the session is transacted, <code>false</code> else. */ public void testGetTransacted() { try { // senderSession has been created as non transacted assertEquals(false, senderSession.getTransacted()); // we re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); assertEquals(true, senderSession.getTransacted()); } catch (Exception e) { fail(e); } }
/** * Test that an attempt to call the <code>recover()</code> method on a * <strong>transacted </strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ public void testRecoverTransactedSession() { try { // senderSession has been created as non transacted assertEquals(false, senderSession.getTransacted()); // we create it again but as a transacted session senderSession = senderConnection.createQueueSession(true, 0); assertEquals(true, senderSession.getTransacted()); senderSession.recover(); fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
/** * Test that the <code>getTransacted()</code> method of a <code>Session</code> returns <code>true</code> * if the session is transacted, <code>false</code> else. */ @Test public void testGetTransacted() { try { // senderSession has been created as non transacted Assert.assertEquals(false, senderSession.getTransacted()); // we re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); Assert.assertEquals(true, senderSession.getTransacted()); } catch (Exception e) { fail(e); } }
/** * Test that an attempt to call the <code>commit()</code> method on a * <strong>non transacted</strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ public void testCommitNonTransactedSession() { try { // senderSession has been created as non transacted in the setUp() method assertEquals(false, senderSession.getTransacted()); senderSession.commit(); fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
/** * Test that an attempt to call the <code>roolback()</code> method on a * <strong>non transacted</strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ public void testRollbackNonTransactedSession() { try { // senderSession has been created as non transacted in the setUp() method assertEquals(false, senderSession.getTransacted()); senderSession.rollback(); fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
/** * Test that an attempt to call the <code>recover()</code> method on a * <strong>transacted </strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ @Test public void testRecoverTransactedSession() { try { // senderSession has been created as non transacted Assert.assertEquals(false, senderSession.getTransacted()); // we create it again but as a transacted session senderSession = senderConnection.createQueueSession(true, 0); Assert.assertEquals(true, senderSession.getTransacted()); senderSession.recover(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
assertEquals(true, senderSession.getTransacted());
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ public void testRollbackTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testRollbackTransactedSession"); // send a message within a transacted session sender.send(message); // rollback the transaction -> the sent message shouldn't be received senderSession.rollback(); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received assertEquals(null, m); } catch (Exception e) { fail(e); } }
/** * Test that an attempt to call the <code>roolback()</code> method on a * <strong>non transacted</strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ @Test public void testRollbackNonTransactedSession() { try { // senderSession has been created as non transacted in the setUp() method Assert.assertEquals(false, senderSession.getTransacted()); senderSession.rollback(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
/** * Test that an attempt to call the <code>commit()</code> method on a * <strong>non transacted</strong> <code>Session</code> throws a * <code>javax.jms.IllegalStateException</code>. */ @Test public void testCommitNonTransactedSession() { try { // senderSession has been created as non transacted in the setUp() method Assert.assertEquals(false, senderSession.getTransacted()); senderSession.commit(); Assert.fail("Should raise an IllegalStateException, the session is not transacted.\n"); } catch (javax.jms.IllegalStateException e) { } catch (java.lang.IllegalStateException e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException.\n"); } catch (Exception e) { Assert.fail("Should raise a javax.jms.IllegalStateException, not a " + e); } }
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ @Test public void testCommitTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); Assert.assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testCommitTransactedSession"); // send a message within a transacted session sender.send(message); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received (the transaction has not been committed yet) Assert.assertEquals(null, m); // commit the transaction -> the sent message should be received senderSession.commit(); m = (TextMessage) receiver.receive(TestConfig.TIMEOUT); Assert.assertTrue(m != null); Assert.assertEquals("testCommitTransactedSession", m.getText()); } catch (Exception e) { fail(e); } }
/** * Test that a call to the <code>rollback()</code> method on a * <strong>transacted</strong> <code>Session</code> rollbacks all * the messages sent in the transaction. */ @Test public void testRollbackTransactedSession() { try { // re-create senderSession as a transacted session senderSession = senderConnection.createQueueSession(true, 0); sender = senderSession.createSender(senderQueue); Assert.assertEquals(true, senderSession.getTransacted()); TextMessage message = senderSession.createTextMessage(); message.setText("testRollbackTransactedSession"); // send a message within a transacted session sender.send(message); // rollback the transaction -> the sent message shouldn't be received senderSession.rollback(); TextMessage m = (TextMessage) receiver.receiveNoWait(); // test that no message has been received Assert.assertEquals(null, m); } catch (Exception e) { fail(e); } }
Assert.assertEquals(true, senderSession.getTransacted()); Assert.assertEquals(true, receiverSession.getTransacted());
Assert.assertEquals(true, senderSession.getTransacted()); Assert.assertEquals(true, receiverSession.getTransacted());