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 <cstdio>
00027 #include <fstream>
00028 #include <iostream>
00029 #include <mpcl/net/corba/client_application.hh>
00030 #include <mpcl/net/corba/orb.hh>
00031 #include <mpcl/test.h>
00032 #include "test-sample_producer.hh"
00033
00034
00035 using mpcl::net::corba::TClientApplication;
00036 using mpcl::net::corba::TOrb;
00037 using mpcl::text::TString;
00038
00039
00040
00041
00042
00043
00044 static const char* _pkcIorFileName = "test-server.ior.txt";
00045
00046
00047 class TConsumerApplication :
00048 public virtual TClientApplication<TOrb>
00049 {
00050
00051 private:
00052
00054 typedef
00055 mpcl::TSampleProducer_var
00056 QTSampleProducer;
00057
00059 QTSampleProducer qtNamedSampleProducer1;
00060
00062 QTSampleProducer qtNamedSampleProducer2;
00063
00065 QTSampleProducer qtSampleProducer;
00066
00067
00068 public:
00069
00070 TConsumerApplication ( const char* pkcNAME ,
00071 const char* pkcRELEASE ,
00072 TOrb& rtORB ) :
00073 TClientApplication<TOrb> (pkcNAME, pkcRELEASE, rtORB) {}
00074
00075 void initialize (void);
00076
00077 int start (void);
00078
00079
00080 public:
00081
00082 TString programFileName (void) const
00083 {
00084 return "test-client";
00085 }
00086
00087 };
00088
00089
00090
00091
00092
00093
00094 void TConsumerApplication::initialize (void)
00095 {
00096
00097 std::string yIor;
00098 std::ifstream tIfstream (_pkcIorFileName);
00099
00100 tIfstream >> yIor;
00101 tIfstream.close();
00102 std::remove (_pkcIorFileName);
00103 qtNamedSampleProducer1 =
00104 rtOrb.request<mpcl::TSampleProducer, QTSampleProducer> ("corbaname:rir:#mpcl/test-server/sample_producer_1.object");
00105 qtNamedSampleProducer2 =
00106 rtOrb.request<mpcl::TSampleProducer, QTSampleProducer> ("corbaname:rir:#mpcl/test-server/sample_producer_2.object");
00107 qtSampleProducer =
00108 rtOrb.request<mpcl::TSampleProducer, QTSampleProducer> (yIor.c_str());
00109
00110 }
00111
00112
00113 int TConsumerApplication::start (void)
00114 {
00115
00116 TEST_INIT ("tests for class 'TConsumerApplication'");
00117
00118
00119
00120
00121 TEST_NUMBERS (0, qtSampleProducer->get());
00122 TEST_NUMBERS (1, qtSampleProducer->get());
00123 TEST_NUMBERS (2, qtSampleProducer->get());
00124 TEST_NUMBERS (3, qtSampleProducer->get());
00125
00126
00127
00128
00129 TEST_NUMBERS (10, qtNamedSampleProducer1->get());
00130 TEST_NUMBERS (11, qtNamedSampleProducer1->get());
00131 TEST_NUMBERS (12, qtNamedSampleProducer1->get());
00132 TEST_NUMBERS (13, qtNamedSampleProducer1->get());
00133
00134
00135
00136
00137 TEST_NUMBERS (20, qtNamedSampleProducer2->get());
00138 TEST_NUMBERS (21, qtNamedSampleProducer2->get());
00139 TEST_NUMBERS (22, qtNamedSampleProducer2->get());
00140 TEST_NUMBERS (23, qtNamedSampleProducer2->get());
00141
00142
00143
00144
00145 qtNamedSampleProducer1->finish();
00146
00147 TEST_MEMORY_STATUS;
00148 TEST_RETURN_CODE;
00149
00150 }
00151
00152
00154 int main (int argc, const char** argv)
00155 {
00156
00157 TEST_INIT ("tests for CORBA as client");
00158 try
00159 {
00160 TOrb tOrb (argc, argv);
00161 TConsumerApplication tApplication ("test-client", "0.0.0", tOrb);
00162
00163 tApplication.initialize();
00164 TEST_FUNCTION (tApplication.start());
00165 }
00166 catch (CORBA::SystemException&)
00167 {
00168 std::cerr << "ORB; caught CORBA::SystemException" << std::endl;
00169 TEST_FAIL;
00170 }
00171 catch (CORBA::Exception&)
00172 {
00173 std::cerr << "ORB; caught CORBA::Exception" << std::endl;
00174 TEST_FAIL;
00175 }
00176 catch (const mpcl::TException& rktEXCEPTION)
00177 {
00178 std::cerr << rktEXCEPTION;
00179 TEST_FAIL;
00180 }
00181 catch (std::exception& rktEXCEPTION)
00182 {
00183 std::cerr << rktEXCEPTION.what();
00184 TEST_FAIL;
00185 }
00186 catch (...)
00187 {
00188 std::cerr << "caught unknown exception" << std::endl;
00189 TEST_FAIL;
00190 }
00191 TEST_MEMORY_STATUS;
00192 TEST_RETURN_CODE;
00193
00194 }