|
From: Teiniker E. <tei...@us...> - 2007-01-24 14:15:43
|
Update of /cvsroot/ccmtools/ccmtools/test/CppRemoteGenerator/attribute_module_types/impl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10512/test/CppRemoteGenerator/attribute_module_types/impl Added Files: _check_ccmtools_remote_world_europe_austria_Test.cc Removed Files: _check_world_europe_austria_ccm_remote_Test.cc Log Message: Refactored test cases --- NEW FILE: _check_ccmtools_remote_world_europe_austria_Test.cc --- /*** * CCM Tools Test Client * * This file was automatically generated by CCM Tools * <http://ccmtools.sourceforge.net/> * * This test client is part of the remote component test concept. ***/ #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef HAVE_MICO #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <ccmtools/remote/CCMContainer.h> #include <CORBA.h> #include <coss/CosNaming.h> #include <ccmtools/remote/world/europe/austria/TestHome_remote.h> #include <ccmtools_corba_world_europe_austria_Test.h> using namespace std; //============================================================================== // Implementation of remote client test //============================================================================== int main (int argc, char *argv[]) { cout << "Enter C++ remote test client" << endl; // Initialize ORB int argc_ = 3; char* argv_[] = { "", "-ORBInitRef", "NameService=corbaloc:iiop:1.2@localhost:5050/NameService" }; CORBA::ORB_var orb = CORBA::ORB_init(argc_, argv_); /** * Server-side code */ // Register all value type factories with the ORB ::ccmtools::remote::register_all_factories (orb); // Deploy local and remote component homes int error = 0; error += deploy_world_europe_austria_TestHome("TestHome"); error += deploy_ccmtools_remote_world_europe_austria_TestHome(orb, "TestHome"); if(!error) { cout << "TestHome server is running..." << endl; } else { cerr << "ERROR: Can't deploy components!" << endl; return -1; } // For testing we use CORBA collocation // orb->run(); /** * Client-side code */ CORBA::Object_var obj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var nc = CosNaming::NamingContextExt::_narrow(obj); // Deployment // Find ComponentHomes in the Naming-Service obj = nc->resolve_str("TestHome"); ::ccmtools::corba::world::europe::austria::TestHome_var myTestHome = ::ccmtools::corba::world::europe::austria::TestHome::_narrow (obj); // Create component instances ::ccmtools::corba::world::europe::austria::Test_var myTest = myTestHome->create(); // Provide facets ::ccmtools::corba::world::europe::austria::BasicTypeInterface_var inBasicType = myTest->provide_inBasicType(); ::ccmtools::corba::world::europe::austria::UserTypeInterface_var inUserType = myTest->provide_inUserType(); // Connect receptacles myTest->connect_outBasicType(inBasicType); myTest->connect_outUserType(inUserType); myTest->configuration_complete(); cout << "==== Begin Test Case ===================================" << endl; // --------------------------------------------------------------------- // Component Attribute Test Cases // --------------------------------------------------------------------- { cout << "Component Attributes (Basic Types) Test..."; CORBA::Short short_value = -7; myTest->short_value(short_value); CORBA::Short short_result = myTest->short_value(); assert(short_value == short_result); CORBA::Long long_value = -7777; myTest->long_value(long_value); CORBA::Long long_result = myTest->long_value(); assert(long_result == long_value); CORBA::UShort ushort_value = 7; myTest->ushort_value(ushort_value); CORBA::UShort ushort_result = myTest->ushort_value(); assert(ushort_result == ushort_value); CORBA::ULong ulong_value = 7777; myTest->ulong_value(ulong_value); CORBA::ULong ulong_result = myTest->ulong_value(); assert(ulong_result == ulong_value); CORBA::Float float_value = -77.77; myTest->float_value(float_value); CORBA::Float float_result = myTest->float_value(); assert(float_result == float_value); CORBA::Double double_value = -77.7777; myTest->double_value(double_value); CORBA::Double double_result = myTest->double_value(); assert(double_result == double_value); CORBA::Char char_value = 'x'; myTest->char_value(char_value); CORBA::Char char_result = myTest->char_value(); assert(char_result == char_value); char* string_value = "0123456789"; myTest->string_value(string_value); char* string_result = myTest->string_value(); assert(strcmp(string_value, string_result)==0); CORBA::Boolean boolean_value = true; myTest->boolean_value(boolean_value); CORBA::Boolean boolean_result = myTest->boolean_value(); assert(boolean_result == boolean_value); CORBA::Octet octet_value = 0xff; myTest->octet_value(octet_value); CORBA::Octet octet_result = myTest->octet_value(); assert(octet_result == octet_value); cout << "OK!" << endl; } { cout << "Component Attributes (User Types) Test..."; { // enum Color {red, green, blue, black, orange} ::ccmtools::corba::world::europe::austria::Color value = ::ccmtools::corba::world::europe::austria::blue; ::ccmtools::corba::world::europe::austria::Color result; myTest->color_value(value); result = myTest->color_value(); assert(result == value); } { // struct Person { long id; string name; } ::ccmtools::corba::world::europe::austria::Person value; ::ccmtools::corba::world::europe::austria::Person_var result; value.name = CORBA::string_dup("Egon"); value.id = 3; myTest->person_value(value); result = myTest->person_value(); assert(strcmp(result->name,value.name) == 0); assert(result->id == value.id); } { // struct Address { string street; long number; Person resident; } ::ccmtools::corba::world::europe::austria::Address value; ::ccmtools::corba::world::europe::austria::Address_var result; ::ccmtools::corba::world::europe::austria::Person person; value.street = CORBA::string_dup("Waltendorf"); value.number = 7; person.name = CORBA::string_dup("Egon"); person.id = 3; value.resident = person; myTest->address_value(value); result = myTest->address_value(); assert(strcmp(result->street, value.street) == 0); assert(result->number == value.number); assert(strcmp(result->resident.name, value.resident.name) == 0); assert(result->resident.id == value.resident.id); } { // typedef sequence<long> LongList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::LongList_var value = new ::ccmtools::corba::world::europe::austria::LongList; ::ccmtools::corba::world::europe::austria::LongList_var result; value->length(MAX_SIZE); for(int i=0;i<MAX_SIZE;i++) { (*value)[i] = i; } myTest->longList_value(value); result = myTest->longList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert((*result)[i] == (*value)[i]); } } { // typedef sequence<string> StringList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::StringList_var value = new ::ccmtools::corba::world::europe::austria::StringList; ::ccmtools::corba::world::europe::austria::StringList_var result; value->length(MAX_SIZE); for(int i=0; i < MAX_SIZE; i++) { (*value)[i] = "Egon"; } myTest->stringList_value(value); result = myTest->stringList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert(strcmp((*result)[i],(*value)[i]) == 0); } } { // typedef sequence<Person> PersonList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::PersonList_var value = new ::ccmtools::corba::world::europe::austria::PersonList; ::ccmtools::corba::world::europe::austria::PersonList_var result; value->length(MAX_SIZE); for(int i=0; i < MAX_SIZE; i++) { (*value)[i].name = "Andrea"; (*value)[i].id = i; } myTest->personList_value(value); result = myTest->personList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert(strcmp((*result)[i].name,(*value)[i].name) == 0); assert((*result)[i].id == (*value)[i].id); } } { // typedef long time_t; ::ccmtools::corba::world::europe::austria::time_t value = -7777; ::ccmtools::corba::world::europe::austria::time_t result; myTest->long_value(value); result = myTest->long_value(); assert(result == value); } cout << "OK!" << endl; } // --------------------------------------------------------------------- // Facet Attribute Test Cases // --------------------------------------------------------------------- { cout << "Facet Attributes (Basic Types) Test..."; CORBA::Short short_value = -7; inBasicType->short_value(short_value); CORBA::Short short_result = inBasicType->short_value(); assert(short_value == short_result); CORBA::Long long_value = -7777; inBasicType->long_value(long_value); CORBA::Long long_result = inBasicType->long_value(); assert(long_result == long_value); CORBA::UShort ushort_value = 7; inBasicType->ushort_value(ushort_value); CORBA::UShort ushort_result = inBasicType->ushort_value(); assert(ushort_result == ushort_value); CORBA::ULong ulong_value = 7777; inBasicType->ulong_value(ulong_value); CORBA::ULong ulong_result = inBasicType->ulong_value(); assert(ulong_result == ulong_value); CORBA::Float float_value = -77.77; inBasicType->float_value(float_value); CORBA::Float float_result = inBasicType->float_value(); assert(float_result == float_value); CORBA::Double double_value = -77.7777; inBasicType->double_value(double_value); CORBA::Double double_result = inBasicType->double_value(); assert(double_result == double_value); CORBA::Char char_value = 'x'; inBasicType->char_value(char_value); CORBA::Char char_result = inBasicType->char_value(); assert(char_result == char_value); char* string_value = "0123456789"; inBasicType->string_value(string_value); char* string_result = inBasicType->string_value(); assert(strcmp(string_value, string_result)==0); CORBA::Boolean boolean_value = true; inBasicType->boolean_value(boolean_value); CORBA::Boolean boolean_result = inBasicType->boolean_value(); assert(boolean_result == boolean_value); CORBA::Octet octet_value = 0xff; inBasicType->octet_value(octet_value); CORBA::Octet octet_result = inBasicType->octet_value(); assert(octet_result == octet_value); cout << "OK!" << endl; } { cout << "Facet Attributes (User Types) Test..."; { // enum Color {red, green, blue, black, orange} ::ccmtools::corba::world::europe::austria::Color value = ::ccmtools::corba::world::europe::austria::blue; ::ccmtools::corba::world::europe::austria::Color result; inUserType->color_value(value); result = inUserType->color_value(); assert(result == value); } { // struct Person { long id; string name; } ::ccmtools::corba::world::europe::austria::Person value; ::ccmtools::corba::world::europe::austria::Person_var result; value.name = CORBA::string_dup("Egon"); value.id = 3; inUserType->person_value(value); result = inUserType->person_value(); assert(strcmp(result->name,value.name) == 0); assert(result->id == value.id); } { // struct Address { string street; long number; Person resident; } ::ccmtools::corba::world::europe::austria::Address value; ::ccmtools::corba::world::europe::austria::Address_var result; ::ccmtools::corba::world::europe::austria::Person person; value.street = CORBA::string_dup("Waltendorf"); value.number = 7; person.name = CORBA::string_dup("Egon"); person.id = 3; value.resident = person; inUserType->address_value(value); result = inUserType->address_value(); assert(strcmp(result->street, value.street) == 0); assert(result->number == value.number); assert(strcmp(result->resident.name, value.resident.name) == 0); assert(result->resident.id == value.resident.id); } { // typedef sequence<long> LongList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::LongList_var value = new ::ccmtools::corba::world::europe::austria::LongList; ::ccmtools::corba::world::europe::austria::LongList_var result; value->length(MAX_SIZE); for(int i=0;i<MAX_SIZE;i++) { (*value)[i] = i; } inUserType->longList_value(value); result = inUserType->longList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert((*result)[i] == (*value)[i]); } } { // typedef sequence<string> StringList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::StringList_var value = new ::ccmtools::corba::world::europe::austria::StringList; ::ccmtools::corba::world::europe::austria::StringList_var result; value->length(MAX_SIZE); for(int i=0; i < MAX_SIZE; i++) { (*value)[i] = "Egon"; } inUserType->stringList_value(value); result = inUserType->stringList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert(strcmp((*result)[i],(*value)[i]) == 0); } } { // typedef sequence<Person> PersonList const int MAX_SIZE = 100; ::ccmtools::corba::world::europe::austria::PersonList_var value = new ::ccmtools::corba::world::europe::austria::PersonList; ::ccmtools::corba::world::europe::austria::PersonList_var result; value->length(MAX_SIZE); for(int i=0; i < MAX_SIZE; i++) { (*value)[i].name = "Andrea"; (*value)[i].id = i; } inUserType->personList_value(value); result = inUserType->personList_value(); assert((int)result->length() == MAX_SIZE); for(int i=0; i < (int)result->length(); i++) { assert(strcmp((*result)[i].name,(*value)[i].name) == 0); assert((*result)[i].id == (*value)[i].id); } } { // typedef long time_t; ::ccmtools::corba::world::europe::austria::time_t value = -7777; ::ccmtools::corba::world::europe::austria::time_t result; inUserType->time_t_value(value); result = inUserType->time_t_value(); assert(result == value); } cout << "OK!" << endl; } cout << "==== End Test Case =====================================" << endl; // Un-Deployment myTest->disconnect_outBasicType(); myTest->disconnect_outUserType(); // Destroy component instances myTest->remove(); // Un-Deployment error = undeploy_world_europe_austria_TestHome("TestHome"); error += undeploy_ccmtools_remote_world_europe_austria_TestHome(orb, "TestHome"); if(!error) { cout << "Exit C++ remote test client" << endl; } else { cerr << "ERROR: Can't undeploy components!" << endl; return -1; } } #endif // HAVE_MICO --- _check_world_europe_austria_ccm_remote_Test.cc DELETED --- |