Net::DB...Message(3)
okay so, bestie, welcome to the Net::DB...Message(3) page from User Contributed Perl Documentation β¨ this one is giving βunit-testing but make it fake-message chicβ and we are here for it π§
πΈ NAME πΈ
Net::DBus::Test::MockMessage β Fake a message object when unit testing π
π¦ SYNOPSIS π¦
π Sending a message
my $msg = new Net::DBus::Test::MockMessage;
my $iterator = $msg->iterator;
$iterator->append_byte(132);
$iterator->append_int32(14241);
$connection->send($msg);
β¨ DESCRIPTION β¨
This module is the βmockβ counterpart to the Net::DBus::Binding::Message class π«Ά Itβs basically a pure Perl fake message object that provides the same contract as the real message object. It is intended for use internally by the testing APIs, iykyk π
π METHODS π
my $call = Net::DBus::Test::MockMessage->new_method_call( service_name => $service, object_path => $object, interface => $interface, method_name => $name);β Create a message representing a call on the object located at the pathobject_pathwithin the client owning the well-known name given byservice_name. The method to be invoked has the namemethod_namewithin the interface specified by theinterfaceparameter. πmy $msg = Net::DBus::Test::MockMessage->new_method_return( replyto => $method_call);β Create a message representing a reply to the method call passed in thereplytoparameter. πmy $signal = Net::DBus::Test::MockMessage->new_signal( object_path => $path, interface => $interface, signal_name => $name);β Creates a new message, representing a signal [to be] emitted by the object located under the path given by theobject_pathparameter. The name of the signal is given by thesignal_nameparameter, and is scoped to the interface given by theinterfaceparameter. π¦my $msg = Net::DBus::Test::MockMessage->new_error( replyto => $method_call, name => $name, description => $description);β Creates a new message, representing an error which occurred during the handling of the method call object passed in as thereplytoparameter. Thenameparameter is the formal name of the error condition, while thedescriptionis a short piece of text giving more specific information on the error. πmy $type = $msg->get_typeβ Retrieves the type code for this message. The returned value corresponds to one of the fourNet::DBus::Test::MockMessage::MESSAGE_TYPE_*constants. βmy $name = $msg->get_error_nameβ Returns the formal name of the error, as previously passed in via thenameparameter in the constructor. π₯my $interface = $msg->get_interfaceβ Retrieves the name of the interface targeted by this message, possibly an empty string if there is no applicable interface for this message. πΈmy $path = $msg->get_pathβ Retrieves the object path associated with the message, possibly an empty string if there is no applicable object for this message. πmy $name = $msg->get_destinationβ 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. π£my $name = $msg->get_senderβ Retrieves the unique name of the client sending the message. πmy $serial = $msg->get_serialβ 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. π’my $name = $msg->get_memberβ For method calls, retrieves the name of the method to be invoked, while for signals, retrieves the name of the signal. π$msg->set_sender($name)β Set the name of the client sending the message. The name must be the unique name of the client. π«Ά$msg->set_destination($name)β Set the name of the intended recipient of the message. This is typically used for signals to switch them from broadcast to unicast. π―my $iterator = $msg->iterator;β Retrieves an iterator which can be used for reading or writing fields of the message. The returned object is an instance of theNet::DBus::Binding::Iteratorclass. π$boolean = $msg->get_no_reply()β Gets the flag indicating whether the message is expecting a reply to be sent. π$msg->set_no_reply($boolean)β 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. πmy @values = $msg->get_args_listβ 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. π$msg->append_args_list(@values)β 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, theNet::DBus::Binding::Iteratorobject should be used instead. πmy $sig = $msg->get_signatureβ Retrieves a string representing the type signature of the values packed into the body of the message. π§
π AUTHOR π
Daniel P. Berrange π
π COPYRIGHT π
Copyright (C) 2005-2009 Daniel P. Berrange πΈ
π SEE ALSO π
Net::DBus::Binding::MessageNet::DBus::Test::MockConnectionNet::DBus::Test::MockIterator
xoxo, your perl v5.42.0 bestie, dated 2019-12-17 πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms