activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r953865 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/decaf/internal/net/tcp/ main/decaf/net/ test/activemq/core/ test/decaf/net/
Date Fri, 11 Jun 2010 20:54:21 GMT
Author: tabish
Date: Fri Jun 11 20:54:20 2010
New Revision: 953865

URL: http://svn.apache.org/viewvc?rev=953865&view=rev
Log:
Fix a case where an invalid exception from Socket connect can get thrown that terminates the
app found while testing pyActiveMQ

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.cpp
Fri Jun 11 20:54: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/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/tcp/TcpSocket.h Fri
Jun 11 20:54: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/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Socket.cpp Fri Jun 11 20:54: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/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.cpp
Fri Jun 11 20:54: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/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/core/ActiveMQConnectionFactoryTest.h
Fri Jun 11 20:54: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();
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp Fri Jun 11
20:54: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/trunk/activemq-cpp/src/test/decaf/net/SocketTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.h?rev=953865&r1=953864&r2=953865&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.h Fri Jun 11 20:54: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