Skip to content
Snippets Groups Projects
Commit 35360c5b authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#4056] Fix unit test for instant message parsing

parent d388a2fa
Branches
Tags
No related merge requests found
...@@ -325,7 +325,7 @@ std::string InstantMessaging::findTextUriList (std::string& text) ...@@ -325,7 +325,7 @@ std::string InstantMessaging::findTextUriList (std::string& text)
throw InstantMessageException ("Could not find Content-Disposition tag while parsing sip message for recipient-list"); throw InstantMessageException ("Could not find Content-Disposition tag while parsing sip message for recipient-list");
// xml content start after content disposition tag (plus \n\n) // xml content start after content disposition tag (plus \n\n)
begin = pos+cdispo.size() +2; begin = pos+cdispo.size();
// find final boundary // find final boundary
if ( (end = text.find (boundary, begin)) == std::string::npos) if ( (end = text.find (boundary, begin)) == std::string::npos)
...@@ -348,13 +348,13 @@ std::string InstantMessaging::findTextMessage (std::string& text) ...@@ -348,13 +348,13 @@ std::string InstantMessaging::findTextMessage (std::string& text)
throw InstantMessageException ("Could not find Content-Type tag while parsing sip message for text"); throw InstantMessageException ("Could not find Content-Type tag while parsing sip message for text");
// plain text content start after content type tag (plus \n\n) // plain text content start after content type tag (plus \n\n)
begin = pos+ctype.size() +2; begin = pos+ctype.size();
// retrive end of the text content // retrive end of the text content
if ( (end = text.find (boundary, begin)) == std::string::npos) if ( (end = text.find (boundary, begin)) == std::string::npos)
throw InstantMessageException ("Could not find end of text \"boundary\" while parsing sip message for text"); throw InstantMessageException ("Could not find end of text \"boundary\" while parsing sip message for text");
return text.substr (begin, end-begin-1); return text.substr (begin, end-begin);
} }
......
...@@ -40,7 +40,7 @@ class InstantMessageException : public std::exception ...@@ -40,7 +40,7 @@ class InstantMessageException : public std::exception
virtual ~InstantMessageException() throw() {} virtual ~InstantMessageException() throw() {}
virtual const char *what() const throw() { virtual const char *what() const throw() {
std::string expt ("YamlParserException occured: "); std::string expt ("InstantMessageException occured: ");
expt.append (errstr); expt.append (errstr);
return expt.c_str(); return expt.c_str();
......
...@@ -266,11 +266,11 @@ void InstantMessagingTest::testXmlUriListParsing () ...@@ -266,11 +266,11 @@ void InstantMessagingTest::testXmlUriListParsing ()
void InstantMessagingTest::testGetTextArea () void InstantMessagingTest::testGetTextArea ()
{ {
std::string formatedText = "--boundary\n Content-Type: text/plain\n\n"; std::string formatedText = "--boundary Content-Type: text/plain";
formatedText.append ("Here is the text area"); formatedText.append ("Here is the text area");
formatedText.append ("\n--boundary\nContent-Type: application/resource-lists+xml\n"); formatedText.append ("--boundary Content-Type: application/resource-lists+xml");
formatedText.append ("Content-Disposition: recipient-list\n\n"); formatedText.append ("Content-Disposition: recipient-list");
formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">"); formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">");
formatedText.append ("<list>"); formatedText.append ("<list>");
...@@ -282,19 +282,19 @@ void InstantMessagingTest::testGetTextArea () ...@@ -282,19 +282,19 @@ void InstantMessagingTest::testGetTextArea ()
std::string message = _im->findTextMessage(formatedText); std::string message = _im->findTextMessage(formatedText);
CPPUNIT_ASSERT(message == "Here is the text area"); std::cout << "message " << message << std::endl;
std::cout << "message: " << message << std::endl; CPPUNIT_ASSERT(message == "Here is the text area");
} }
void InstantMessagingTest::testGetUriListArea () void InstantMessagingTest::testGetUriListArea ()
{ {
std::string formatedText = "--boundary\n Content-Type: text/plain\n\n"; std::string formatedText = "--boundary Content-Type: text/plain";
formatedText.append ("Here is the text area"); formatedText.append ("Here is the text area");
formatedText.append ("\n--boundary\nContent-Type: application/resource-lists+xml\n"); formatedText.append ("--boundary Content-Type: application/resource-lists+xml");
formatedText.append ("Content-Disposition: recipient-list\n\n"); formatedText.append ("Content-Disposition: recipient-list");
formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">"); formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">");
formatedText.append ("<list>"); formatedText.append ("<list>");
...@@ -334,11 +334,11 @@ void InstantMessagingTest::testIllFormatedMessage () ...@@ -334,11 +334,11 @@ void InstantMessagingTest::testIllFormatedMessage ()
bool exceptionCaught = false; bool exceptionCaught = false;
// SHOULD BE: Content-Type: text/plain // SHOULD BE: Content-Type: text/plain
std::string formatedText = "--boundary\n Content-Ty\n\n"; std::string formatedText = "--boundary Content-Ty";
formatedText.append ("Here is the text area"); formatedText.append ("Here is the text area");
formatedText.append ("\n--boundary\nContent-Type: application/resource-lists+xml\n"); formatedText.append ("--boundary Content-Type: application/resource-lists+xml");
formatedText.append ("Content-Disposition: recipient-list\n\n"); formatedText.append ("Content-Disposition: recipient-list");
formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); formatedText.append ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">"); formatedText.append ("<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">");
formatedText.append ("<list>"); formatedText.append ("<list>");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment