Author: tabish
Date: Thu Apr 22 14:57:30 2010
New Revision: 936881
URL: http://svn.apache.org/viewvc?rev=936881&view=rev
Log:
Adds some new Socket tests
Modified:
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/test/decaf/net/SocketTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/SocketTest.cpp?rev=936881&r1=936880&r2=936881&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
Thu Apr 22 14:57:30 2010
@@ -29,11 +29,47 @@
using namespace std;
using namespace decaf;
+using namespace decaf::io;
using namespace decaf::net;
using namespace decaf::util;
using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testConnectUnknownHost() {
+
+ // TODO - Should throw an UnknownHostException
+ Socket s;
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "IOException should have been thrown",
+ s.connect( "unknown.host", 45 ),
+ IOException );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testConstructor() {
+
+ // create the socket and then validate some basic state
+ Socket s;
+ CPPUNIT_ASSERT_MESSAGE("new socket should not be connected",
!s.isConnected());
+ CPPUNIT_ASSERT_MESSAGE("new socket should not be bound", !s.isBound());
+ CPPUNIT_ASSERT_MESSAGE("new socket should not be closed", !s.isClosed());
+ CPPUNIT_ASSERT_MESSAGE("new socket should not be in InputShutdown",
!s.isInputShutdown());
+ CPPUNIT_ASSERT_MESSAGE("new socket should not be in OutputShutdown",
!s.isOutputShutdown());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SocketTest::testGetReuseAddress() {
+
+ Socket s;
+ s.setReuseAddress( true );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Socket Reuse Address value not what was
expected.", true, s.getReuseAddress() );
+ s.setReuseAddress( false );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Socket Reuse Address value not what was
expected.", false, s.getReuseAddress() );
+}
+
+// TODO - Remove or replace old tests
+
+////////////////////////////////////////////////////////////////////////////////
namespace {
class MyServerThread : public lang::Thread{
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=936881&r1=936880&r2=936881&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
Thu Apr 22 14:57:30 2010
@@ -27,7 +27,9 @@ namespace net{
class SocketTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE( SocketTest );
-// CPPUNIT_TEST( testConnect );
+ CPPUNIT_TEST( testConnectUnknownHost );
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testGetReuseAddress );
// CPPUNIT_TEST( testTx );
// CPPUNIT_TEST( testTrx );
// CPPUNIT_TEST( testTrxNoDelay );
@@ -42,6 +44,11 @@ namespace net{
virtual ~SocketTest() {}
+ void testConnectUnknownHost();
+ void testConstructor();
+ void testGetReuseAddress();
+
+ // Old Tests
void testConnect();
void testTx();
void testTrx();