1 /*****************************************************************************\
3 * Name : octopus identity test *
4 * Author : Chris Koeritz *
8 * Checks out the client identification methods in octopus. *
10 *******************************************************************************
11 * Copyright (c) 2002-$now By Author. This program is free software; you can *
12 * redistribute it and/or modify it under the terms of the GNU General Public *
13 * License as published by the Free Software Foundation; either version 2 of *
14 * the License or (at your option) any later version. This is online at: *
15 * http://www.fsf.org/copyleft/gpl.html *
16 * Please send any updates to: fred@gruntose.com *
17 \*****************************************************************************/
19 #include <basis/astring.h>
20 #include <octopus/entity_defs.h>
21 #include <octopus/identity_infoton.h>
22 #include <octopus/infoton.h>
23 #include <octopus/octopus.h>
24 #include <octopus/tentacle.h>
25 #include <application/application_shell.h>
26 #include <loggers/console_logger.h>
27 #include <structures/static_memory_gremlin.h>
31 class test_octopus_identity : public application_shell
34 test_octopus_identity() : application_shell(class_name()) {}
35 DEFINE_CLASS_NAME("test_octopus_identity");
36 virtual int execute();
39 int test_octopus_identity::execute()
41 octopus logos("local", 18 * MEGABYTE);
43 identity_infoton *ide = new identity_infoton;
44 octopus_request_id junk_id = octopus_request_id::randomized_id();
49 if (ide->packed_size() != packed.length())
50 deadly_error(class_name(), "packing test",
51 astring("the packed size was different than expected."));
53 outcome ret = logos.evaluate(ide, junk_id);
54 if (ret != tentacle::OKAY)
55 deadly_error(class_name(), "evaluate test",
56 astring("the evaluation failed with an error ")
57 + tentacle::outcome_name(ret));
60 octopus_request_id response_id; // based on bogus from before.
61 infoton *response = logos.acquire_result(junk_id._entity, response_id);
63 deadly_error(class_name(), "acquire test",
64 astring("the acquire_result failed to produce a result."));
66 identity_infoton *new_id = dynamic_cast<identity_infoton *>(response);
68 deadly_error(class_name(), "casting",
69 astring("the returned infoton is not the right type."));
71 octopus_entity my_ide = new_id->_new_name;
73 log(astring("new id is: ") + my_ide.text_form());
76 deadly_error(class_name(), "retrieving id",
77 astring("the new entity id is blank."));
80 log("octopus:: identity works for those functions tested.");
85 HOOPLE_MAIN(test_octopus_identity, )