qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1613425 - in /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test: client/RollbackOrderTest.java unit/transacted/CommitRollbackTest.java
Date Fri, 25 Jul 2014 12:56:00 GMT
Author: kwall
Date: Fri Jul 25 12:56:00 2014
New Revision: 1613425

URL: http://svn.apache.org/r1613425
Log:
NO-JIRA: [Java System Tests] Remove duplicated test

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java?rev=1613425&r1=1613424&r2=1613425&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/RollbackOrderTest.java
Fri Jul 25 12:56:00 2014
@@ -82,6 +82,7 @@ import java.util.concurrent.atomic.Atomi
  * the race condition occurred. However, performing that check will only validate
  * the problem exists and will not be suitable as part of a system test.
  *
+ * @see org.apache.qpid.test.unit.transacted.CommitRollbackTest
  */
 public class RollbackOrderTest extends QpidBrokerTestCase
 {
@@ -118,13 +119,12 @@ public class RollbackOrderTest extends Q
             assertEquals("Incorrect Message Received", 0, msg.getIntProperty(INDEX));
 
             // Pull additional messages through so we have some reject work to do
-            for (int m=0; m < 5 ; m++)
+            for (int m=1; m <= 5 ; m++)
             {
-                _consumer.receive();
+                msg = _consumer.receive();
+                assertEquals("Incorrect Message Received (message " + m + ")", m, msg.getIntProperty(INDEX));
             }
 
-            System.err.println("ROT-Rollback");
-            _logger.warn("ROT-Rollback");
             _session.rollback();
         }
     }
@@ -183,7 +183,7 @@ public class RollbackOrderTest extends Q
         }
 
         _connection.close();
-        
+
         assertFalse("Exceptions thrown during test run, Check Std.err.", failed.get());
     }
 }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java?rev=1613425&r1=1613424&r2=1613425&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
Fri Jul 25 12:56:00 2014
@@ -44,11 +44,14 @@ import java.util.concurrent.TimeUnit;
  * This class tests a number of commits and roll back scenarios
  *
  * Assumptions; - Assumes empty Queue
+ *
+ * @see org.apache.qpid.test.client.RollbackOrderTest
  */
 public class CommitRollbackTest extends QpidBrokerTestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(CommitRollbackTest.class);
-    private static final int POSIITIVE_TIMEOUT = 2000;
+    private static final int POSITIVE_TIMEOUT = 2000;
+    private static final int NEGATIVE_TIMEOUT = 250;
 
     protected AMQConnection _conn;
     private Session _session;
@@ -57,15 +60,6 @@ public class CommitRollbackTest extends 
     private MessageConsumer _consumer;
     private Queue _jmsQueue;
 
-    private boolean _gotone = false;
-    private boolean _gottwo = false;
-    private boolean _gottwoRedelivered = false;
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
     private void newConnection() throws Exception
     {
         _logger.debug("calling newConnection()");
@@ -106,7 +100,7 @@ public class CommitRollbackTest extends 
         newConnection();
 
         _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(NEGATIVE_TIMEOUT);
 
         // commit to ensure message is removed from queue
         _session.commit();
@@ -114,38 +108,6 @@ public class CommitRollbackTest extends 
         assertNull("test message was put and disconnected before commit, but is still present",
result);
     }
 
-    /**
-     * PUT a text message, disconnect before commit, confirm it is gone.
-     *
-     * @throws Exception On error
-     */
-    public void testPutThenCloseDisconnect() throws Exception
-    {
-        newConnection();
-
-        assertTrue("session is not transacted", _session.getTransacted());
-        assertTrue("session is not transacted", _pubSession.getTransacted());
-
-        _logger.info("sending test message");
-        String MESSAGE_TEXT = "testPutThenDisconnect";
-        _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
-
-        _logger.info("closing publisher without commit");
-        _publisher.close();
-
-        _logger.info("reconnecting without commit");
-        _conn.close();
-
-        newConnection();
-
-        _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
-
-        // commit to ensure message is removed from queue
-        _session.commit();
-
-        assertNull("test message was put and disconnected before commit, but is still present",
result);
-    }
 
     /**
      * PUT a text message, rollback, confirm message is gone. The consumer is on the same
connection but different
@@ -168,7 +130,7 @@ public class CommitRollbackTest extends 
         _pubSession.rollback();
 
         _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(NEGATIVE_TIMEOUT);
 
         assertNull("test message was put and rolled back, but is still present", result);
     }
@@ -193,7 +155,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("getting test message");
 
-        Message msg = _consumer.receive(1000);
+        Message msg = _consumer.receive(POSITIVE_TIMEOUT);
         assertNotNull("retrieved message is null", msg);
 
         _logger.info("closing connection");
@@ -202,7 +164,7 @@ public class CommitRollbackTest extends 
         newConnection();
 
         _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(NEGATIVE_TIMEOUT);
 
         _session.commit();
 
@@ -231,7 +193,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("getting test message");
 
-        Message msg = _consumer.receive(1000);
+        Message msg = _consumer.receive(POSITIVE_TIMEOUT);
         assertNotNull("retrieved message is null", msg);
         assertEquals("test message was correct message", MESSAGE_TEXT, ((TextMessage) msg).getText());
 
@@ -242,7 +204,7 @@ public class CommitRollbackTest extends 
         newConnection();
 
         _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(POSITIVE_TIMEOUT);
 
         _session.commit();
 
@@ -271,7 +233,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("getting test message");
 
-        Message msg = _consumer.receive(1000);
+        Message msg = _consumer.receive(POSITIVE_TIMEOUT);
 
         assertNotNull("retrieved message is null", msg);
         assertEquals("test message was correct message", MESSAGE_TEXT, ((TextMessage) msg).getText());
@@ -282,7 +244,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("receiving result");
 
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(POSITIVE_TIMEOUT);
 
         _session.commit();
         assertNotNull("test message was consumed and rolled back, but is gone", result);
@@ -311,7 +273,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("getting test message");
 
-        Message msg = _consumer.receive(1000);
+        Message msg = _consumer.receive(POSITIVE_TIMEOUT);
 
         assertNotNull("retrieved message is null", msg);
         assertEquals("test message was correct message", MESSAGE_TEXT, ((TextMessage) msg).getText());
@@ -326,7 +288,7 @@ public class CommitRollbackTest extends 
 
         _consumer = _session.createConsumer(_jmsQueue);
 
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(POSITIVE_TIMEOUT);
 
         _session.commit();
         assertNotNull("test message was consumed and rolled back, but is gone", result);
@@ -335,107 +297,7 @@ public class CommitRollbackTest extends 
     }
 
     /**
-     * Test that rolling back a session purges the dispatcher queue, and the messages arrive
in the correct order
-     *
-     * @throws Exception On error
-     */
-    public void testSend2ThenRollback() throws Exception
-    {
-        newConnection();
-
-        int run = 0;
-        while (run < 10)
-        {
-            run++;
-            _logger.info("Run:" + run);
-            assertTrue("session is not transacted", _session.getTransacted());
-            assertTrue("session is not transacted", _pubSession.getTransacted());
-
-            _logger.info("sending two test messages");
-            _publisher.send(_pubSession.createTextMessage("1"));
-            _publisher.send(_pubSession.createTextMessage("2"));
-            _pubSession.commit();
-
-            _logger.info("getting test message");
-            assertEquals("1", ((TextMessage) _consumer.receive(1000)).getText());
-
-            _logger.info("rolling back");
-            _session.rollback();
-
-            _logger.info("receiving result");
-            Message result = _consumer.receive(1000);
-
-            assertNotNull("test message was consumed and rolled back, but is gone", result);
-
-            // Message Order is:
-
-            // Send 1 , 2
-            // Retrieve 1 and then rollback
-            // Receieve 1 (redelivered) , 2 (may or may not be redelivered??)
-
-            verifyMessages(result);
-
-            // Occassionally get message 2 first!
-//            assertEquals("Should get message one first", "1", ((TextMessage) result).getText());
-//            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
-//
-//            result = _consumer.receive(1000);
-//            assertEquals("Second message should be message 2", "2", ((TextMessage) result).getText());
-//            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
-//
-//            result = _consumer.receive(1000);
-//            assertNull("There should be no more messages", result);
-
-            _session.commit();
-        }
-    }
-
-    private void verifyMessages(Message result) throws JMSException
-    {
-
-        if (result == null)
-        {
-            assertTrue("Didn't receive redelivered message one", _gotone);
-            assertTrue("Didn't receive message two at all", _gottwo | _gottwoRedelivered);
-            _gotone = false;
-            _gottwo = false;
-            _gottwoRedelivered = false;
-            return;
-        }
-
-        if (((TextMessage) result).getText().equals("1"))
-        {
-            _logger.info("Got 1 redelivered");
-            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
-            assertFalse("Already received message one", _gotone);
-            _gotone = true;
-
-        }
-        else
-        {
-            assertEquals("2", ((TextMessage) result).getText());
-
-            if (result.getJMSRedelivered())
-            {
-                _logger.info("Got 2 redelivered, message was prefetched");
-                assertFalse("Already received message redelivered two", _gottwoRedelivered);
-
-                _gottwoRedelivered = true;
-            }
-            else
-            {
-                _logger.warn("Got 2, message prefetched wasn't cleared or messages was in
transit when rollback occured");
-                assertFalse("Already received message two", _gottwo);
-                assertFalse("Already received message redelivered two", _gottwoRedelivered);
-                _gottwo = true;
-            }
-        }
-
-        verifyMessages(_consumer.receive(1000));
-    }
-
-    /**
-     * This test sends two messages receives on of them but doesn't ack it.
+     * This test sends two messages receives one of them but doesn't ack it.
      * The consumer is then closed
      * the first message should be returned as redelivered.
      *  the second message should be delivered normally.
@@ -454,11 +316,11 @@ public class CommitRollbackTest extends 
         _pubSession.commit();
 
         _logger.info("getting test message");
-        Message result = _consumer.receive(5000);
+        Message result = _consumer.receive(POSITIVE_TIMEOUT);
 
         assertNotNull("Message received should not be null", result);
         assertEquals("1", ((TextMessage) result).getText());
-        assertTrue("Messasge is marked as redelivered" + result, !result.getJMSRedelivered());
+        assertTrue("Message is marked as redelivered" + result, !result.getJMSRedelivered());
 
         _logger.info("Closing Consumer");
         
@@ -471,7 +333,7 @@ public class CommitRollbackTest extends 
 
 
         // Message 2 may be marked as redelivered if it was prefetched.
-        result = _consumer.receive(5000);
+        result = _consumer.receive(POSITIVE_TIMEOUT);
         assertNotNull("Second message was not consumed, but is gone", result);
 
         // The first message back will be 2, message 1 has been received but not committed
@@ -480,10 +342,10 @@ public class CommitRollbackTest extends 
         // if this is message 1 then it should be marked as redelivered
         if("1".equals(((TextMessage) result).getText()))
         {
-            fail("First message was recieved again");
+            fail("First message was received again");
         }
 
-        result = _consumer.receive(1000);
+        result = _consumer.receive(NEGATIVE_TIMEOUT);
         assertNull("test message should be null:" + result, result);
 
         _session.commit();
@@ -502,7 +364,7 @@ public class CommitRollbackTest extends 
         _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
         _pubSession.commit();
 
-        assertNotNull(_consumer.receive(1000));
+        assertNotNull(_consumer.receive(POSITIVE_TIMEOUT));
 
         _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
 
@@ -510,14 +372,14 @@ public class CommitRollbackTest extends 
         _pubSession.rollback();
 
         _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+        Message result = _consumer.receive(NEGATIVE_TIMEOUT);
         assertNull("test message was put and rolled back, but is still present", result);
 
         _publisher.send(_pubSession.createTextMessage(MESSAGE_TEXT));
 
         _pubSession.commit();
 
-        assertNotNull(_consumer.receive(100));
+        assertNotNull(_consumer.receive(POSITIVE_TIMEOUT));
 
         _session.commit();
     }
@@ -600,7 +462,7 @@ public class CommitRollbackTest extends 
 
         for (int i=0 ;i< maxPrefetch; i++)
         {
-            final Message message = _consumer.receive(POSIITIVE_TIMEOUT);
+            final Message message = _consumer.receive(POSITIVE_TIMEOUT);
             assertNotNull("Received:" + i, message);
             assertEquals("Unexpected message received", i, message.getIntProperty(INDEX));
         }
@@ -610,7 +472,7 @@ public class CommitRollbackTest extends 
 
         _logger.info("Receiving messages");
 
-        Message result = _consumer.receive(POSIITIVE_TIMEOUT);;
+        Message result = _consumer.receive(POSITIVE_TIMEOUT);;
         assertNotNull("Message expected", result);
         // Expect the first message
         assertEquals("Unexpected message received", 0, result.getIntProperty(INDEX));
@@ -667,15 +529,15 @@ public class CommitRollbackTest extends 
 
         _pubSession.commit();
 
-        assertNotNull("two messages were sent, but none has been received", _consumer.receive(1000));
+        assertNotNull("two messages were sent, but none has been received", _consumer.receive(POSITIVE_TIMEOUT));
 
         _session.rollback();
 
         _logger.info("receiving result");
 
-        assertNotNull("two messages were sent, but none has been received", _consumer.receive(1000));
-        assertNotNull("two messages were sent, but only one has been received", _consumer.receive(1000));
-        assertNull("Only two messages were sent, but more have been received", _consumer.receive(100));
+        assertNotNull("two messages were sent, but none has been received", _consumer.receive(POSITIVE_TIMEOUT));
+        assertNotNull("two messages were sent, but only one has been received", _consumer.receive(POSITIVE_TIMEOUT));
+        assertNull("Only two messages were sent, but more have been received", _consumer.receive(NEGATIVE_TIMEOUT));
 
         _session.commit();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message