|
From: <tei...@us...> - 2003-11-27 17:32:16
|
Update of /cvsroot/ccmtools/ccmtools/test/CppRemoteGenerator/facet_exception/CCM_Test
In directory sc8-pr-cvs1:/tmp/cvs-serv12261/facet_exception/CCM_Test
Added Files:
_check_CCM_Remote_CCM_Session_Hello_remote.cc
Log Message:
I added some test cases for the remote generator. Note that these tests will be removed (and added in the test/CppGenerator) after the remote generator is able to run all user_type tests.
--- NEW FILE: _check_CCM_Remote_CCM_Session_Hello_remote.cc ---
#include <cstdlib>
#include <iostream>
#include <string>
#include <CCM_Utils/Debug.h>
#include <CORBA.h>
#include <coss/CosNaming.h>
#include <CCM_Remote/CCM_Session_Hello/HelloHome_remote.h>
#include <Hello.h>
using namespace std;
using namespace CCM_Utils;
//==============================================================================
// Implementation of remote client test
//==============================================================================
int main (int argc, char *argv[])
{
Debug::set_global(true);
DEBUGNL("C++_remote_test_client()");
// Initialize ORB
int argc_=3;
char ns[200];
sprintf(ns,"NameService=%s",getenv("CCM_NAME_SERVICE"));
char* argv_[] = {"", "-ORBInitRef", ns };
DEBUGNL(ns);
CORBA::ORB_var orb = CORBA::ORB_init(argc_, argv_);
/**
* Server-side code
*/
CCM::register_all_factories (orb);
int error = deploy_HelloHome(orb, "HelloHome:1.0");
if(!error) {
cout << "HelloHome stand-alone server is running..." << endl;
}
else {
cerr << "ERROR: Can't start components!" << endl;
assert(0);
}
/**
* Client-side code
*/
CORBA::Object_var obj = orb->resolve_initial_references ("NameService");
CosNaming::NamingContextExt_var nc =
CosNaming::NamingContextExt::_narrow (obj);
assert (!CORBA::is_nil (nc));
// Deployment
// Find ComponentHomes in the Naming-Service
obj = nc->resolve_str ("HelloHome:1.0");
assert (!CORBA::is_nil (obj));
HelloHome_var myHelloHome = HelloHome::_narrow (obj);
// Create component instances
Hello_var myHello = myHelloHome->create();
// Provide facets
//Console_var console = myHello->provide_console();
Console_var Consoleconsole = myHello->provide_console();
myHello->configuration_complete();
DEBUGNL("==== Begin Test Case =============================================" );
char* s = CORBA::string_dup("Salomon.Automation");
CORBA::Long len;
len = Consoleconsole->println(s);
assert(len == strlen(s));
try {
char* s = CORBA::string_dup("error");
Consoleconsole->println(s);
assert(0);
}
catch(const ::error& e) {
cout << "OK: error exception catched!" << endl;
}
catch(const CORBA::SystemException& e) {
cout << "CORBA::SystemException catched!" << endl;
assert(0);
}
try {
char* s = CORBA::string_dup("super_error");
Consoleconsole->println(s);
assert(0);
}
catch(const ::super_error& e) {
cout << "OK: super_error exception catched!" << endl;
}
catch(const CORBA::SystemException& e) {
cout << "CORBA::SystemException catched!" << endl;
assert(0);
}
try {
char* s = CORBA::string_dup("fatal_error");
Consoleconsole->println(s);
assert(0);
}
catch(const ::fatal_error& e) {
cout << "OK: fatal_error exception catched!" << endl;
}
catch(const CORBA::SystemException& e) {
cout << "CORBA::SystemException catched!" << endl;
assert(0);
}
DEBUGNL("==== End Test Case ===============================================" );
// Un-Deployment
// Destroy component instances
myHello->remove();
}
|