Ejemplo n.º 1
0
void
test_reference_to_servant_active_object(PortableServer::POA_ptr root_poa)
{
  test_i test;
  CORBA::ULong expected_refcount = 1;

  PortableServer::ObjectId_var id =
    root_poa->activate_object (&test);
  expected_refcount++;

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

  PortableServer::ServantBase_var servant =
    root_poa->reference_to_servant (object.in ());
  ++expected_refcount;

  root_poa->deactivate_object (id.in ());
  --expected_refcount;

  CORBA::ULong refcount =
    test._refcount_value ();

  ACE_UNUSED_ARG (refcount);
  ACE_UNUSED_ARG (expected_refcount);
  ACE_ASSERT (expected_refcount == refcount);
}
Ejemplo n.º 2
0
void
test_poas (CORBA::ORB_ptr orb,
           PortableServer::POA_ptr root_poa,
           PortableServer::POA_ptr first_poa,
           PortableServer::POA_ptr second_poa,
           PortableServer::POA_ptr third_poa,
           PortableServer::POA_ptr forth_poa,
           int perform_deactivation_test)
{
  {
    test_i servant (root_poa);

    CORBA::Object_var obj = root_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = root_poa->reference_to_id (obj.in ());

    root_poa->activate_object_with_id (id.in (),
                                       &servant);

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

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      root_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      root_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = root_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = root_poa->servant_to_id (&servant);

    ACE_ASSERT (id_from_servant.in () == id.in ());

    root_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        root_poa->activate_object_with_id (id.in (),
                                           &servant);

        servant_from_reference = root_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        root_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (root_poa);

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

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

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = root_poa->create_reference_with_id (id.in (),
                                              "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    root_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (first_poa);

    CORBA::Object_var obj = first_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = first_poa->reference_to_id (obj.in ());

    first_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = first_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      first_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      first_poa->id_to_servant (id.in ());

    if (servant_from_reference .in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    first_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        first_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = first_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        first_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (first_poa);

    PortableServer::ObjectId_var id = first_poa->activate_object (&servant);

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

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = first_poa->create_reference_with_id (id.in (),
                                               "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    first_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (second_poa);

    CORBA::Object_var obj = second_poa->create_reference ("IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id = second_poa->reference_to_id (obj.in ());

    second_poa->activate_object_with_id (id.in (),
                                         &servant);

    obj = second_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      second_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      second_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = second_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = second_poa->servant_to_id (&servant);

    ACE_ASSERT (id_from_servant.in () == id.in ());

    second_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        second_poa->activate_object_with_id (id.in (),
                                             &servant);

        servant_from_reference = second_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        second_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (second_poa);

    PortableServer::ObjectId_var id = second_poa->activate_object (&servant);

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

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = second_poa->create_reference_with_id (id.in (),
                                                "IDL:test:1.0");

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    second_poa->deactivate_object (id.in ());
  }

  {
    test_i servant (third_poa);
    PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello");

    CORBA::Object_var obj = third_poa->create_reference_with_id (id.in (),
                                                                 "IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_reference = third_poa->reference_to_id (obj.in ());

    string = PortableServer::ObjectId_to_string (id_from_reference.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_reference.in () == id.in ());

    third_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = third_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      third_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      third_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    obj = third_poa->servant_to_reference (&servant);

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    obj = servant._this ();

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_servant = third_poa->servant_to_id (&servant);

    string = PortableServer::ObjectId_to_string (id_from_servant.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_servant.in () == id.in ());

    third_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        third_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = third_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        third_poa->deactivate_object (id.in ());
      }
  }

  {
    test_i servant (forth_poa);
    PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("hello");

    CORBA::Object_var obj = forth_poa->create_reference_with_id (id.in (),
                                                                 "IDL:test:1.0");

    CORBA::String_var string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ObjectId_var id_from_reference = forth_poa->reference_to_id (obj.in ());

    string = PortableServer::ObjectId_to_string (id_from_reference.in ());
    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    ACE_ASSERT (id_from_reference.in () == id.in ());

    forth_poa->activate_object_with_id (id.in (),
                                        &servant);

    obj = forth_poa->id_to_reference (id.in ());

    string = orb->object_to_string (obj.in ());

    ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));

    PortableServer::ServantBase_var servant_from_reference =
      forth_poa->reference_to_servant (obj.in ());

    PortableServer::ServantBase_var servant_from_id =
      forth_poa->id_to_servant (id.in ());

    if (servant_from_reference.in () != servant_from_id.in ()
        || servant_from_reference.in () != &servant)
      {
        ACE_ERROR ((LM_ERROR,
                    "Mismatched servant_from_reference, "
                    "servant_from_id and &servant\n"));
      }

    forth_poa->deactivate_object (id.in ());

    if (perform_deactivation_test)
      {
        forth_poa->activate_object_with_id (id.in (),
                                            &servant);

        servant_from_reference = forth_poa->reference_to_servant (obj.in ());

        ACE_ASSERT (servant_from_reference.in () == &servant);

        forth_poa->deactivate_object (id.in ());
      }
  }
}