예제 #1
0
파일: client.cpp 프로젝트: OspreyHub/ATCD
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
파일: client.cpp 프로젝트: OspreyHub/ATCD
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;
}
예제 #3
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;

}
예제 #4
0
파일: client.cpp 프로젝트: OspreyHub/ATCD
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;
}
예제 #5
0
파일: client.cpp 프로젝트: manut/TAO
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;
}
예제 #6
0
파일: client.cpp 프로젝트: asdlei00/ACE
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;
}
예제 #7
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;
}
예제 #8
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;
}
예제 #9
0
파일: client.cpp 프로젝트: OspreyHub/ATCD
  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;
  }
예제 #10
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;

}
예제 #11
0
파일: client.cpp 프로젝트: asdlei00/ACE
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;
}
예제 #12
0
파일: client.cpp 프로젝트: asdlei00/ACE
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;
}
예제 #13
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 ()));

      this->test_system_exception (hello.in ());

      this->test_user_exception_expected (hello.in ());

      this->test_user_exception_not_expected (hello.in ());

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

  return 0;

}
예제 #14
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;
}
예제 #15
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      orb = CORBA::ORB_init (argc, argv);
      CORBA::Object_var object =
        orb->resolve_initial_references ("RTORB");

      RTCORBA::RTORB_var rt_orb =
        RTCORBA::RTORB::_narrow (object.in ());

      // Set the tcp protocol properties
      RTCORBA::TCPProtocolProperties_var tcp_properties =
        rt_orb->create_tcp_protocol_properties (ACE_DEFAULT_MAX_SOCKET_BUFSIZ,
                                                ACE_DEFAULT_MAX_SOCKET_BUFSIZ,
                                                1, 0, 1, 0);
      RTCORBA::ProtocolList protocols;
      protocols.length (1);
      protocols[0].protocol_type = 0;
      protocols[0].transport_protocol_properties =
        RTCORBA::ProtocolProperties::_duplicate (tcp_properties.in ());
      protocols[0].orb_protocol_properties =
        RTCORBA::ProtocolProperties::_nil ();

      CORBA::PolicyList policy_list;

      policy_list.length (1);
      policy_list[0] =
        rt_orb->create_client_protocol_policy (protocols);
      object = orb->resolve_initial_references ("ORBPolicyManager");

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

      policy_manager->set_policy_overrides (policy_list,
                                            CORBA::SET_OVERRIDE);

      // start the failsafe thread. It will expire in 10 seconds and
      // terminate with a failure if the following does not complete.

      ACE_Thread::spawn (failsafe);

      object = orb->string_to_object ("corbaloc::localhost:5678/Test");
      Test::Hello_var hello = Test::Hello::_narrow(object.in());

      is_ok = true;
      test_lock.acquire ();
      cond.signal();
      test_lock.release ();
      ACE_DEBUG ((LM_DEBUG, "SUCCESS: test did not spin.\n"));

      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)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
예제 #16
0
파일: client.cpp 프로젝트: asdlei00/ACE
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;
}
예제 #17
0
파일: client.cpp 프로젝트: asdlei00/ACE
int
ACE_TMAIN (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_ERROR,
                           ACE_TEXT ("ERROR: wrong arguments\n")),
                          -1);

      if (id_offset + client_threads >= ACE_OS::strlen (Test::ClientIDs))
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("ERROR: too many clients\n")),
                          -1);

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

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

      if (CORBA::is_nil (hello.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("ERROR: nil Hello object\n")),
                          -1);

      if (do_shutdown)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("\nClient sending server shutdown message....\n")));
          ACE_OS::sleep (7);
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("Shutting down NOW\n")));
          hello->shutdown ();
        }
      else
        {
          Test::UIPMC_Object_var uipmc_obj = hello->get_object ();

          {
            // start clients
            ClientThread cln_thr (uipmc_obj.in (), payload_length,
                                  id_offset, payload_calls, sleep_millis);
            cln_thr.activate (THR_NEW_LWP | THR_JOINABLE, client_threads);
            cln_thr.wait ();
          }

          // Give a chance to flush all OS buffers for client.
          while (orb->work_pending ())
            orb->perform_work ();
        }

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

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("\nClient finished successfully.\n")));
  return 0;
}
예제 #18
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      ACE_Get_Opt opts (argc, argv, ACE_TEXT ("s:c:"));
      const ACE_TCHAR *server = 0, *client = 0;
      for (int o; (o = opts ()) != -1;)
        {
          switch (o)
            {
            case 's':
              server = opts.opt_arg ();
              break;
            case 'c':
              client = opts.opt_arg ();
              break;
            }
        }

      Servant srv (orb);
      ORBTask task (orb);

      if (server)
        {
          CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
          PortableServer::POA_var poa = PortableServer::POA::_narrow (obj);
          PortableServer::POAManager_var pm = poa->the_POAManager ();
          pm->activate ();
          Test::Hello_var srv_obj = srv._this ();
          CORBA::String_var srv_str = orb->object_to_string (srv_obj);
          FILE *f = ACE_OS::fopen (server, "w");
          ACE_OS::fputs (srv_str, f);
          ACE_OS::fclose (f);
          if (!client)
            task.activate();
        }

      if (client)
        {
          ACE_CString ior ("file://");
          ior += ACE_TEXT_ALWAYS_CHAR (client);
          CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
          Test::Hello_var hello = Test::Hello::_narrow (obj);
          CORBA::String_var str = hello->get_string ();
          ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) - returned <%C>\n"),
                      str.in ()));
          hello->shutdown ();
        }
      else if (server)
        {
          task.wait ();
        }

      orb->destroy ();
      return 0;
    }
  catch (const CORBA::Exception &e)
    {
      e._tao_print_exception ("Exception caught:");
    }
  catch (...)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception ")
                            ACE_TEXT ("caught in main\n")));
    }
  return 1;
}
예제 #19
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;
}
예제 #20
0
파일: client.cpp 프로젝트: CCJY/ATCD
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 2;

      // create UIPMC reference
      CORBA::Object_var miop_ref =
        orb->string_to_object (ior_file);

      // create Hello reference
      Test::Hello_var hello =
        Test::Hello::_unchecked_narrow (miop_ref.in ());

      if (CORBA::is_nil (hello.in ()))
        return 5;

      TAO::DiffservCodepoint request_dscp = dscp[12];
      TAO::DiffservCodepoint reply_dscp = dscp[13];

      CORBA::PolicyList policy_list;
      policy_list.length (1);

      CORBA::Policy_var client_network_policy =
        orb->_create_policy (TAO::CLIENT_NETWORK_PRIORITY_TYPE);

      TAO::NetworkPriorityPolicy_var nw_priority =
        TAO::NetworkPriorityPolicy::_narrow (client_network_policy.in ());

      nw_priority->request_diffserv_codepoint (
           request_dscp);

      nw_priority->reply_diffserv_codepoint (
           reply_dscp);

      nw_priority->network_priority_model (
        TAO::CLIENT_PROPAGATED_NETWORK_PRIORITY);

      policy_list[0] = TAO::NetworkPriorityPolicy::_duplicate (nw_priority.in ());

      CORBA::Object_var over_ridden_object = hello->_set_policy_overrides (
         policy_list, CORBA::SET_OVERRIDE);

      policy_list[0]->destroy ();

      hello = Test::Hello::_unchecked_narrow (over_ridden_object.in ());

      {
        // start clients
        ClientThread cln_thr (hello.in (), HELLO_CALL_NUMBER);
        cln_thr.activate (THR_NEW_LWP | THR_JOINABLE, CLIENT_THREAD_NUMBER);
        cln_thr.wait ();
      }

      // shutdown the server, after 10 invocations of shutdown() we can be
      // more or less sure that server actually received that call
      for (int i = 0; i < 10; i++)
        hello->shutdown ();

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

  ACE_DEBUG ((LM_DEBUG,
              "\n (%P|%t) client finished successfully..\n"));
  return 0;
}
예제 #21
0
파일: client.cpp 프로젝트: CCJY/ATCD
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;

      // First perform the test with an IOR
      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 exceptions for any other reason
      hello->ping ();

      if (hello->has_ft_request_service_context ())
        {
          ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on a plain IOR has a FT_REQUEST service context.\n" ));
          result = 1;
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG, "Request made on a plain IOR has no FT_REQUEST service context. This is OK.\n" ));
        }

      // Now repeat the test (for the converse result) with an IOGR
      tmp =
        orb->string_to_object(iogr);

      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",
                             iogr),
                            1);
        }

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

      if (! hello->has_ft_request_service_context ())
        {
          ACE_DEBUG ((LM_ERROR, "ERROR - REGRESSION - Request made on an IOGR has no FT_REQUEST service context.\n" ));
          result = 1;
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG, "Request made on an IOGR has a FT_REQUEST service context. This is OK.\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;
}
예제 #22
0
파일: client.cpp 프로젝트: asdlei00/ACE
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);

      // No remote calls, first request flag is on.
      if (!first_request_flag (tmp.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "Test FAILED at the beginning (why?)\n"));
        }

      // This call must issue LocateRequest message.
      CORBA::PolicyList_var pl;
      tmp->_validate_connection (pl.out ());

      // There was a LocateRequest call, first request flag
      // must be still on.
      if (!first_request_flag (tmp.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "Test FAILED after LocateRequest (bug#3676 is not fixed)!!\n"));
        }

      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 ();

      // Either _narrow or get_string issued a remote call,
      // first request flag is off.
      if (first_request_flag (tmp.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "Test FAILED after normal request (why?)\n"));
        }

      hello->shutdown ();

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

  return 0;
}
예제 #23
0
파일: client.cpp 프로젝트: CCJY/ATCD
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("corbaloc:iiop:1.2@localhost:9931/NameService");

      CosNaming::NamingContext_var root =
        CosNaming::NamingContext::_narrow(tmp.in());

      if (CORBA::is_nil (root.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil NamingService reference\n"),
                            1);
        }

      ACE_DEBUG ((LM_INFO, "**** Narrowed root NamingContext\n"));

      CosNaming::Name name;
      name.length(2);
      name[0].id = CORBA::string_dup("example");
      name[1].id = CORBA::string_dup("Hello");

      try
        {
          tmp = root->resolve (name);
          ACE_DEBUG ((LM_INFO, "**** Resolved #example/Hello\n"));

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

          if (CORBA::is_nil (hello.in ()))
            {
              ACE_ERROR_RETURN ((LM_DEBUG,
                                 "Nil Test::Hello reference\n"),
                                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 CosNaming::NamingContext::CannotProceed&)
        {
          ACE_DEBUG ((LM_DEBUG, "Caught correct exception\n"));
        }

      if (shutdown_nsmain)
        {
          CORBA::Object_var shutdowntmp = orb->string_to_object(ior);

          Test::NsShutdown_var shutdown =
            Test::NsShutdown::_narrow(shutdowntmp.in ());

          ACE_DEBUG ((LM_DEBUG, "Shutdown nsmain\n"));
          shutdown->shutdown ();
        }

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

  return 0;
}