You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/07/07 02:00:39 UTC
svn commit: r961044 - in /activemq/activemq-cpp/trunk/activemq-cpp/src:
main/decaf/net/ test/decaf/net/
Author: tabish
Date: Wed Jul 7 00:00:39 2010
New Revision: 961044
URL: http://svn.apache.org/viewvc?rev=961044&view=rev
Log:
Add a clone method and test
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h
activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.cpp Wed Jul 7 00:00:39 2010
@@ -39,6 +39,12 @@ Inet4Address::~Inet4Address() {
}
////////////////////////////////////////////////////////////////////////////////
+InetAddress* Inet4Address::clone() const {
+
+ return new Inet4Address( *this );
+}
+
+////////////////////////////////////////////////////////////////////////////////
bool Inet4Address::isAnyLocalAddress() const {
for( int ix = 0; ix < 4; ix++ ) {
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet4Address.h Wed Jul 7 00:00:39 2010
@@ -40,6 +40,10 @@ namespace net {
virtual ~Inet4Address();
+ public:
+
+ virtual InetAddress* clone() const;
+
/**
* Check if this InetAddress is a valid wildcard address.
*
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.cpp Wed Jul 7 00:00:39 2010
@@ -37,3 +37,9 @@ Inet6Address::Inet6Address( const std::s
////////////////////////////////////////////////////////////////////////////////
Inet6Address::~Inet6Address() {
}
+
+////////////////////////////////////////////////////////////////////////////////
+InetAddress* Inet6Address::clone() const {
+
+ return NULL;
+}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/Inet6Address.h Wed Jul 7 00:00:39 2010
@@ -40,6 +40,10 @@ namespace net {
virtual ~Inet6Address();
+ public:
+
+ virtual InetAddress* clone() const;
+
};
}}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.cpp Wed Jul 7 00:00:39 2010
@@ -22,6 +22,7 @@
#include <decaf/net/Inet4Address.h>
#include <decaf/net/Inet6Address.h>
#include <decaf/net/UnknownHostException.h>
+#include <decaf/lang/exceptions/RuntimeException.h>
#include <apr_network_io.h>
#include <decaf/internal/AprPool.h>
@@ -85,6 +86,12 @@ InetAddress::~InetAddress() {
}
////////////////////////////////////////////////////////////////////////////////
+InetAddress* InetAddress::clone() const {
+
+ return new InetAddress( *this );
+}
+
+////////////////////////////////////////////////////////////////////////////////
ArrayPointer<unsigned char> InetAddress::getAddress() const {
return this->addressBytes.clone();
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/InetAddress.h Wed Jul 7 00:00:39 2010
@@ -91,6 +91,14 @@ namespace net {
*/
virtual std::string toString() const;
+ /**
+ * Returns a newly allocated copy of this InetAddress. The caller owns the resulting
+ * copy and must delete it.
+ *
+ * @return a new InetAddress instance that is a copy of this one, caller owns.
+ */
+ virtual InetAddress* clone() const;
+
public: // Address Property Tests, override in the subclasses for correct results
/**
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.cpp?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.cpp Wed Jul 7 00:00:39 2010
@@ -20,6 +20,8 @@
#include <decaf/net/InetAddress.h>
#include <decaf/net/UnknownHostException.h>
+#include <memory>
+
using namespace decaf;
using namespace decaf::net;
using namespace decaf::lang;
@@ -33,6 +35,19 @@ InetAddressTest::~InetAddressTest() {
}
////////////////////////////////////////////////////////////////////////////////
+void InetAddressTest::testClone() {
+
+ InetAddress address = InetAddress::getLocalHost();
+ CPPUNIT_ASSERT( address.getHostName() != "" );
+ CPPUNIT_ASSERT( address.getHostAddress() != "" );
+
+ std::auto_ptr<InetAddress> copy( address.clone() );
+
+ CPPUNIT_ASSERT( address.getHostName() == copy->getHostName() );
+ CPPUNIT_ASSERT( address.getHostAddress() == copy->getHostAddress() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
void InetAddressTest::testGetByAddress() {
const unsigned char bytes[] = { 127, 0, 0, 1 };
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.h?rev=961044&r1=961043&r2=961044&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/net/InetAddressTest.h Wed Jul 7 00:00:39 2010
@@ -30,6 +30,7 @@ namespace net {
CPPUNIT_TEST( testGetByAddress );
CPPUNIT_TEST( testGetHostAddress );
CPPUNIT_TEST( testGetLocalHost );
+ CPPUNIT_TEST( testClone );
CPPUNIT_TEST_SUITE_END();
public:
@@ -37,6 +38,7 @@ namespace net {
InetAddressTest();
virtual ~InetAddressTest();
+ void testClone();
void testGetByAddress();
void testGetHostAddress();
void testGetLocalHost();