refactoring test/test_Message.hpp

master
Denes Matetelki 12 years ago
parent ef2a90f17f
commit 6bc4ddc488

@ -5,66 +5,69 @@
#include "Message.hpp"
#include "Connection.hpp"
class TestMessage : public CxxTest::TestSuite
class SimpleMessage : public Message
{
private:
public:
class SimpleMessage : public Message
SimpleMessage( void *msgParam = 0)
: Message(msgParam)
{
public:
TRACE;
}
SimpleMessage( void *msgParam = 0)
: Message(msgParam)
{
TRACE;
}
bool buildMessage( const void *msgPart,
const size_t msgLen )
{
TRACE;
m_buffer = std::string( (const char*) msgPart, msgLen );
onMessageReady();
return true;
}
bool buildMessage( const void *msgPart,
const size_t msgLen )
{
TRACE;
m_buffer = std::string( (const char*) msgPart, msgLen );
onMessageReady();
return true;
}
void onMessageReady()
{
TRACE;
void onMessageReady()
{
TRACE;
LOG_BEGIN(Logger::INFO)
LOG_PROP("message", m_buffer)
LOG_END("Got reply from server.");
LOG_BEGIN(Logger::INFO)
LOG_PROP("message", m_buffer)
LOG_END("Got reply from server.");
*( static_cast<bool*>(m_param) ) = true;
*( static_cast<bool*>(m_param) ) = true;
if (m_connection != 0)
m_connection->send(m_buffer.c_str(), m_buffer.length());
if (m_connection != 0)
m_connection->send(m_buffer.c_str(), m_buffer.length());
}
m_buffer.clear();
}
Message* clone()
{
TRACE;
return new SimpleMessage(m_param);
}
Message* clone()
{
TRACE;
return new SimpleMessage(m_param);
}
std::string getBuffer()
{
TRACE;
return m_buffer;
}
std::string getBuffer()
{
TRACE;
return m_buffer;
}
protected:
protected:
size_t getExpectedLength()
{
TRACE;
return 0;
}
size_t getExpectedLength()
{
TRACE;
return 0;
}
}; // SimpleMessage
}; // SimpleMessage
class TestMessage : public CxxTest::TestSuite
{
private:
class DummyConnection : public Connection
{
public:

Loading…
Cancel
Save