Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
ea25ec6d
Commit
ea25ec6d
authored
14 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#3963] Add instant messaging unit test for parsing exceptions
parent
0bc6f0b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/test/instantmessagingtest.cpp
+40
-7
40 additions, 7 deletions
sflphone-common/test/instantmessagingtest.cpp
sflphone-common/test/instantmessagingtest.h
+4
-1
4 additions, 1 deletion
sflphone-common/test/instantmessagingtest.h
with
44 additions
and
8 deletions
sflphone-common/test/instantmessagingtest.cpp
+
40
−
7
View file @
ea25ec6d
...
...
@@ -175,9 +175,9 @@ static void XMLCALL startElementCallback(void *userData, const char *name, const
if
(
strcmp
(
attribute
,
"uri"
)
==
0
)
{
if
((
strcmp
(
value
,
"sip:alex@example.com"
)
==
0
)
||
(
strcmp
(
value
,
"sip:manu@example.com"
)
==
0
))
CPPUNIT_ASSERT
(
1
==
1
);
CPPUNIT_ASSERT
(
true
);
else
CPPUNIT_ASSERT
(
0
==
1
);
CPPUNIT_ASSERT
(
false
);
}
}
...
...
@@ -220,13 +220,13 @@ void InstantMessagingTest::testGenerateXmlUriList ()
if
(
XML_Parse
(
parser
,
buffer
.
c_str
(),
buffer
.
size
(),
1
)
==
XML_STATUS_ERROR
)
{
std
::
cout
<<
"Error: "
<<
XML_ErrorString
(
XML_GetErrorCode
(
parser
))
<<
" at line "
<<
XML_GetCurrentLineNumber
(
parser
)
<<
std
::
endl
;
CPPUNIT_ASSERT
(
0
==
1
);
CPPUNIT_ASSERT
(
false
);
}
XML_ParserFree
(
parser
);
CPPUNIT_ASSERT
(
nbEntry
==
4
);
CPPUNIT_ASSERT
(
1
==
1
);
CPPUNIT_ASSERT
(
true
);
}
void
InstantMessagingTest
::
testXmlUriListParsing
()
...
...
@@ -256,9 +256,9 @@ void InstantMessagingTest::testXmlUriListParsing ()
if
((
iterAttr
->
second
==
std
::
string
(
"sip:alex@example.com"
))
||
(
iterAttr
->
second
==
std
::
string
(
"sip:manu@example.com"
)))
CPPUNIT_ASSERT
(
1
==
1
);
CPPUNIT_ASSERT
(
true
);
else
CPPUNIT_ASSERT
(
0
==
1
);
CPPUNIT_ASSERT
(
false
);
iterEntry
++
;
}
}
...
...
@@ -321,7 +321,7 @@ void InstantMessagingTest::testGetUriListArea ()
if
(
iterAttr
==
entry
->
end
())
{
std
::
cout
<<
"Error, did not found attribute"
<<
std
::
endl
;
CPPUNIT_ASSERT
(
0
==
1
);
CPPUNIT_ASSERT
(
false
);
}
std
::
string
from
=
iterAttr
->
second
;
...
...
@@ -329,6 +329,39 @@ void InstantMessagingTest::testGetUriListArea ()
}
void
InstantMessagingTest
::
testIllFormatedMessage
()
{
bool
exceptionCaught
=
false
;
// SHOULD BE: Content-Type: text/plain
std
::
string
formatedText
=
"--boundary
\n
Content-Ty
\n\n
"
;
formatedText
.
append
(
"Here is the text area"
);
formatedText
.
append
(
"
\n
--boundary
\n
Content-Type: application/resource-lists+xml
\n
"
);
formatedText
.
append
(
"Content-Disposition: recipient-list
\n\n
"
);
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
(
"<list>"
);
formatedText
.
append
(
"<entry uri=
\"
sip:alex@example.com
\"
cp:copyControl=
\"
to
\"
/>"
);
formatedText
.
append
(
"<entry uri=
\"
sip:manu@example.com
\"
cp:copyControl=
\"
to
\"
/>"
);
formatedText
.
append
(
"</list>"
);
formatedText
.
append
(
"</resource-lists>"
);
formatedText
.
append
(
"--boundary--"
);
try
{
std
::
string
message
=
_im
->
findTextMessage
(
formatedText
);
}
catch
(
sfl
::
InstantMessageException
&
e
)
{
exceptionCaught
=
true
;
}
if
(
exceptionCaught
)
CPPUNIT_ASSERT
(
true
);
else
CPPUNIT_ASSERT
(
false
);
}
void
InstantMessagingTest
::
tearDown
()
{
delete
_im
;
...
...
This diff is collapsed.
Click to expand it.
sflphone-common/test/instantmessagingtest.h
+
4
−
1
View file @
ea25ec6d
...
...
@@ -60,6 +60,7 @@ class InstantMessagingTest : public CppUnit::TestCase {
CPPUNIT_TEST
(
testXmlUriListParsing
);
CPPUNIT_TEST
(
testGetTextArea
);
CPPUNIT_TEST
(
testGetUriListArea
);
CPPUNIT_TEST
(
testIllFormatedMessage
);
CPPUNIT_TEST_SUITE_END
();
public:
...
...
@@ -91,6 +92,8 @@ class InstantMessagingTest : public CppUnit::TestCase {
void
testGetUriListArea
();
void
testIllFormatedMessage
();
private
:
sfl
::
InstantMessaging
*
_im
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment