252 lines
6.7 KiB
HTML
252 lines
6.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Net::DBus::Test::MockMessage</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Net::DBus::Test::MockMessage</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-12-26<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Net::DBus::Test::MockMessage - Fake a message object when unit testing
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
Sending a message
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
my $msg = new Net::DBus::Test::MockMessage;
|
|
my $iterator = $msg->iterator;
|
|
|
|
$iterator->append_byte(132);
|
|
$iterator->append_int32(14241);
|
|
|
|
$connection->send($msg);
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module provides a ``mock'' counterpart to the Net::DBus::Binding::Message
|
|
class. It is basically a pure Perl fake message object providing the same
|
|
contract as the real message object. It is intended for use internally by the
|
|
testing APIs.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">my $call = Net::DBus::Test::MockMessage->new_method_call( service_name => $service, object_path => $object, interface => $interface, method_name => $name);<DD>
|
|
|
|
|
|
|
|
|
|
Create a message representing a call on the object located at
|
|
the path <TT>"object_path"</TT> within the client owning the well-known
|
|
name given by <TT>"service_name"</TT>. The method to be invoked has
|
|
the name <TT>"method_name"</TT> within the interface specified by the
|
|
<TT>"interface"</TT> parameter.
|
|
<DT id="2">my $msg = Net::DBus::Test::MockMessage->new_method_return( replyto => $method_call);<DD>
|
|
|
|
|
|
|
|
|
|
Create a message representing a reply to the method call passed in
|
|
the <TT>"replyto"</TT> parameter.
|
|
<DT id="3">my $signal = Net::DBus::Test::MockMessage->new_signal( object_path => $path, interface => $interface, signal_name => $name);<DD>
|
|
|
|
|
|
|
|
|
|
Creates a new message, representing a signal [to be] emitted by
|
|
the object located under the path given by the <TT>"object_path"</TT>
|
|
parameter. The name of the signal is given by the <TT>"signal_name"</TT>
|
|
parameter, and is scoped to the interface given by the
|
|
<TT>"interface"</TT> parameter.
|
|
<DT id="4">my $msg = Net::DBus::Test::MockMessage->new_error( replyto => $method_call, name => $name, description => $description);<DD>
|
|
|
|
|
|
|
|
|
|
Creates a new message, representing an error which occurred during
|
|
the handling of the method call object passed in as the <TT>"replyto"</TT>
|
|
parameter. The <TT>"name"</TT> parameter is the formal name of the error
|
|
condition, while the <TT>"description"</TT> is a short piece of text giving
|
|
more specific information on the error.
|
|
<DT id="5">my $type = $msg->get_type<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves the type code for this message. The returned value corresponds
|
|
to one of the four <TT>"Net::DBus::Test::MockMessage::MESSAGE_TYPE_*"</TT> constants.
|
|
<DT id="6">my $name = $msg->get_error_name<DD>
|
|
|
|
|
|
|
|
|
|
Returns the formal name of the error, as previously passed in via
|
|
the <TT>"name"</TT> parameter in the constructor.
|
|
<DT id="7">my $interface = $msg->get_interface<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves the name of the interface targeted by this message, possibly
|
|
an empty string if there is no applicable interface for this message.
|
|
<DT id="8">my $path = $msg->get_path<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves the object path associated with the message, possibly an
|
|
empty string if there is no applicable object for this message.
|
|
<DT id="9">my $name = $msg->get_destination<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves the unique or well-known bus name for client intended to be
|
|
the recipient of the message. Possibly returns an empty string if
|
|
the message is being broadcast to all clients.
|
|
<DT id="10">my $name = $msg->get_sender<DD>
|
|
|
|
|
|
|
|
|
|
Retireves the unique name of the client sending the message
|
|
<DT id="11">my $serial = $msg->get_serial<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves the unique serial number of this message. The number
|
|
is guaranteed unique for as long as the connection over which
|
|
the message was sent remains open. May return zero, if the message
|
|
is yet to be sent.
|
|
<DT id="12">my $name = $msg->get_member<DD>
|
|
|
|
|
|
|
|
|
|
For method calls, retrieves the name of the method to be invoked,
|
|
while for signals, retrieves the name of the signal.
|
|
<DT id="13">$msg->set_sender($name)<DD>
|
|
|
|
|
|
|
|
|
|
Set the name of the client sending the message. The name must
|
|
be the unique name of the client.
|
|
<DT id="14">$msg->set_destination($name)<DD>
|
|
|
|
|
|
|
|
|
|
Set the name of the intended recipient of the message. This is
|
|
typically used for signals to switch them from broadcast to
|
|
unicast.
|
|
<DT id="15">my $iterator = $msg->iterator;<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves an iterator which can be used for reading or
|
|
writing fields of the message. The returned object is
|
|
an instance of the <TT>"Net::DBus::Binding::Iterator"</TT> class.
|
|
<DT id="16">$boolean = $msg-><B>get_no_reply()</B><DD>
|
|
|
|
|
|
|
|
|
|
Gets the flag indicating whether the message is expecting
|
|
a reply to be sent.
|
|
<DT id="17">$msg->set_no_reply($boolean)<DD>
|
|
|
|
|
|
|
|
|
|
Toggles the flag indicating whether the message is expecting
|
|
a reply to be sent. All method call messages expect a reply
|
|
by default. By toggling this flag the communication latency
|
|
is reduced by removing the need for the client to wait
|
|
<DT id="18">my @values = $msg->get_args_list<DD>
|
|
|
|
|
|
|
|
|
|
De-marshall all the values in the body of the message, using the
|
|
message signature to identify data types. The values are returned
|
|
as a list.
|
|
<DT id="19">$msg->append_args_list(@values)<DD>
|
|
|
|
|
|
|
|
|
|
Append a set of values to the body of the message. Values will
|
|
be encoded as either a string, list or dictionary as appropriate
|
|
to their Perl data type. For more specific data typing needs,
|
|
the Net::DBus::Binding::Iterator object should be used instead.
|
|
<DT id="20">my $sig = $msg->get_signature<DD>
|
|
|
|
|
|
|
|
|
|
Retrieves a string representing the type signature of the values
|
|
packed into the body of the message.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Daniel P. Berrange
|
|
<A NAME="lbAG"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
Copyright (C) 2005-2009 Daniel P. Berrange
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
Net::DBus::Binding::Message, Net::DBus::Test::MockConnection, Net::DBus::Test::MockIterator
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="21"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="22"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="23"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="24"><A HREF="#lbAE">METHODS</A><DD>
|
|
<DT id="25"><A HREF="#lbAF">AUTHOR</A><DD>
|
|
<DT id="26"><A HREF="#lbAG">COPYRIGHT</A><DD>
|
|
<DT id="27"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:49 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|