t_identity.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : octopus identity test                                             *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    Checks out the client identification methods in octopus.                 *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 2002-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
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     // bogus right now.
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;  // based on bogus from before.
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 

Generated on Fri Nov 28 04:29:39 2008 for HOOPLE Libraries by  doxygen 1.5.1