00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #if !defined(DEBUG)
00021 #define DEBUG 1
00022 #endif
00023
00024 #include <assert.h>
00025 #include <assert_pp.h>
00026
00027 #include <BrokerC.h>
00028 #include <ManagerImpl.hh>
00029
00030 #include <StubTask.hh>
00031 #include <StubPolicy.hh>
00032
00033 int main(int argc, char *argv[])
00034 {
00035 int retval = EXIT_SUCCESS;
00036
00037
00038 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
00039
00040 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00041
00042 PortableServer::POA_var root_poa =
00043 PortableServer::POA::_narrow(obj.in());
00044 PortableServer::POAManager_var mgr = root_poa->the_POAManager();
00045 mgr->activate();
00046
00047
00048 ManagerImpl *mi = new ManagerImpl("dummy");
00049 Broker::Manager_var manager;
00050
00051 manager = mi->_this();
00052
00053 StubPolicy *sp = new StubPolicy("dummy");
00054 Broker::Policy_var policy;
00055
00056 policy = sp->_this();
00057
00058 StubTask *st = new StubTask();
00059 Broker::Task_var task;
00060
00061 task = st->_this();
00062
00063
00064 assert(CORBA::is_nil(manager->CurrentPolicy()));
00065
00066 Broker::ScheduleParameters sparam;
00067 sparam.length(0);
00068
00069
00070 manager->AddTask(task.in(), sparam);
00071
00072 manager->RemoveTask(task.in());
00073
00074
00075 manager->CurrentPolicy(policy.in());
00076
00077 assert(!CORBA::is_nil(manager->CurrentPolicy()));
00078 assert(sp->sp_Tasks.length() == 0);
00079
00080
00081 manager->CurrentPolicy(Broker::Policy::_nil());
00082 assert(CORBA::is_nil(manager->CurrentPolicy()));
00083
00084
00085 manager->AddTask(task.in(), sparam);
00086 manager->CurrentPolicy(policy.in());
00087 assert(sp->sp_Tasks.length() == 1);
00088
00089
00090 manager->CurrentPolicy(Broker::Policy::_nil());
00091
00092 assert(sp->sp_Tasks.length() == 0);
00093
00094
00095 manager->CurrentPolicy(policy.in());
00096 assert(sp->sp_Tasks.length() == 1);
00097
00098
00099 manager->RemoveTask(task.in());
00100 assert(sp->sp_Tasks.length() == 0);
00101 manager->AddTask(task.in(), sparam);
00102 assert(sp->sp_Tasks.length() == 1);
00103
00104 task = Broker::Task::_nil();
00105 delete st;
00106
00107
00108
00109
00110 manager = Broker::Manager::_nil();
00111 delete mi;
00112
00113 return( retval );
00114 }