Author: tabish Date: Mon Dec 4 04:37:02 2006 New Revision: 482155 URL: http://svn.apache.org/viewvc?view=rev&rev=482155 Log: http://issues.apache.org/activemq/browse/AMQCPP-14
Added initail Time to Live processing to the Consumer, and the Time Stamping is now correct in the producer. Updated integ tests Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.cpp incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.h Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.cpp?view=diff&rev=482155&r1=482154&r2=482155 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.cpp (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.cpp Mon Dec 4 04:37:02 2006 @@ -19,7 +19,7 @@ #include <integration/common/IntegrationCommon.h> -//CPPUNIT_TEST_SUITE_REGISTRATION( integration::expiration::ExpirationTest ); +CPPUNIT_TEST_SUITE_REGISTRATION( integration::expiration::ExpirationTest ); #include <sstream> @@ -89,6 +89,7 @@ MessageProducer* producer; int numMessages; long long timeToLive; + bool disableTimeStamps; public: @@ -99,12 +100,21 @@ producer = NULL; this->numMessages = numMessages; this->timeToLive = timeToLive; + this->disableTimeStamps = false; } virtual ~Producer(){ cleanup(); } + virtual bool getDisableTimeStamps() const { + return disableTimeStamps; + } + + virtual void setDisableTimeStamps( bool value ) { + this->disableTimeStamps = value; + } + virtual void run() { try { // Create a ConnectionFactory @@ -123,6 +133,7 @@ producer = session->createProducer( destination ); producer->setDeliveryMode( DeliveryMode::PERSISTANT ); + producer->setDisableMessageTimeStamp( disableTimeStamps ); //unsigned long ttt=getcurt(); producer->setTimeToLive( 1); @@ -291,30 +302,37 @@ void ExpirationTest::testExpired() { - Producer producer( 2, 1 ); + Producer producer( 1, 1 ); Thread producerThread( &producer ); producerThread.start(); producerThread.join(); + Thread::sleep( 100 ); + Consumer consumer( 2000 ); Thread consumerThread( &consumer ); consumerThread.start(); consumerThread.join(); + Thread::sleep( 100 ); + CPPUNIT_ASSERT( consumer.getNumReceived() == 0 ); } void ExpirationTest::testNotExpired() { Producer producer( 2, 2000 ); + producer.setDisableTimeStamps( true ); Thread producerThread( &producer ); producerThread.start(); producerThread.join(); - Consumer consumer( 2000 ); + Consumer consumer( 3000 ); Thread consumerThread( &consumer ); consumerThread.start(); consumerThread.join(); + + Thread::sleep( 50 ); CPPUNIT_ASSERT( consumer.getNumReceived() == 2 ); } Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.h URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.h?view=diff&rev=482155&r1=482154&r2=482155 ============================================================================== --- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.h (original) +++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/integration/expiration/ExpirationTest.h Mon Dec 4 04:37:02 2006 @@ -36,8 +36,8 @@ class ExpirationTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( ExpirationTest ); - //CPPUNIT_TEST( testExpired ); - //CPPUNIT_TEST( testNotExpired ); + CPPUNIT_TEST( testExpired ); + CPPUNIT_TEST( testNotExpired ); CPPUNIT_TEST_SUITE_END(); public: