⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple-test.cc

📁 MICO2.3.13 corba 环境平台
💻 CC
📖 第 1 页 / 共 4 页
字号:
    else      cout << "error2!\n" << flush;  }  else    cout << "error!\n" << flush;  cout << "Checking RelationshipIterator::next_n ()  ..." << flush;  iterator->next_n (10, rel_handles);  if (rel_handles->length () == 1 &&       ( (*rel_handles)[0].the_relationship->is_identical (relship1)))    cout << "ok.\n" << flush;  else    cout << "error!\n" << flush;  iterator->destroy ();  cout << "Checking RelationshipIterator::next_one ()  ..." << flush;  CosRelationships::RelationshipHandle* rel_handle;  role1->get_relationships (0, rel_handles, iterator);  iterator->next_one (rel_handle);  if (rel_handle->the_relationship->is_identical (relship1))    cout << "ok.\n" << flush;  else    cout << "error!\n" << flush;  // testing second level of MICO RS  cout << "Checking second level\n";  assert (!CORBA::is_nil (text_factory));  assert (!CORBA::is_nil (figure_factory));  Documents::Text_var text = text_factory->create_with_file     (CORBA::string_dup ("MICO Relationship Service."),      CORBA::string_dup ("thesis.tex"));  Documents::Figure_var obr1 = figure_factory->create_with_file     (CORBA::string_dup ("obr1"), CORBA::string_dup ("obr1.eps"));  Documents::Figure_var obr2 = figure_factory->create_with_file     (CORBA::string_dup ("obr2"), CORBA::string_dup ("obr2.eps"));   Documents::Figure_var obr3 = figure_factory->create_with_file     (CORBA::string_dup ("obr3"), CORBA::string_dup ("obr3.eps"));  Documents::Figure_var obr4 = figure_factory->create_with_file     (CORBA::string_dup ("obr4"), CORBA::string_dup ("obr4.eps"));  Documents::Figure_var obr5 = figure_factory->create_with_file     (CORBA::string_dup ("obr5"), CORBA::string_dup ("obr5.eps"));    assert (!CORBA::is_nil (text));  assert (!CORBA::is_nil (obr1));  assert (!CORBA::is_nil (obr2));  assert (!CORBA::is_nil (obr3));  assert (strcmp (text->file (), "thesis.tex") == 0);  cout << "Checking NodeFactory::create_node () ..." << flush;  CosGraphs::Node_var node_text = node_factory->create_node (text);  if (!CORBA::is_nil (node_text))    cout << "ok.\n";  else    cout << "error.\n";  cout << "Checking Node::related_object () ..." << flush;  exception = FALSE;#ifdef HAVE_EXCEPTIONS  try {#endif    node_text->related_object ();    node_text->related_object ();    if (!CORBA::is_nil (node_text->related_object ()))      if (Documents::Text::_narrow (node_text->related_object ()))	if ((Documents::Text::_narrow (node_text->related_object ()))	    ->name () != NULL)	  cout << "ok.\n";#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    cout << "failed.\n";  } catch (CORBA::UserException &e) {    cout << "error.\n";  }#endif  cout << "Checking Node::add_role () ..." << flush;  CosGraphs::Node_var node_obr1;     CosGraphs::Node_var node_obr2;  CosGraphs::Node_var node_obr3;  CosGraphs::Node_var node_obr4;  CosGraphs::Node_var node_obr5;#ifdef HAVE_EXCEPTIONS  try {#endif    node_obr1 = node_factory->create_node (obr1);    node_obr2 = node_factory->create_node (obr2);    node_obr3 = node_factory->create_node (obr3);    node_obr4 = node_factory->create_node (obr4);    node_obr5 = node_factory->create_node (obr5);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::Exception &e) {    cout << "can't create nodes!!! " << flush;  }#endif  CosGraphs::Role_var contains;  CosGraphs::Role_var containedin1;  CosGraphs::Role_var containedin2;  CosGraphs::Role_var containedin3;  CosGraphs::Role_var contains_obr1;  CosGraphs::Role_var containedin4;  CosGraphs::Role_var containedin5;  #ifdef HAVE_EXCEPTIONS  try {#endif    contains = CosGraphs::Role::_narrow       (contains_factory->create_role (node_text));    containedin1 = CosGraphs::Role::_narrow      (containedin_factory->create_role (node_obr1));    containedin2 = CosGraphs::Role::_narrow      (containedin_factory->create_role (node_obr2));    containedin3 = CosGraphs::Role::_narrow      (containedin_factory->create_role (node_obr3));    contains_obr1 = CosGraphs::Role::_narrow       (contains_factory->create_role (node_obr1));    containedin4 = CosGraphs::Role::_narrow      (containedin_factory->create_role (node_obr4));    containedin5 = CosGraphs::Role::_narrow      (containedin_factory->create_role (node_obr5));#ifdef HAVE_EXCEPTIONS  } catch (CosRelationships::RoleFactory::NilRelatedObject_catch &e) {    cout << "can't create roles - nil related object\n";  } catch (CosRelationships::RoleFactory::RelatedObjectTypeError_catch &e) {    cout << "can't create roles - related object type error\n";  } catch (::CORBA::SystemException_catch &e) {    cout << "can't create roles!!! system exception\n" << flush;  }#endif  assert (!CORBA::is_nil (contains));  exception = FALSE;#ifdef HAVE_EXCEPTIONS  try {#endif    node_text->add_role (contains);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    exception = TRUE;  }#endif  if (node_text->roles_of_node ()->length () == 1 && !exception)    cout << "ok.\n";  else    cout << "error.\n";  cout << "Checking Node::roles_of_node () ..." << flush;  exception = FALSE;  CosGraphs::Node::Roles_var node_roles;#ifdef HAVE_EXCEPTIONS  try {#endif    node_roles = node_text->roles_of_node ();    node_roles = node_text->roles_of_node ();    node_roles = node_text->roles_of_node ();#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    exception = TRUE;  }#endif  if (node_roles->length () == 1 && !exception)    cout << "ok.\n";  else    cout << "error.\n";   cout << "Checking Node::remove_role () ..." << flush;#ifdef HAVE_EXCEPTIONS  try {#endif    ::CORBA::InterfaceDef_var type = contains->_get_interface ();    node_text->remove_role (type);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    cout << "system exception\n";  } catch (CORBA::UserException &e) {    exception = TRUE;  }#endif  if (node_text->roles_of_node ()->length () == 0 && !exception)    cout << "ok.\n";  else    cout << "error.\n";  assert (!CORBA::is_nil (node_text));  cout << "Checking Node::roles_of_type () ..." << flush;  // in this time is role_of_types buggy  exception = FALSE;  Test::BaseRole_ptr base_role = Test::BaseRole::_narrow     (base_factory->create_role (node_text));  CORBA::InterfaceDef_var base_role_type = base_role->_get_interface ();  Test::DerivedRole1_ptr derived1_role = Test::DerivedRole1::_narrow     (derived_factory1->create_role (node_text));  CORBA::InterfaceDef_var derived1_role_type     = derived1_role->_get_interface ();  Test::DerivedRole2_ptr derived2_role = Test::DerivedRole2::_narrow     (derived_factory2->create_role (node_text));  CORBA::InterfaceDef_var derived2_role_type     = derived2_role->_get_interface ();  state_good = TRUE;  exception = FALSE;  exception2 = FALSE;#ifdef HAVE_EXCEPTIONS  try {#endif    node_text->add_role (derived1_role);    node_text->add_role (derived2_role);    node_roles = node_text->roles_of_type (derived1_role_type);    if (node_roles->length () == 1 	&& (!CORBA::is_nil (Test::DerivedRole1::_narrow ((*node_roles)[0]))))      state_good = TRUE;    else      state_good = FALSE;        if (state_good) {      node_roles = node_text->roles_of_type (derived2_role_type);      if (node_roles->length () == 1 	  && (Test::DerivedRole2::_narrow ((*node_roles)[0])))	state_good = TRUE;      else	state_good = FALSE;    }    if (state_good) {      node_roles = node_text->roles_of_type (base_role_type);      if (node_roles->length () == 2)	state_good = TRUE;      else	state_good = FALSE;    }    // cleaning up    node_text->remove_role (base_role_type);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    exception = TRUE;  } catch (CORBA::UserException &e) {    exception2 = TRUE;  }#endif    if (state_good && !exception2 && !exception)    cout << "ok.\n";  if (!state_good)    cout << "failed.\n";  if (exception)    cout << "failed2.\n";  if (exception2)    cout << "error.\n";    cout << "Checking Node::DuplicateRoleType exception ..." << flush;  exception = FALSE;#ifdef HAVE_EXCEPTIONS  try {#endif    node_text->add_role (contains);    node_text->add_role (contains);#ifdef HAVE_EXCEPTIONS  } catch (CosGraphs::Node::DuplicateRoleType_catch &e) {    exception = TRUE;  }#endif  if (exception)    cout << "ok.\n";  else    cout << "error.\n";    cout << "Checking Node::NoSuchRole exception ..." << flush;  exception = FALSE;  exception2 = FALSE;  exception3 = FALSE;#ifdef HAVE_EXCEPTIONS  try {    CORBA::InterfaceDef_var type;#endif    type = containedin1->_get_interface ();    node_text->remove_role (type);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    cout << "system exception\n";  } catch (CosGraphs::Node::NoSuchRole_catch &e) {    exception = TRUE;  }#endif#ifdef HAVE_EXCEPTIONS  try {    CORBA::InterfaceDef_var type;#endif    type = contains->_get_interface ();    node_text->remove_role (type);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    cout << "system exception\n";  } catch (CosGraphs::Node::NoSuchRole_catch &e) {    exception2 = TRUE;  }#endif#ifdef HAVE_EXCEPTIONS  try {    CORBA::InterfaceDef_var type;#endif    type = contains->_get_interface ();    node_text->remove_role (type);#ifdef HAVE_EXCEPTIONS  } catch (CORBA::SystemException_catch &e) {    cout << "system exception\n";  } catch (CosGraphs::Node::NoSuchRole_catch &e) {    exception3 = TRUE;  }#endif      if (exception && !exception2 && exception3)     cout << "ok.\n";  else    cout << "error.\n";  cout << "Checking Role::get_edges () " << flush;  assert (node_text->roles_of_node ()->length () == 0);  node_text->add_role (contains);  node_obr1->add_role (containedin1);  node_obr1->add_role (contains_obr1);  node_obr2->add_role (containedin2);  node_obr3->add_role (containedin3);  node_obr4->add_role (containedin4);  node_obr5->add_role (containedin5);    cout << "." << flush;  nr.length (2);  nr[0].name = CORBA::string_dup ("ContainsRole");  nr[1].name = CORBA::string_dup ("ContainedInRole");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -