activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r953868 - in /activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src: main/decaf/internal/net/tcp/ main/decaf/net/ test-integration/activemq/test/ test-integration/activemq/test/openwire/ test/activemq/core/ test/activemq/transp...
Date Fri, 11 Jun 2010 21:05:20 GMT
Author: tabish
Date: Fri Jun 11 21:05:20 2010
New Revision: 953868

URL: http://svn.apache.org/viewvc?rev=953868&view=rev
Log:
Add an additional transaction test and fixes issues with Socket.connect.

Modified:
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/net/Socket.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/transport/correlator/
  (props changed)
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.cpp
    activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.h

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
Fri Jun 11 21:05:20 2010
@@ -258,6 +258,7 @@ void TcpSocket::bind( const std::string&
 ////////////////////////////////////////////////////////////////////////////////
 void TcpSocket::connect( const std::string& hostname, int port, int timeout )
     throw( decaf::io::IOException,
+           decaf::net::SocketException,
            decaf::lang::exceptions::IllegalArgumentException ) {
 
     try{
@@ -307,10 +308,13 @@ void TcpSocket::connect( const std::stri
         ex.setMark( __FILE__, __LINE__);
         try{ close(); } catch( lang::Exception& cx){ /* Absorb */ }
         throw ex;
-    } catch( Exception& ex ) {
+    } catch( IllegalArgumentException& ex ) {
         ex.setMark( __FILE__, __LINE__);
         try{ close(); } catch( lang::Exception& cx){ /* Absorb */ }
         throw ex;
+    } catch( Exception& ex ) {
+        try{ close(); } catch( lang::Exception& cx){ /* Absorb */ }
+        throw SocketException( &ex );
     } catch( ... ) {
         try{ close(); } catch( lang::Exception& cx){ /* Absorb */ }
         throw SocketException(

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
Fri Jun 11 21:05:20 2010
@@ -182,6 +182,7 @@ namespace tcp {
          */
         virtual void connect( const std::string& hostname, int port, int timeout )
             throw( decaf::io::IOException,
+                   decaf::net::SocketException,
                    decaf::lang::exceptions::IllegalArgumentException );
 
         /**

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/net/Socket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/net/Socket.cpp?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/net/Socket.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/main/decaf/net/Socket.cpp
Fri Jun 11 21:05:20 2010
@@ -318,7 +318,7 @@ void Socket::connect( const std::string&
         try {
 
             if( !isBound() ) {
-                //this->impl->bind( "", 0 );
+                this->impl->bind( "", 0 );
                 this->bound = true;
             }
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.cpp
Fri Jun 11 21:05:20 2010
@@ -122,6 +122,47 @@ void TransactionTest::testSendRollback()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void TransactionTest::testSendRollbackCommitRollback() {
+
+    // Create CMS Object for Comms
+    cms::Session* session = cmsProvider->getSession();
+    cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+    cms::MessageProducer* producer = cmsProvider->getProducer();
+
+    producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+    auto_ptr<TextMessage> outbound1( session->createTextMessage( "First Message"
) );
+    auto_ptr<TextMessage> outbound2( session->createTextMessage( "Second Message"
) );
+
+    // sends them and then rolls back.
+    producer->send( outbound1.get() );
+    producer->send( outbound2.get() );
+    session->rollback();
+
+    // Send one and commit.
+    producer->send( outbound1.get() );
+    session->commit();
+
+    // receives the first message
+    auto_ptr<TextMessage> inbound1(
+        dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+    CPPUNIT_ASSERT( NULL == consumer->receive( 1500 ) );
+    CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+
+    session->rollback();
+
+    inbound1.reset(
+        dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+    CPPUNIT_ASSERT( NULL == consumer->receive( 1500 ) );
+    CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+
+    // validates that the rollbacked was not consumed
+    session->commit();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void TransactionTest::testSendSessionClose() {
 
     try {

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/TransactionTest.h
Fri Jun 11 21:05:20 2010
@@ -44,6 +44,7 @@ namespace test{
         void testSendRollback();
         void testSendSessionClose();
         void testWithTTLSet();
+        void testSendRollbackCommitRollback();
 
     };
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h
Fri Jun 11 21:05:20 2010
@@ -30,6 +30,7 @@ namespace openwire{
         CPPUNIT_TEST( testSendReceiveTransactedBatches );
         CPPUNIT_TEST( testSendRollback );
         CPPUNIT_TEST( testWithTTLSet );
+        CPPUNIT_TEST( testSendRollbackCommitRollback );
 //        CPPUNIT_TEST( testSendSessionClose );
         CPPUNIT_TEST_SUITE_END();
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
Fri Jun 11 21:05:20 2010
@@ -138,11 +138,28 @@ void ActiveMQConnectionFactoryTest::test
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ActiveMQConnectionFactoryTest::testExceptionWithPortOutOfRange() {
+    try
+    {
+        std::string URI = "tcp://127.0.0.2:70000";
+
+        ActiveMQConnectionFactory connectionFactory( URI );
+
+        auto_ptr<cms::Connection> connection(
+            connectionFactory.createConnection() );
+
+        CPPUNIT_ASSERT( false );
+    }
+    AMQ_CATCH_NOTHROW( exceptions::ActiveMQException )
+    AMQ_CATCHALL_NOTHROW( )
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ActiveMQConnectionFactoryTest::testExceptionOnCreate() {
     try
     {
         std::string URI =
-            "tcp://127.0.0.2:23232?wireFormat=openwire";
+            "tcp://127.0.0.2:23232?soConnectTimeout=3000";
 
         ActiveMQConnectionFactory connectionFactory( URI );
 

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
Fri Jun 11 21:05:20 2010
@@ -32,6 +32,7 @@ namespace core{
         CPPUNIT_TEST( testExceptionOnCreate );
         CPPUNIT_TEST( testCreateWithURIOptions );
         CPPUNIT_TEST( testTransportListener );
+        CPPUNIT_TEST( testExceptionWithPortOutOfRange );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -50,6 +51,7 @@ namespace core{
         void test1WithOpenWire();
         void test2WithOpenWire();
         void testExceptionOnCreate();
+        void testExceptionWithPortOutOfRange();
         void testCreateWithURIOptions();
         void testTransportListener();
 

Propchange: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/activemq/transport/correlator/
            ('svn:mergeinfo' removed)

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.cpp?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.cpp
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.cpp
Fri Jun 11 21:05:20 2010
@@ -49,6 +49,22 @@ void SocketTest::testConnectUnknownHost(
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testConnectPortOutOfRange() {
+
+    Socket s;
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw an IllegalArguementException",
+        s.connect( "0.0.0.0", 70000 ),
+        IllegalArgumentException );
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should Throw an IllegalArguementException",
+        s.connect( "0.0.0.0", 70000, 1000 ),
+        IllegalArgumentException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void SocketTest::testConstructor() {
 
     // create the socket and then validate some basic state

Modified: activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.h?rev=953868&r1=953867&r2=953868&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.h
(original)
+++ activemq/activemq-cpp/branches/activemq-cpp-3.2.x/activemq-cpp/src/test/decaf/net/SocketTest.h
Fri Jun 11 21:05:20 2010
@@ -43,6 +43,7 @@ namespace net{
         CPPUNIT_TEST( testIsClosed );
         CPPUNIT_TEST( testIsInputShutdown );
         CPPUNIT_TEST( testIsOutputShutdown );
+        CPPUNIT_TEST( testConnectPortOutOfRange );
 
         CPPUNIT_TEST( testTx );
         CPPUNIT_TEST( testTrx );
@@ -70,6 +71,7 @@ namespace net{
         void testIsClosed();
         void testIsInputShutdown();
         void testIsOutputShutdown();
+        void testConnectPortOutOfRange();
 
         // Old Tests
         void testConnect();



Mime
View raw message