feisty meow concerns codebase  2.140
t_identity.cpp
Go to the documentation of this file.
1 /*****************************************************************************\
2 * *
3 * Name : octopus identity test *
4 * Author : Chris Koeritz *
5 * *
6 * Purpose: *
7 * *
8 * Checks out the client identification methods in octopus. *
9 * *
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 \*****************************************************************************/
18 
19 #include <basis/astring.h>
20 #include <octopus/entity_defs.h>
22 #include <octopus/infoton.h>
23 #include <octopus/octopus.h>
24 #include <octopus/tentacle.h>
26 #include <loggers/console_logger.h>
28 
30 
31 class test_octopus_identity : public application_shell
32 {
33 public:
34  test_octopus_identity() : application_shell(class_name()) {}
35  DEFINE_CLASS_NAME("test_octopus_identity");
36  virtual int execute();
37 };
38 
39 int test_octopus_identity::execute()
40 {
41  octopus logos("local", 18 * MEGABYTE);
42 
43  identity_infoton *ide = new identity_infoton;
44  octopus_request_id junk_id = octopus_request_id::randomized_id();
45  // bogus right now.
46 
47  byte_array packed;
48  ide->pack(packed);
49  if (ide->packed_size() != packed.length())
50  deadly_error(class_name(), "packing test",
51  astring("the packed size was different than expected."));
52 
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));
58 log("point a");
59 
60  octopus_request_id response_id; // based on bogus from before.
61  infoton *response = logos.acquire_result(junk_id._entity, response_id);
62  if (!response)
63  deadly_error(class_name(), "acquire test",
64  astring("the acquire_result failed to produce a result."));
65 
66  identity_infoton *new_id = dynamic_cast<identity_infoton *>(response);
67  if (!new_id)
68  deadly_error(class_name(), "casting",
69  astring("the returned infoton is not the right type."));
70 
71  octopus_entity my_ide = new_id->_new_name;
72 
73 log(astring("new id is: ") + my_ide.text_form());
74 
75  if (my_ide.blank())
76  deadly_error(class_name(), "retrieving id",
77  astring("the new entity id is blank."));
78 
79 
80  log("octopus:: identity works for those functions tested.");
81 
82  return 0;
83 }
84 
85 HOOPLE_MAIN(test_octopus_identity, )
86 
#define deadly_error(c, f, i)
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition: enhance_cpp.h:45
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Definition: hoople_main.h:61
const int MEGABYTE
Number of bytes in a megabyte.
Definition: definitions.h:135