Commit 867304f3 authored by webchick's avatar webchick

#307477 by clemens.tolboom and boombatower: Test how XML-RPC responds to large messages.

parent 7f29b142
......@@ -126,3 +126,37 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
$this->assertEqual($a_l_res, $a_r_res, 'multicall equals result');
}
}
class XMLRPCMessagesTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo().
*/
function getInfo() {
return array(
'name' => t('XML-RPC message'),
'description' => t('Test large messages.'),
'group' => t('XML-RPC'),
);
}
/**
* Implementation of setUp().
*/
function setUp() {
parent::setUp('xmlrpc_test');
}
/**
* Make sure that XML-RPC can transfer large messages.
*/
function testSizedMessages() {
$xml_url = url(NULL, array('absolute' => TRUE)) . 'xmlrpc.php';
$sizes = array(8, 80, 160);
foreach ($sizes as $size) {
$xml_message_l = xmlrpc_test_message_sized_in_kb($size);
$xml_message_r = xmlrpc($xml_url, 'messages.messageSizedInKB', $size);
$this->assertEqual($xml_message_l, $xml_message_r, t('XML-RPC messages.messageSizedInKB of %s Kb size received', array('%s' => $size)));
}
}
}
......@@ -58,5 +58,32 @@ function xmlrpc_test_xmlrpc() {
'validator1.manyTypesTest' => 'xmlrpc_test_manyTypesTest',
'validator1.moderateSizeArrayCheck' => 'xmlrpc_test_moderateSizeArrayCheck',
'validator1.nestedStructTest' => 'xmlrpc_test_nestedStructTest',
'validator1.simpleStructReturnTest' => 'xmlrpc_test_simpleStructReturnTest');
'validator1.simpleStructReturnTest' => 'xmlrpc_test_simpleStructReturnTest',
'messages.messageSizedInKB' => 'xmlrpc_test_message_sized_in_kb',
);
}
/**
* Created a message of the desired size in KB.
*
* @param $size
* Message size in KB.
* @return array
* Generated message structure.
*/
function xmlrpc_test_message_sized_in_kb($size) {
$message = array();
$word = 'abcdefg';
// Create a ~1KB sized struct.
for ($i = 0 ; $i < 128; $i++) {
$line['word_' . $i] = $word;
}
for($i = 0; $i < $size; $i++) {
$message['line_' . $i] = $line;
}
return $message;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment