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

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

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

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

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

      CORBA::String_var the_string =
        hello->get_string ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string.in ()));

      hello->shutdown ();

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      if (expect_error)
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - expected exception occurred!\n%s\n",
                      ex._info().c_str()));

          return 0;
        }
      else
        {
          ex._tao_print_exception ("Exception caught:");
          return 1;
        }
    }

  if (expect_error)
    {
      ACE_DEBUG ((LM_ERROR, "(%P|%t) client - expected error did not occur!\n"));

      return 1;
    }

  return 0;
}
Пример #2
0
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
  register_factories(orb);

  CORBA::Object_var objectman =
    orb->resolve_initial_references ("ORBPolicyManager");

  CORBA::PolicyManager_var policy_manager =
    CORBA::PolicyManager::_narrow (objectman.in ());

  PortableServer::POA_var my_compress_poa = 0;
  CORBA::PolicyList policies(4);
  policies.length(4);

  try
    {
      policies[0] = create_compressor_id_level_list_policy (orb);
      policies[1] = create_low_value_policy (orb);
      policies[2] = create_compression_enabled_policy (orb);
      policies[3] = create_min_ratio_policy (orb);

      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }
  catch(const CORBA::PolicyError&)
    {
      policies.length(0);
      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }

  policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  CORBA::Object_var pcobject =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (pcobject.in ());

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager ();

  Hello *hello_impl = 0;
  ACE_NEW_RETURN (hello_impl,
                  Hello (orb),
                  0);
  PortableServer::ServantBase_var owner_transfer(hello_impl);

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

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

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

  poa_manager->activate ();

  return hello._retn ();
}
Пример #3
0
int
test_timeout (CORBA::Object_ptr object)
{
  // Start the timer
  profile_timer.start ();

  try
    {
      // First connection happens here..
      Test::Hello_var hello =
        Test::Hello::_narrow(object);

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

      CORBA::String_var the_string =
        hello->get_string ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string.in ()));

      hello->shutdown ();
    }
  catch (const CORBA::Exception&)
    {
      // Stop the timer
      profile_timer.stop ();

      // Get the elampsed time
      ACE_Profile_Timer::ACE_Elapsed_Time el;
      profile_timer.elapsed_time (el);

      // Give a 30% error margin for handling exceptions etc. It is a
      // high margin, though!. But the timeout is too small and wider
      // range would help.
      // The elapsed time is in secs
      if (el.real_time > 0.200)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%P|%t) ERROR: Too long to timeout: %F\n",
                             el.real_time),
                             1);
        }
      else
        ACE_DEBUG ((LM_DEBUG,
                    "(%P|%t) Success, timeout: %F\n",
                    el.real_time));
    }

  return 0;
}
Пример #4
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;
}
Пример #5
0
int
Client_Task::svc (void)
{
  try
    {
      CORBA::Object_var tmp =
        this->corb_->string_to_object (input_);

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

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

      CORBA::String_var the_string =
        hello->get_string ();

      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) - string returned <%C>\n",
                  the_string.in ()));

      if (!this->result_)
        {
          // We would expect the call to fail, so we have an error now
          ACE_ERROR ((LM_ERROR, "(%P|%t) - ERROR: get_string should have failed\n"));
        }

      hello->shutdown ();
    }
  catch (const CORBA::TRANSIENT& ex)
    {
      if (!this->result_)
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - caught expected exception\n"));
          // When collocation has been disabled we expect a transient
          // with minor code 2
          return 0;
        }

      ex._tao_print_exception ("Caught exception:");
      return 1;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;

}
Пример #6
0
int
main (int argc, char *argv[])
{
	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,
					   " (%N|%l) Panic: nil RootPOA\n"),
					  1);

		PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

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

		Test::Hello_var hello =	hello_impl->_this ();

		//
		// Register the server object in the IOR table
		//

		// Turn the object reference into an IOR string
		CORBA::String_var ior_string = orb->object_to_string(hello.in());

		// Get a reference to the IOR Table and bind the hello object
		CORBA::Object_var table_obj = orb->resolve_initial_references("IORTable");
		IORTable::Table_var ior_table = IORTable::Table::_narrow(table_obj.in());
		ior_table->bind(::Test::Hello::IOR_TABLE_KEY, ior_string.in());

		poa_manager->activate ();

		ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop beginning\n"));

		orb->run ();

		ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop finished\n"));

		root_poa->destroy (1, 1);

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

	return 0;
}
Пример #7
0
int
Server_Task::svc (void)
{
    try
    {
        CORBA::Object_var poa_object =
            this->sorb_->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);

        PortableServer::POAManager_var poa_manager =
            root_poa->the_POAManager ();

        Hello *hello_impl = 0;
        ACE_NEW_RETURN (hello_impl,
                        Hello (this->sorb_.in (),
                               ACE_Thread::self ()),
                        1);

        PortableServer::ServantBase_var owner_transfer(hello_impl);

        Test::Hello_var hello =
            hello_impl->_this ();

        CosNaming::NamingContext_var example_nc;
        CosNaming::Name name;
        name.length(1);
        name[0].id = CORBA::string_dup("Hello");
        root_context_->rebind(name, hello.in());

        poa_manager->activate ();

        // Signal the main thread before we call orb->run ();
        this->me_.signal ();

        ACE_Time_Value runtime (10);
        this->sorb_->run (runtime);

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception caught:");
        return 1;
    }

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

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

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

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

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

      try
        {

          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - calling get_string\n"));
          CORBA::String_var the_string = hello->get_string ();
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                      the_string.in ()));
          ACE_OS::sleep (1);
          hello->shutdown ();
        }
      catch (const CORBA::TRANSIENT& )
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - caught expected transient\n"));
          result = 1;
        }
      catch (const CORBA::COMM_FAILURE& )
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - caught expected comm failure\n"));
        }

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

  return result;
}
Пример #9
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  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);

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

      Test::Hello_var hello = prepare_tests (orb.in (), root_poa.in ());

      CORBA::String_var ior = orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

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

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

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

      Test::Hello_var hello = prepare_tests (orb.in ());

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

      try
        {
          result += start_tests(hello.in (), orb.in ());
        }
      catch (const CORBA::Exception& ex)
        {
          ex._tao_print_exception ("Exception caught:");
          ++result;
        }

      if (test == 2)
        {
          ACE_DEBUG((LM_DEBUG,
                     ACE_TEXT("*** NOTE TestCompressor is EXPECTED to throw IDL:omg.org/Compression/CompressionException ***\n")));
        }

      hello->shutdown ();

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

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

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

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

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

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

        if (oneway_call)
        {
            CORBA::String_var the_string = CORBA::string_dup( "Test" );
            ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Client sending string <%C> oneway\n",
                        the_string.in ()));
            hello->set_string (the_string);
        }
        else
        {
            CORBA::String_var the_string = hello->get_string ();
            ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Client getting string <%C>\n",
                        the_string.in ()));
        }

        hello->shutdown ();

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

    return 0;
}
Пример #12
0
int
Client_Task::svc (void)
{
  CORBA::Boolean exception = false;
  try
    {
      CORBA::Object_var tmp =
        this->corb_->string_to_object (input_);

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

      if (CORBA::is_nil (hello.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil Test::Hello reference <%s>\n",
                             input_),
                             1);
        }
      try
        {
          CORBA::String_var the_string =
            hello->get_string ();

          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                      the_string.in ()));

          hello->shutdown ();
        }
      catch (CORBA::INTERNAL)
        {
          exception = true;
          ACE_DEBUG ((LM_DEBUG, "OK: Client_Task Expected exception received\n"));
          corb_->destroy ();
          return 0;
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }
  if (!exception)
    {
      ACE_ERROR ((LM_ERROR, "(ERROR: Client_Task::svc Expected exception not received\n"));
    }
  return 0;
}
Пример #13
0
void
shutdown_handler (void)
{
	if (!CORBA::is_nil(mapper.in()))
		mapper->remove_server(mapped_hello.in());
	orb->shutdown();
}
Пример #14
0
Test::Hello_var
create_policies (CORBA::ORB_ptr orb, bool add_zlib_compressor)
{
  CORBA::PolicyList policies(4);
  policies.length(4);

  policies[0] = create_compressor_id_level_list_policy (orb, add_zlib_compressor);
  policies[1] = create_low_value_policy (orb);
  policies[2] = create_compression_enabled_policy (orb);
  policies[3] = create_min_ratio_policy (orb);

  CORBA::Object_var tmp = orb->string_to_object(ior);
  CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
  Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ());
  return hello._retn ();
}
Пример #15
0
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, bool create_factories=true)
{
#if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1
  if (create_factories)
    {
      register_factories(orb);
    }

  return create_policies (orb, !create_factories);
#else
  ACE_UNUSED_ARG (create_factories);
  CORBA::Object_var tmp = orb->string_to_object(ior);
  Test::Hello_var hello = Test::Hello::_narrow(tmp.in ());
  return hello._retn ();
#endif
}
Пример #16
0
  virtual int handle_timeout(const ACE_Time_Value &, const void *)
  {
    --iterationsLeft;

    try
      {
        ACE_DEBUG ((LM_DEBUG,
                    "\n(%P|%t) - handling timeout with %d iterations left\n",
                    iterationsLeft + 1));
        CORBA::Object_var tmp = orb->string_to_object(ior);

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

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

        CORBA::String_var the_string = hello->get_string ();

        ++successfulConnections;
        ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                    the_string.in ()));
        ACE_OS::sleep(2);
        hello->shutdown ();

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) - shutdown requested\n"));
      }
    catch (const CORBA::Exception& ex)
      {
        ex._tao_print_exception ("Exception caught:");
        process_result = 1;
        orb->shutdown();
      }

    if(successfulConnections == 2)
      {
        process_result = 0;
        orb->shutdown();
      }

    return 0;
  }
Пример #17
0
int
Client_Task::svc (void)
{
  int status = 1;
  try
    {
      CORBA::Object_var tmp =
        this->corb_->string_to_object (input_);

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

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

      CORBA::String_var the_string =
        hello->get_string ();

      if (ACE_OS::strcmp (the_string.in (), "Hello there!") != 0)
        {
          ACE_ERROR ((LM_ERROR, "(%P|%t) - Error, incorrect string returned <%C>\n",
                      the_string.in ()));
          status = 1;
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                      the_string.in ()));
        }

      hello->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      status = 1;
    }

  return status;

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

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

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

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

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

      Test::Fls_var fstruct;
      Test::Vls_var vstruct;

      ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - op test 1\n"));
      hello->op(fstruct.out(), vstruct.out());

      ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - op test 2\n"));
      hello->op(fstruct, vstruct.out());

      hello->shutdown ();

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

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

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

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

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

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

      CORBA::String_var A = CORBA::string_dup ("DKWC");
      CORBA::String_var B = CORBA::string_dup ("kwc");
      CORBA::String_var C = CORBA::string_dup ("MV-files");
      CORBA::String_var the_string =
        hello->get_string (A.in (), B.in (), C.in ());

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string.in ()));

      hello->shutdown ();

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

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

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

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

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

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

      CORBA::StringSeq my_seq (1);
      my_seq.length (1);

      hello->get_string (my_seq[0].out ());

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  my_seq[0].in ()));

      hello->shutdown ();

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

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

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

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

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

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

      hello->shutdown ();

      ACE_Time_Value duration(20, 0);
      orb->run(duration);
      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
Пример #22
0
int
Client_Task::svc (void)
{
  try
    {
      CORBA::Object_var tmp =
        this->corb_->string_to_object (input_);

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

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

      CORBA::String_var the_string =
        hello->get_string ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string.in ()));

      hello->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;

}
Пример #23
0
int
Client_Worker::test_main (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        ACE_ERROR_RETURN ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) Could not parse the arguments\n")),
                          1);

      // Doing this dance to allow the server some time to come up.
      CORBA::Object_ptr co = 0;
      for (int attempts_left = 5; attempts_left > 0; --attempts_left)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) Client is ready to proceed - awaiting the server ...\n")));
          ACE_OS::sleep (1);

          try
            {
              co = orb->string_to_object (ior_file_.c_str ());

              if (co == 0)
                {
                  ACE_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) Unable to obtain object reference yet. Retrying.\n")));
                  continue;
                }
              CORBA::Object_var tmp (co);

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

              if (CORBA::is_nil (hello.in ()))
                {
                  ACE_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) Nil Test::Hello reference <%s>. Retrying.\n"),
                              ior_file_.c_str ()));
                  continue;
                }

              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) Successfuly narrowed the Hello interface\n")));

              CORBA::String_var the_string =
                hello->get_string ();

              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) String returned from the server <%C>\n"),
                          the_string.in ()));

              hello->shutdown ();

              attempts_left = 0; // We're done here!

            }
          catch (const CORBA::TRANSIENT& ex)
            {
              if (!attempts_left)
                throw;

              ex._tao_print_exception ("Temporary problem encountered");

              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) Client was too quick. Pausing ")
                          ACE_TEXT ("while the server gets ready.\n")));
              ACE_OS::sleep (5);
            }
          catch (const CORBA::Exception& ex)
            {
              ex._tao_print_exception("Unexpected CORBA exception caught");

              if (!attempts_left)
                throw;

              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) Pausing for a while.\n")));
              ACE_OS::sleep (5);
            }
      }

      orb->shutdown (0);

      orb->destroy ();
    }
  catch (const ::CORBA::Exception &e)
    {
      e._tao_print_exception("Client_Worker::test_main");
      return 1;
    }

  return 0;
}
Пример #24
0
int
check_results (CORBA::ORB_ptr orb)
{
#if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1
  switch (test)
    {
    case 1:
      try
        {
          // should throw an exception
          ::Compression::Compressor_var compressor (
            compression_manager->get_compressor (
              ::Compression::COMPRESSORID_LZO,
              LEAST_COMPRESSION_LEVEL ));
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("ERROR : check_results, ")
                             ACE_TEXT ("no exception thrown when applying for ")
                             ACE_TEXT ("LZO Compressor\n")),
                            1);
        }
      catch (::Compression::UnknownCompressorId)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("check_results, expected exception caught, ")
                      ACE_TEXT ("(unknown factory)\n")));
          Test::Hello_var hello = prepare_tests (orb, false);
          test = -1;
          return start_tests (hello.in (), orb);
        }
      break;
    case 4:
    case -1:
      {
        ::Compression::Compressor_var compressor (
          compression_manager->get_compressor (
            ::Compression::COMPRESSORID_ZLIB,
            LEAST_COMPRESSION_LEVEL ));
        if (!CORBA::is_nil (compressor))
          {
            if (compressor->compressed_bytes () == 0)
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("ERROR : check_results, no compression used ")
                                 ACE_TEXT ("during test 1a\n")),
                                1);
            else
               return 0;
          }
        else
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("ERROR : check_results, zlib compressor not found ")
                               ACE_TEXT ("during test 1a\n")),
                              1);
          }
      }
      break;
    case 2:
      return 0;
      break;
    case 3:
      {
        // low value policy test. No compression should be used.
        ::Compression::Compressor_var compressor (
        compression_manager->get_compressor (
          ::Compression::COMPRESSORID_ZLIB,
          LEAST_COMPRESSION_LEVEL ));
        if (!CORBA::is_nil (compressor))
          {
            if (compressor->compressed_bytes () != 0)
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("ERROR : check_results, compression used ")
                                 ACE_TEXT ("during test %d\n"), test),
                                1);
            else
              return 0;
          }
        else
          {
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("ERROR : check_results, zlib compressor not found ")
                               ACE_TEXT ("during test %d\n"), test),
                              1);
          }
      }
      break;
    default:
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ERROR : check_results, unknown test ID\n")),
                        1);
    }
  ACE_ERROR_RETURN ((LM_ERROR,
                     ACE_TEXT ("ERROR : check_results, unexpected\n")),
                    1);
#else
  ACE_UNUSED_ARG (orb);
  return 0;
#endif
}
Пример #25
0
int
Server_Task::svc (void)
{
 try
   {
     CORBA::Object_var poa_object =
       this->sorb_->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);

     PortableServer::POAManager_var poa_manager =
       root_poa->the_POAManager ();

     Hello *hello_impl;
     ACE_NEW_RETURN (hello_impl,
                     Hello (this->sorb_.in (),
                            ACE_Thread::self ()),
                     1);

     PortableServer::ServantBase_var owner_transfer(hello_impl);

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

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

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

     CORBA::String_var ior =
       this->sorb_->object_to_string (hello.in ());

     // Output the IOR to the <this->output_>
     FILE *output_file= ACE_OS::fopen (this->output_,
                                       "w");
     if (output_file == 0)
       ACE_ERROR_RETURN ((LM_ERROR,
                          "Cannot open output file for writing IOR: %s",
                          this->output_),
                         1);

     ACE_OS::fprintf (output_file, "%s", ior.in ());
     ACE_OS::fclose (output_file);

     poa_manager->activate ();

     // Signal the main thread before we call orb->run ();
     this->me_.signal ();

     this->sorb_->run ();

     ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

     root_poa->destroy (1, 1);

     this->sorb_->destroy ();
   }
 catch (const CORBA::Exception& ex)
   {
     ex._tao_print_exception ("Exception caught:");
     return 1;
   }

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


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

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


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


      if (CORBA::is_nil (hello.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n",
                             ior),
                            1);
        }

      // Check this isn't generating transients for any other reason
      hello->ping ();

      try
        {
          hello->throw_location_forward ();


          ACE_DEBUG ((LM_ERROR, "REGRESSION - Test has failed !!!\n"));
          result = 1;
        }
      catch (CORBA::TRANSIENT my_ex)
        {
          ACE_UNUSED_ARG (my_ex);
          ACE_DEBUG ((LM_DEBUG, "Client catches a TRANSIENT, as expected. No problem !\n"));
        }


      hello->shutdown ();


      orb->destroy ();

    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
                           "Test failed (Not regression) because unexpected exception caught:");
      return 1;
    }


  if (result)
    {
      ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n"));
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n"));
    }
  return result;
}
Пример #27
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
	for(int i = 2; i < 10; i++)
	{
         for(int j = 2; j < i; j++)
			 if(i%j == 0) break;
		 if(j > i)
			 printf("%2d", i);
	}
	
  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);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

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

      Test_Hello_Impl *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Test_Hello_Impl (),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

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

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

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

      CORBA::String_var ior = orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

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

  return 0;
}
Пример #28
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int idle_count = 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);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

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

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

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

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

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

      CORBA::String_var ior = orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      for (;;)
      {
        ACE_Time_Value tv (0, 500);
        while (orb->work_pending (tv))
          {
            ACE_DEBUG ((LM_DEBUG, "Work pending\n"));
            ACE_Time_Value tv2 (0, 500);
            if (orb->work_pending (tv2))
              {
                ACE_Time_Value work_tv (0, 500);
                orb->perform_work (work_tv);
              }
          }
        ++idle_count;
      }

      orb->destroy ();
    }
  catch (const CORBA::BAD_INV_ORDER&)
    {
      // Expected
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  if (idle_count == 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Got unexpected idle_count %d\n", idle_count), 1);
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, "Got %d idle moments\n", idle_count));
    }

  return 0;
}
Пример #29
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int retval = 0;

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

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

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

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

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

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      poa_manager->activate ();


      // Let the client perform the test in a separate thread


      Client_Task client (hello.in (),
                          orb.in (),
                          ACE_Thread_Manager::instance ());

      if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0)
      {
        ACE_ERROR_RETURN ((LM_ERROR,
                              "ERROR - Cannot activate client threads\n"),
            1);
      }


      ACE_Time_Value thread_deadline = ACE_OS::gettimeofday();
      thread_deadline += 30;

      if(client.thr_mgr ()->wait (&thread_deadline) == -1)
      {
        ACE_ERROR((LM_ERROR,
                             "ERROR - Timeout waiting for client threads\n"));

        retval = 1;
      }

      root_poa->destroy (1,  // ethernalize objects
                         0  // wait for completion
                        );

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

  return retval;
}
Пример #30
0
int
main (int argc, char *argv[])
{
	try
	{
		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);

		PortableServer::POAManager_var poa_manager =
			root_poa->the_POAManager ();

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

		CORBA::PolicyList policies(2);
    policies.length(2);
		policies[0] = 
			root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
		policies[1] = 
			root_poa->create_id_assignment_policy(PortableServer::USER_ID);

		PortableServer::POA_var child_poa = 
			root_poa->create_POA ("persistent", poa_manager.in(), policies);

		poa_manager->activate();

		PortableServer::ServantBase_var servant (new Hello);

		PortableServer::ObjectId_var oid = 
			PortableServer::string_to_ObjectId ("gctest");
    child_poa->activate_object_with_id (oid.in(), servant.in() );
		CORBA::Object_var obj = child_poa->id_to_reference (oid.in());
		Test::Hello_var hello = Test::Hello::_narrow (obj.in());

		if (!no_register) 
			{
				obj = orb->string_to_object (lorica_ior);

				mapper = Lorica::ReferenceMapper::_narrow(obj.in());
				if (CORBA::is_nil(mapper.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot get reference to Lorica "
														 "reference mapper\n"),1);

				obj = mapper->as_server(hello.in(),"Hello",
																Lorica::ServerAgent::_nil());

				if (CORBA::is_nil (obj.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned a nil "
														 "mapped reference.\n"),1);
				mapped_hello = Test::Hello::_narrow(obj.in());
				if (CORBA::is_nil(mapped_hello.in()))
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned an "
														 "incorrectly typed reference\n"),1);

				CORBA::String_var orig_ior =
					orb->object_to_string (hello.in ());
				CORBA::String_var mapped_ior =
					orb->object_to_string (mapped_hello.in());

				if (ACE_OS::strcmp (orig_ior.in(), mapped_ior.in()) == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Lorica reference mapper returned "
														 "the original reference unmapped.\n"),1);

				ACE_DEBUG ((LM_DEBUG,"writing original IOR to file %s\n",orig_file));
				ACE_DEBUG ((LM_DEBUG,"writing mapped IOR to file %s\n",mapped_file));
				ACE_DEBUG ((LM_DEBUG,"Size of orig IOR = %d, size of mapped = %d\n",
										ACE_OS::strlen(orig_ior.in()),
										ACE_OS::strlen(mapped_ior.in())));

				FILE *output_file= ACE_OS::fopen (mapped_file, "w");
				if (output_file == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot open output file for writing IOR: %s\n",
														 mapped_file),
														1);
				ACE_OS::fprintf (output_file, "%s", mapped_ior.in());
				ACE_OS::fclose (output_file);
		
				output_file= ACE_OS::fopen (orig_file, "w");
				if (output_file == 0)
					ACE_ERROR_RETURN ((LM_ERROR,
														 "Cannot open output file for writing IOR: %s\n",
														 orig_file),
														1);
				ACE_OS::fprintf (output_file, "%s", orig_ior.in());
				ACE_OS::fclose (output_file);
			}

		ACE_Time_Value delay(8,0); // run for 8 seconds, which gets past 1 gc 
                               // iterateion and gives client time for 2
		                           // string gets.
		orb->run(delay);

		// No need to run the ORB the test only requires modifying an IOR
		orb->destroy ();
	}
	catch (const CORBA::Exception& ex)
	{
		ex._tao_print_exception ("Exception caught:");
		return 1;
	}

	return 0;
}