#include <sstream>
#include <stdexcept>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-#include <cppunit/extensions/HelperMacros.h>
+#include "test_fixtures.hxx"
+
+#define BOOST_TEST_DYN_LINK
+#include <boost/test/unit_test.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <command_server.hxx>
using namespace std;
-using namespace CppUnit;
string testfunc3(const string& str)
{
using namespace libt2n;
-class test_serialize : public TestFixture
-{
- CPPUNIT_TEST_SUITE(test_serialize);
-
- CPPUNIT_TEST(ClientSerializeErr);
-
- // TODO: Server Deserialization Error
- // TODO: Server Serialization Error
- // TODO: Client Deserialization Error
- // but those probably need separate client/server binaries
-
- CPPUNIT_TEST_SUITE_END();
-
- pid_t child_pid;
-
- public:
-
- void setUp()
- {
- }
-
- void tearDown()
- {
- // make sure the server-child is dead before the next test runs
- kill(child_pid,SIGKILL);
- sleep(1);
- }
+BOOST_FIXTURE_TEST_SUITE(test_serialize, KillChildOnShutdownFixture)
+// TODO: Server Deserialization Error
+// TODO: Server Serialization Error
+// TODO: Client Deserialization Error
+// but those probably need separate client/server binaries
- void ClientSerializeErr()
+BOOST_AUTO_TEST_CASE(ClientSerializeErr)
+{
+ switch(child_pid=fork())
{
- switch(child_pid=fork())
+ case -1:
+ {
+ BOOST_FAIL("fork error");
+ break;
+ }
+ case 0:
+ // child
{
- case -1:
+ try
{
- CPPUNIT_FAIL("fork error");
- break;
- }
- case 0:
- // child
+ socket_server ss("./socket");
+ command_server cs(ss);
+
+ // max 10 sec
+ for (int i=0; i < 10; i++)
+ cs.handle(1000000);
+ } catch(...)
{
- try
- {
- socket_server ss("./socket");
- command_server cs(ss);
-
- // max 10 sec
- for (int i=0; i < 10; i++)
- cs.handle(1000000);
- } catch(...)
- {
- std::cerr << "exception in child. ignoring\n";
- }
-
- // don't call atexit and stuff
- _exit(0);
+ std::cerr << "exception in child. ignoring\n";
}
- default:
- // parent
+ // don't call atexit and stuff
+ _exit(0);
+ }
+
+ default:
+ // parent
+ {
+ // wait till server is up
+ sleep(1);
+ socket_client_connection sc("./socket");
+ command_client cc(&sc);
+
+ string errormsg;
+
+ result_container rc;
+ try
{
- // wait till server is up
- sleep(1);
- socket_client_connection sc("./socket");
- command_client cc(&sc);
-
- string errormsg;
-
- result_container rc;
- try
- {
- cc.send_command(new testfunc3_cmd("xyz"),rc);
- }
- catch(t2n_serialization_error &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
-
- CPPUNIT_ASSERT_EQUAL(string("archive_exception while serializing on client-side, code 2 (unregistered class)"),errormsg);
+ cc.send_command(new testfunc3_cmd("xyz"),rc);
}
+ catch(t2n_serialization_error &e)
+ { errormsg=e.what(); }
+
+ BOOST_CHECK_EQUAL(string("archive_exception while serializing on client-side, code 2 (unregistered class - derived class not registered or exported)"),errormsg);
}
}
+}
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(test_serialize);
+BOOST_AUTO_TEST_SUITE_END()