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);
+ }
void send_hello(string hello_string, socket_server* ss, int conn_id)
{
void HelloOk()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
void BadTag()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
+
+ t2n_exception* ep=cc.get_constuctor_exception();
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("illegal hello received (T2N)"),errormsg);
}
void BadVersion()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ t2n_exception* ep=cc.get_constuctor_exception();
+
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("not compatible with the server protocol version"),errormsg);
}
void SeparatorMissing()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ t2n_exception* ep=cc.get_constuctor_exception();
+
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("illegal hello received (1. ;)"),errormsg);
}
void WrongByteOrder()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ t2n_exception* ep=cc.get_constuctor_exception();
+
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("host byte order not matching"),errormsg);
}
void OtherServerBig()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
+
+ t2n_exception* ep=cc.get_constuctor_exception();
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("illegal hello received (T2N)"),errormsg);
}
void OtherServerSmall()
{
- pid_t pid;
-
- switch(pid=fork())
+ switch(child_pid=fork())
{
case -1:
{
sleep(1);
socket_client_connection sc("./socket");
- string errormsg;
+ command_client cc(&sc);
- try
- {
- command_client cc(&sc);
- }
- catch(t2n_version_mismatch &e)
- { errormsg=e.what(); }
- catch(...)
- { throw; }
+ t2n_exception* ep=cc.get_constuctor_exception();
+
+ string errormsg;
+ if (ep)
+ errormsg=ep->what();
CPPUNIT_ASSERT_EQUAL(string("illegal hello received (T2N)"),errormsg);
}