1Net::DBus::Test::MockMeUssseargeC(o3n)tributed Perl DocuNmeetn:t:aDtBiuosn::Test::MockMessage(3)
2
3
4

NAME

6       Net::DBus::Test::MockMessage - Fake a message object when unit testing
7

SYNOPSIS

9       Sending a message
10
11         my $msg = new Net::DBus::Test::MockMessage;
12         my $iterator = $msg->iterator;
13
14         $iterator->append_byte(132);
15         $iterator->append_int32(14241);
16
17         $connection->send($msg);
18

DESCRIPTION

20       This module provides a "mock" counterpart to the
21       Net::DBus::Binding::Message class. It is basically a pure Perl fake
22       message object providing the same contract as the real message object.
23       It is intended for use internally by the testing APIs.
24

METHODS

26       my $call = Net::DBus::Test::MockMessage->new_method_call( service_name
27       => $service, object_path => $object, interface => $interface,
28       method_name => $name);
29           Create a message representing a call on the object located at the
30           path "object_path" within the client owning the well-known name
31           given by "service_name". The method to be invoked has the name
32           "method_name" within the interface specified by the "interface"
33           parameter.
34
35       my $msg = Net::DBus::Test::MockMessage->new_method_return( replyto =>
36       $method_call);
37           Create a message representing a reply to the method call passed in
38           the "replyto" parameter.
39
40       my $signal = Net::DBus::Test::MockMessage->new_signal( object_path =>
41       $path, interface => $interface, signal_name => $name);
42           Creates a new message, representing a signal [to be] emitted by the
43           object located under the path given by the "object_path" parameter.
44           The name of the signal is given by the "signal_name" parameter, and
45           is scoped to the interface given by the "interface" parameter.
46
47       my $msg = Net::DBus::Test::MockMessage->new_error( replyto =>
48       $method_call, name => $name, description => $description);
49           Creates a new message, representing an error which occurred during
50           the handling of the method call object passed in as the "replyto"
51           parameter. The "name" parameter is the formal name of the error
52           condition, while the "description" is a short piece of text giving
53           more specific information on the error.
54
55       my $type = $msg->get_type
56           Retrieves the type code for this message. The returned value
57           corresponds to one of the four
58           "Net::DBus::Test::MockMessage::MESSAGE_TYPE_*" constants.
59
60       my $name = $msg->get_error_name
61           Returns the formal name of the error, as previously passed in via
62           the "name" parameter in the constructor.
63
64       my $interface = $msg->get_interface
65           Retrieves the name of the interface targeted by this message,
66           possibly an empty string if there is no applicable interface for
67           this message.
68
69       my $path = $msg->get_path
70           Retrieves the object path associated with the message, possibly an
71           empty string if there is no applicable object for this message.
72
73       my $name = $msg->get_destination
74           Retrieves the unique or well-known bus name for client intended to
75           be the recipient of the message. Possibly returns an empty string
76           if the message is being broadcast to all clients.
77
78       my $name = $msg->get_sender
79           Retireves the unique name of the client sending the message
80
81       my $serial = $msg->get_serial
82           Retrieves the unique serial number of this message. The number is
83           guaranteed unique for as long as the connection over which the
84           message was sent remains open. May return zero, if the message is
85           yet to be sent.
86
87       my $name = $msg->get_member
88           For method calls, retrieves the name of the method to be invoked,
89           while for signals, retrieves the name of the signal.
90
91       $msg->set_sender($name)
92           Set the name of the client sending the message. The name must be
93           the unique name of the client.
94
95       $msg->set_destination($name)
96           Set the name of the intended recipient of the message. This is
97           typically used for signals to switch them from broadcast to
98           unicast.
99
100       my $iterator = $msg->iterator;
101           Retrieves an iterator which can be used for reading or writing
102           fields of the message. The returned object is an instance of the
103           "Net::DBus::Binding::Iterator" class.
104
105       $boolean = $msg->get_no_reply()
106           Gets the flag indicating whether the message is expecting a reply
107           to be sent.
108
109       $msg->set_no_reply($boolean)
110           Toggles the flag indicating whether the message is expecting a
111           reply to be sent. All method call messages expect a reply by
112           default. By toggling this flag the communication latency is reduced
113           by removing the need for the client to wait
114
115       my @values = $msg->get_args_list
116           De-marshall all the values in the body of the message, using the
117           message signature to identify data types. The values are returned
118           as a list.
119
120       $msg->append_args_list(@values)
121           Append a set of values to the body of the message. Values will be
122           encoded as either a string, list or dictionary as appropriate to
123           their Perl data type. For more specific data typing needs, the
124           Net::DBus::Binding::Iterator object should be used instead.
125
126       my $sig = $msg->get_signature
127           Retrieves a string representing the type signature of the values
128           packed into the body of the message.
129

AUTHOR

131       Daniel P. Berrange
132
134       Copyright (C) 2005-2009 Daniel P. Berrange
135

SEE ALSO

137       Net::DBus::Binding::Message, Net::DBus::Test::MockConnection,
138       Net::DBus::Test::MockIterator
139
140
141
142perl v5.30.1                      2020-01-30   Net::DBus::Test::MockMessage(3)
Impressum