activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1434771 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test: SimpleTest.cpp SimpleTest.h openwire/OpenwireSimpleTest.h
Date Thu, 17 Jan 2013 16:37:52 GMT
Author: tabish
Date: Thu Jan 17 16:37:52 2013
New Revision: 1434771

URL: http://svn.apache.org/viewvc?rev=1434771&view=rev
Log:
another test for: https://issues.apache.org/jira/browse/AMQCPP-448

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp?rev=1434771&r1=1434770&r2=1434771&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.cpp
Thu Jan 17 16:37:52 2013
@@ -400,6 +400,81 @@ void SimpleTest::testBytesMessageSendRec
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class Listener : public cms::MessageListener {
+    private:
+
+        bool passed;
+        bool triggered;
+
+    public:
+
+        Listener() : MessageListener(), passed(false), triggered(false) {}
+
+        virtual ~Listener() {}
+
+        bool isPassed() {
+            return passed;
+        }
+
+        bool isTriggered() {
+            return triggered;
+        }
+
+        void onMessage( const cms::Message* message ) {
+            try {
+                triggered = true;
+                const BytesMessage* bytesMessage = dynamic_cast<const cms::BytesMessage*>(
message );
+
+                CPPUNIT_ASSERT( bytesMessage != NULL );
+                CPPUNIT_ASSERT( bytesMessage->getBodyLength() > 0 );
+
+                unsigned char* result = bytesMessage->getBodyBytes();
+                CPPUNIT_ASSERT( result != NULL );
+                delete result;
+
+                passed = true;
+            } catch(...) {
+                passed = false;
+            }
+        }
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testBytesMessageSendRecvAsync() {
+
+    Listener listener;
+
+    // Create CMS Object for Comms
+    cms::Session* session(cmsProvider->getSession());
+    cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+    consumer->setMessageListener( &listener );
+    cms::MessageProducer* producer = cmsProvider->getProducer();
+    producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);
+
+    auto_ptr<cms::BytesMessage> bytesMessage(session->createBytesMessage());
+
+    bytesMessage->writeBoolean(true);
+    bytesMessage->writeByte(127);
+    bytesMessage->writeDouble(123456.789);
+    bytesMessage->writeInt(65537);
+    bytesMessage->writeString("TEST-STRING");
+
+    // Send some text messages
+    producer->send( bytesMessage.get() );
+
+    int count = 0;
+    while (!listener.isTriggered() && count++ < 30) {
+        decaf::lang::Thread::sleep(100);
+    }
+
+    CPPUNIT_ASSERT( listener.isPassed() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void SimpleTest::testLibraryInitShutdownInit() {
 
     {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h?rev=1434771&r1=1434770&r2=1434771&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/SimpleTest.h
Thu Jan 17 16:37:52 2013
@@ -42,6 +42,7 @@ namespace test{
         virtual void testReceiveAlreadyInQueue();
         virtual void testQuickCreateAndDestroy();
         virtual void testBytesMessageSendRecv();
+        virtual void testBytesMessageSendRecvAsync();
         virtual void testLibraryInitShutdownInit();
 
     };

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h?rev=1434771&r1=1434770&r2=1434771&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h
Thu Jan 17 16:37:52 2013
@@ -48,6 +48,7 @@ namespace openwire{
         CPPUNIT_TEST( testDestroyDestination );
         CPPUNIT_TEST( tesstStreamMessage );
         CPPUNIT_TEST( testLibraryInitShutdownInit );
+        CPPUNIT_TEST( testBytesMessageSendRecvAsync );
         CPPUNIT_TEST_SUITE_END();
 
     public:



Mime
View raw message