Пример #1
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int status = 0;
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      Hello *hello_impl;
      ACE_NEW_RETURN (hello_impl,
                      Hello,
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var obj = root_poa->id_to_reference (id.in ());

      Test::Hello_var hello = Test::Hello::_narrow (obj.in ());

      Filter_Localhost filter;
      obj = filter.sanitize_profiles (hello.in ());
      Test::Hello_var after = Test::Hello::_narrow(obj.in());

      if (hello->_stubobj ()->base_profiles ().profile_count () ==
          after->_stubobj ()->base_profiles ().profile_count ())
        {
          ACE_ERROR ((LM_ERROR,
                      "ERROR: profiles were not correctly filtered\n"));
          status++;
        }

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      status++;
    }

  return status;
}
Пример #2
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv, "test");

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var tmp = orb->string_to_object(ior);

      if (CORBA::is_nil (tmp.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR, "Invalid IOR.\n")
                            ,1);
        }

      {
        // Set the Synch Scopes

        CORBA::Any scope_as_any;

        if (synch_none == true)
          {
            ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Applying SYNC_NONE.\n"));
            scope_as_any <<= Messaging::SYNC_NONE;
          }
        else if (synch_delayed == true)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "(%P|%t) - Applying SYNC_DELAYED_BUFFERING.\n"));
            scope_as_any <<= TAO::SYNC_DELAYED_BUFFERING;
          }

        CORBA::PolicyList policies (1);
        policies.length (1);
        policies[0] =
          orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                              scope_as_any);

        if (level_thread == true)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "(%P|%t) - Applying Synch Scope at thread level.\n"));

            CORBA::Object_var object =
              orb->resolve_initial_references ("PolicyCurrent");
            CORBA::PolicyCurrent_var policy_current =
              CORBA::PolicyCurrent::_narrow (object.in ());

            policy_current->set_policy_overrides (policies,
                                                  CORBA::ADD_OVERRIDE);
          }
        else if (level_orb == true)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "(%P|%t) - Applying Synch Scope at orb level.\n"));

            CORBA::Object_var obj =
              orb->resolve_initial_references("ORBPolicyManager");
            CORBA::PolicyManager_var policy_manager =
              CORBA::PolicyManager::_narrow(obj.in());

            policy_manager->set_policy_overrides (policies,
                                                  CORBA::ADD_OVERRIDE);
          }
        else if (level_obj == true)
          {
            ACE_DEBUG ((LM_DEBUG,
                        "(%P|%t) - Applying Synch Scope at Object level.\n"));

            tmp = tmp->_set_policy_overrides (policies, CORBA::SET_OVERRIDE);
          }

        policies[0]->destroy ();
      }

      Test::Hello_var hello =
        Test::Hello::_narrow(tmp.in ());

      if (CORBA::is_nil (hello.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil Test::Hello reference <%s>\n",
                             ior),
                            1);
        }

      // If a blocking connection is initiated in the next step
      // the test will get an exception indicating test failure.
      // Be sure you IOR is for the localhost endpoint, else
      // grab a book and wait around for timeout.
      hello->get_string ();

      TAO::Transport_Cache_Manager &tcm =
        hello->orb_core ()->lane_resources ().transport_cache ();

      TAO_Base_Transport_Property desc (hello->_stubobj ()->profile_in_use ()->endpoint ());

      if (tcm.current_size() == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
           "The Transport Cache shouldn't be empty here.\n"),
          1);
        }

      size_t busy_count = 0;
      TAO_Transport *transport = 0;
      TAO::Transport_Cache_Manager::Find_Result find_result =
        tcm.find_transport (&desc, transport, busy_count);
      // We don't need this transport any more. Release the ownership.
      transport->remove_reference ();

      switch (find_result){
        case TAO::Transport_Cache_Manager::CACHE_FOUND_NONE:
          {
            ACE_ERROR_RETURN ((LM_ERROR,
              ACE_TEXT("Expected to find a transport in the cache.\n")
              ),1);
          }
        case TAO::Transport_Cache_Manager::CACHE_FOUND_CONNECTING:
          {
            ACE_DEBUG (( LM_DEBUG,
              ACE_TEXT ("Transport Cache contains connecting entry as expected.\n")
              ));
            break; // that's what we expected
          }
        case TAO::Transport_Cache_Manager::CACHE_FOUND_BUSY:
          {
            ACE_ERROR_RETURN ((LM_ERROR,
              ACE_TEXT("Cached Transport is busy.  Should not happen because there's no server.\n")
              ),1);
          }
        case TAO::Transport_Cache_Manager::CACHE_FOUND_AVAILABLE:
          {
            ACE_ERROR_RETURN ((LM_ERROR,
              ACE_TEXT("Cached Transport is available.  Should not happen because there's no server.\n")
              ),1);
          }
        default:
          {
            ACE_ERROR_RETURN ((LM_ERROR,
              ACE_TEXT("Transport_Cache::find returned unknown status.\n")
              ),1);
          }
      }

      orb->destroy ();
    }
  catch (const CORBA::Exception &ex)
    {
      ACE_ERROR ((LM_ERROR, "ERROR: Exception caught: %s\"%s\"\n"
      , ex._name(), ex._rep_id ()));
      return 1;
    }

  return 0;
}