X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=octopi%2Flibrary%2Ftests_octopus%2Ft_identity.cpp;fp=octopi%2Flibrary%2Ftests_octopus%2Ft_identity.cpp;h=eb7dd35f114b01bf59d74fba76f2b362d62a2a25;hb=aad83c15eb10a34baff9b6472f88d1dfa1db9d77;hp=0000000000000000000000000000000000000000;hpb=7b499c3676de8069f7cfa13bca61837e9ee1f970;p=feisty_meow.git diff --git a/octopi/library/tests_octopus/t_identity.cpp b/octopi/library/tests_octopus/t_identity.cpp new file mode 100644 index 00000000..eb7dd35f --- /dev/null +++ b/octopi/library/tests_octopus/t_identity.cpp @@ -0,0 +1,86 @@ +/*****************************************************************************\ +* * +* Name : octopus identity test * +* Author : Chris Koeritz * +* * +* Purpose: * +* * +* Checks out the client identification methods in octopus. * +* * +******************************************************************************* +* Copyright (c) 2002-$now By Author. This program is free software; you can * +* redistribute it and/or modify it under the terms of the GNU General Public * +* License as published by the Free Software Foundation; either version 2 of * +* the License or (at your option) any later version. This is online at: * +* http://www.fsf.org/copyleft/gpl.html * +* Please send any updates to: fred@gruntose.com * +\*****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +////////////// + +class test_octopus_identity : public application_shell +{ +public: + test_octopus_identity() : application_shell(class_name()) {} + DEFINE_CLASS_NAME("test_octopus_identity"); + virtual int execute(); +}; + +int test_octopus_identity::execute() +{ + octopus logos("local", 18 * MEGABYTE); + + identity_infoton *ide = new identity_infoton; + octopus_request_id junk_id = octopus_request_id::randomized_id(); + // bogus right now. + + byte_array packed; + ide->pack(packed); + if (ide->packed_size() != packed.length()) + deadly_error(class_name(), "packing test", + astring("the packed size was different than expected.")); + + outcome ret = logos.evaluate(ide, junk_id); + if (ret != tentacle::OKAY) + deadly_error(class_name(), "evaluate test", + astring("the evaluation failed with an error ") + + tentacle::outcome_name(ret)); +log("point a"); + + octopus_request_id response_id; // based on bogus from before. + infoton *response = logos.acquire_result(junk_id._entity, response_id); + if (!response) + deadly_error(class_name(), "acquire test", + astring("the acquire_result failed to produce a result.")); + + identity_infoton *new_id = dynamic_cast(response); + if (!new_id) + deadly_error(class_name(), "casting", + astring("the returned infoton is not the right type.")); + + octopus_entity my_ide = new_id->_new_name; + +log(astring("new id is: ") + my_ide.text_form()); + + if (my_ide.blank()) + deadly_error(class_name(), "retrieving id", + astring("the new entity id is blank.")); + + + log("octopus:: identity works for those functions tested."); + + return 0; +} + +HOOPLE_MAIN(test_octopus_identity, ) +