00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <basis/istring.h>
00020 #include <octopus/entity_defs.h>
00021 #include <octopus/identity_infoton.h>
00022 #include <octopus/infoton.h>
00023 #include <octopus/octopus.h>
00024 #include <octopus/tentacle.h>
00025 #include <opsystem/application_shell.h>
00026 #include <loggers/console_logger.h>
00027 #include <data_struct/static_memory_gremlin.h>
00028
00030
00031 class test_octopus_identity : public application_shell
00032 {
00033 public:
00034 test_octopus_identity() : application_shell(class_name()) {}
00035 IMPLEMENT_CLASS_NAME("test_octopus_identity");
00036 virtual int execute();
00037 };
00038
00039 int test_octopus_identity::execute()
00040 {
00041 octopus logos("local", 18 * MEGABYTE);
00042
00043 identity_infoton *ide = new identity_infoton;
00044 octopus_request_id junk_id = octopus_request_id::randomized_id();
00045
00046
00047 byte_array packed;
00048 ide->pack(packed);
00049 if (ide->packed_size() != packed.length())
00050 deadly_error(class_name(), "packing test",
00051 istring("the packed size was different than expected."));
00052
00053 outcome ret = logos.evaluate(ide, junk_id);
00054 if (ret != tentacle::OKAY)
00055 deadly_error(class_name(), "evaluate test",
00056 istring("the evaluation failed with an error ")
00057 + tentacle::outcome_name(ret));
00058 log("point a");
00059
00060 octopus_request_id response_id;
00061 infoton *response = logos.acquire_result(junk_id._entity, response_id);
00062 if (!response)
00063 deadly_error(class_name(), "acquire test",
00064 istring("the acquire_result failed to produce a result."));
00065
00066 identity_infoton *new_id = dynamic_cast<identity_infoton *>(response);
00067 if (!new_id)
00068 deadly_error(class_name(), "casting",
00069 istring("the returned infoton is not the right type."));
00070
00071 octopus_entity my_ide = new_id->_new_name;
00072
00073 log(istring("new id is: ") + my_ide.text_form());
00074
00075 if (my_ide.blank())
00076 deadly_error(class_name(), "retrieving id",
00077 istring("the new entity id is blank."));
00078
00079
00080 log("octopus:: identity works for those functions tested.");
00081
00082 return 0;
00083 }
00084
00085 HOOPLE_MAIN(test_octopus_identity, )
00086