00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <cstdlib>
00027 #include <fstream>
00028 #include <iostream>
00029 #include <mpcl/net/corba/orb.hh>
00030 #include <mpcl/net/corba/server_application.hh>
00031 #include <mpcl/system/system.hh>
00032 #include <mpcl/test.h>
00033 #include "test-sample_producer.hh"
00034
00035
00036 using mpcl::net::corba::TOrb;
00037 using mpcl::net::corba::TServerApplication;
00038
00039
00040
00041
00042
00043
00048 template <typename TOrb>
00049 class TSampleProducer :
00050 public POA_mpcl::TSampleProducer ,
00051 public PortableServer::RefCountServantBase
00052 {
00053
00054 private:
00055
00057 long int liValue;
00058
00060 TOrb& rtOrb;
00061
00062
00063 public:
00064
00065 TSampleProducer (TOrb& rtORB) :
00066 POA_mpcl::TSampleProducer () ,
00067 PortableServer::RefCountServantBase () ,
00068 liValue (0) ,
00069 rtOrb (rtORB) {}
00070
00072 CORBA::Long get (void)
00073 {
00074 return liValue++;
00075 }
00076
00078 void finish (void)
00079 {
00080 rtOrb.finish();
00081 }
00082
00083 };
00084
00085
00087 class TColocatedApplication :
00088 public TServerApplication<TOrb>
00089 {
00090
00091 private:
00092
00094 typedef
00095 TSampleProducer<TOrb>
00096 TCorbaSampleProducer;
00097
00099 typedef
00100 mpcl::TSampleProducer_var
00101 QTCorbaSampleProducer;
00102
00104 QTCorbaSampleProducer qtSampleProducer;
00105
00106
00107 public:
00108
00109 TColocatedApplication ( const char* pkcNAME ,
00110 const char* pkcRELEASE ,
00111 TOrb& rtORB ) :
00112 TServerApplication<TOrb> (pkcNAME, pkcRELEASE, rtORB) {}
00113
00114 void initialize (void)
00115 {
00116 TCorbaSampleProducer* ptSampleProducer;
00117
00118 ptSampleProducer = new TCorbaSampleProducer (rtOrb);
00119 qtSampleProducer =
00120 rtOrb.enrol<TCorbaSampleProducer, QTCorbaSampleProducer> (ptSampleProducer);
00121 }
00122
00123 int start (void)
00124 {
00125 TEST_INIT ("tests for class 'TClientApplication'");
00126
00127 TServerApplication<TOrb>::start();
00128 TEST_NUMBERS (0, qtSampleProducer->get());
00129 TEST_NUMBERS (1, qtSampleProducer->get());
00130 TEST_NUMBERS (2, qtSampleProducer->get());
00131 TEST_NUMBERS (3, qtSampleProducer->get());
00132
00133 TEST_MEMORY_STATUS;
00134 TEST_RETURN_CODE;
00135 }
00136
00137
00138 public:
00139
00140 mpcl::TString programFileName (void) const
00141 {
00142 return "test-colocated";
00143 }
00144
00145 };
00146
00147
00149 int main (int argc, const char** argv)
00150 {
00151
00152 TEST_INIT ("tests for CORBA (colocated)");
00153
00154 try
00155 {
00156 TOrb tOrb (argc, argv);
00157 TColocatedApplication tApplication ("test-colocated", "0.0.0", tOrb);
00158
00159 tOrb.setColocated (true);
00160 tApplication.initialize();
00161 TEST_FUNCTION (tApplication.start());
00162 }
00163 catch (CORBA::SystemException&)
00164 {
00165 std::cerr << "ORB; caught CORBA::SystemException" << std::endl;
00166 TEST_FAIL;
00167 }
00168 catch (CORBA::Exception&)
00169 {
00170 std::cerr << "ORB; caught CORBA::Exception" << std::endl;
00171 TEST_FAIL;
00172 }
00173 catch (const mpcl::TException& rktEXCEPTION)
00174 {
00175 std::cerr << rktEXCEPTION;
00176 TEST_FAIL;
00177 }
00178 catch (std::exception& rktEXCEPTION)
00179 {
00180 std::cerr << rktEXCEPTION.what();
00181 TEST_FAIL;
00182 }
00183 catch (...)
00184 {
00185 std::cerr << "caught unknown exception" << std::endl;
00186 TEST_FAIL;
00187 }
00188 TEST_MEMORY_STATUS;
00189 TEST_RETURN_CODE;
00190
00191 }