libt2n-git Archives

Subject: C++ inter-process communication library branch, master, updated. v0.5-14-gdf94ded

From: libt2n-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libt2n-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 4 Feb 2010 16:38:21 +0100 (CET)
The branch, master has been updated
       via  df94ded3d8958d9baff6baebc8e0ac85244da31d (commit)
      from  307b5e74c506b609d5c407be0943f45255ab5122 (commit)


- Log -----------------------------------------------------------------
commit df94ded3d8958d9baff6baebc8e0ac85244da31d
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date:   Thu Feb 4 16:38:18 2010 +0100

    Remove code duplication in test fixtures

-----------------------------------------------------------------------

Summary of changes:
 test/hello.cpp         |   37 +------------------------------------
 test/reconnect.cpp     |   32 +-------------------------------
 test/test_fixtures.hxx |   29 +++++++++++++++++++++++++++++
 test/timeout.cpp       |   36 ++++++------------------------------
 test/wrapper.cpp       |   24 ++----------------------
 5 files changed, 39 insertions(+), 119 deletions(-)

diff --git a/test/hello.cpp b/test/hello.cpp
index d53a312..6bce679 100644
--- a/test/hello.cpp
+++ b/test/hello.cpp
@@ -49,43 +49,8 @@ on this file might be covered by the GNU General Public 
License.
 using namespace std;
 using namespace libt2n;
 
-// this is an evil hack to get access to real_write, don't ever do this in an 
app!!!
-class real_write_connection: public socket_server_connection
-{
-    public:
-        void real_write(const std::string& data)
-            { socket_write(data); }
-};
-
-class test_helloFixture : public KillChildOnShutdownFixture
-{
-protected:
-    void send_hello(string hello_string, socket_server* ss, int conn_id)
-    {
-        server_connection *sc=ss->get_connection(conn_id);
-        sc->write(hello_string);
-    }
-
-    void send_raw_socket(string hello_string, socket_server* ss, int conn_id)
-    {
-        socket_server_connection 
*ssc=dynamic_cast<socket_server_connection*>(ss->get_connection(conn_id));
-
-        // this is an evil hack to get access to real_write, don't ever do 
this in an app!!!
-        real_write_connection *rwc=(real_write_connection*)ssc;
-        rwc->real_write(hello_string);
-    }
-
-public:
-    test_helloFixture()
-    {
-    }
-
-    ~test_helloFixture()
-    {
-    }
-};
 
-BOOST_FIXTURE_TEST_SUITE(test_hello, test_helloFixture)
+BOOST_FIXTURE_TEST_SUITE(test_hello, KillChildOnShutdownFixture)
 
 BOOST_AUTO_TEST_CASE(HelloOk)
 {
diff --git a/test/reconnect.cpp b/test/reconnect.cpp
index 6c70458..80fc57f 100644
--- a/test/reconnect.cpp
+++ b/test/reconnect.cpp
@@ -46,37 +46,7 @@ on this file might be covered by the GNU General Public 
License.
 using namespace std;
 using namespace libt2n;
 
-// this is an evil hack to get access to real_write, don't ever do this in an 
app!!!
-class real_write_connection: public socket_server_connection
-{
-    public:
-        void real_write(const std::string& data)
-            { socket_write(data); }
-};
-
-class test_reconnectFixture : public KillChildOnShutdownFixture
-{
-protected:
-    void send_raw_socket(string hello_string, socket_server* ss, int conn_id)
-    {
-        socket_server_connection 
*ssc=dynamic_cast<socket_server_connection*>(ss->get_connection(conn_id));
-
-        // this is an evil hack to get access to real_write, don't ever do 
this in an app!!!
-        real_write_connection *rwc=(real_write_connection*)ssc;
-        rwc->real_write(hello_string);
-    }
-
-public:
-    test_reconnectFixture()
-    {
-    }
-
-    ~test_reconnectFixture()
-    {
-    }
-};
-
-BOOST_FIXTURE_TEST_SUITE(test_reconnect, test_reconnectFixture)
+BOOST_FIXTURE_TEST_SUITE(test_reconnect, KillChildOnShutdownFixture)
 
 BOOST_AUTO_TEST_CASE(simple_reconnect)
 {
diff --git a/test/test_fixtures.hxx b/test/test_fixtures.hxx
index 882457c..255202e 100644
--- a/test/test_fixtures.hxx
+++ b/test/test_fixtures.hxx
@@ -26,11 +26,40 @@ on this file might be covered by the GNU General Public 
License.
 #include <sys/types.h>
 #include <signal.h>
 
+#include <socket_server.hxx>
+#include <string>
+
 class KillChildOnShutdownFixture
 {
 protected:
     pid_t child_pid;
 
+    // this is an evil hack to get access to real_write, don't ever do this in 
an app!!!
+    class real_write_connection: public libt2n::socket_server_connection
+    {
+        public:
+            void real_write(const std::string& data)
+                { socket_write(data); }
+    };
+
+    //
+    // common functions used by some tests
+    //
+    void send_hello(std::string hello_string, libt2n::socket_server* ss, int 
conn_id)
+    {
+        libt2n::server_connection *sc=ss->get_connection(conn_id);
+        sc->write(hello_string);
+    }
+
+    void send_raw_socket(std::string hello_string, libt2n::socket_server* ss, 
int conn_id)
+    {
+        libt2n::socket_server_connection 
*ssc=dynamic_cast<libt2n::socket_server_connection*>(ss->get_connection(conn_id));
+
+        // this is an evil hack to get access to real_write, don't ever do 
this in an app!!!
+        real_write_connection *rwc=(real_write_connection*)ssc;
+        rwc->real_write(hello_string);
+    }
+
 public:
     KillChildOnShutdownFixture()
         : child_pid(0)
diff --git a/test/timeout.cpp b/test/timeout.cpp
index 3434c0b..8f67cac 100644
--- a/test/timeout.cpp
+++ b/test/timeout.cpp
@@ -127,33 +127,18 @@ class testfunc2_cmd : public libt2n::command
 BOOST_CLASS_EXPORT(testfunc2_cmd)
 BOOST_CLASS_EXPORT(testfunc2_res)
 
-// this is an evil hack to get access to real_write, don't ever do this in an 
app!!!
-class real_write_connection: public socket_server_connection
-{
-    public:
-        void real_write(const std::string& data)
-            { socket_write(data); }
-};
-
-// this is an evil hack to get access to real_write, don't ever do this in an 
app!!!
-class real_write_client_connection: public socket_client_connection
-{
-    public:
-        void real_write(const std::string& data)
-            { socket_write(data); }
-};
-
-
 class test_timeoutFixture : public KillChildOnShutdownFixture
 {
 protected:
     typedef uint32_t packet_size_indicator;
 
-    void send_hello(string hello_string, socket_server* ss, unsigned int 
conn_id)
+    // this is an evil hack to get access to real_write, don't ever do this in 
an app!!!
+    class real_write_client_connection: public socket_client_connection
     {
-        server_connection *sc=ss->get_connection(conn_id);
-        sc->write(hello_string);
-    }
+        public:
+            void real_write(const std::string& data)
+                { socket_write(data); }
+    };
 
     void send_slow_raw_socket(string data, socket_server* ss, unsigned int 
conn_id)
     {
@@ -171,15 +156,6 @@ protected:
             usleep(200000);
         }
     }
-
-public:
-    test_timeoutFixture()
-    {
-    }
-
-    ~test_timeoutFixture()
-    {
-    }
 };
 
 BOOST_FIXTURE_TEST_SUITE(test_timeout, test_timeoutFixture)
diff --git a/test/wrapper.cpp b/test/wrapper.cpp
index e4bffb6..b1d30cd 100644
--- a/test/wrapper.cpp
+++ b/test/wrapper.cpp
@@ -424,30 +424,10 @@ BOOST_AUTO_TEST_CASE(ignore_handler_reconnects)
 
     BOOST_CHECK_EQUAL(2,cnt);
 }
-BOOST_AUTO_TEST_SUITE_END()
-
-
-
-class test_wrapper_noserverFixture : public KillChildOnShutdownFixture
-{
-protected:
-    void send_hello(string hello_string, socket_server* ss, int conn_id)
-    {
-        server_connection *sc=ss->get_connection(conn_id);
-        sc->write(hello_string);
-    }
 
-public:
-    test_wrapper_noserverFixture()
-    {
-    }
-
-    ~test_wrapper_noserverFixture()
-    {
-    }
-};
+BOOST_AUTO_TEST_SUITE_END()
 
-BOOST_FIXTURE_TEST_SUITE(test_wrapper_noserver, test_wrapper_noserverFixture)
+BOOST_FIXTURE_TEST_SUITE(test_wrapper_noserver, KillChildOnShutdownFixture)
 
 BOOST_AUTO_TEST_CASE(ignore_noserver)
 {


hooks/post-receive
-- 
C++ inter-process communication library

--
libt2n-git - see http://www.intra2net.com/en/developer/libt2n for details.
To unsubscribe send a mail to libt2n-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • C++ inter-process communication library branch, master, updated. v0.5-14-gdf94ded, libt2n-git <=