Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / AMH_Exceptions / client.cpp
blobf76ad5091404013d1422f59faeec5db2f09f57de
1 // -*- C++ -*-
2 #include "TestC.h"
3 #include "ace/Get_Opt.h"
5 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'k':
17 ior = get_opts.opt_arg ();
18 break;
20 case '?':
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 "usage: %s "
24 "-k <ior> "
25 "\n",
26 argv [0]),
27 -1);
29 // Indicates successful parsing of the command line
30 return 0;
34 int
35 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
37 int received_expected_exception = 0;
38 try
40 CORBA::ORB_var orb =
41 CORBA::ORB_init (argc, argv);
43 if (parse_args (argc, argv) != 0)
44 return 1;
46 CORBA::Object_var object =
47 orb->string_to_object (ior);
49 Test::Roundtrip_var roundtrip =
50 Test::Roundtrip::_narrow (object.in ());
52 if (CORBA::is_nil (roundtrip.in ()))
54 ACE_ERROR_RETURN ((LM_ERROR,
55 "Nil Test::Roundtrip reference <%s>\n",
56 ior),
57 1);
60 try{
61 Test::Timestamp time = 10;
62 roundtrip->test_method (time);
64 catch (const Test::ServerOverload& )
66 ACE_DEBUG ((LM_DEBUG, "Received expected exception\n"));
67 received_expected_exception = 1;
69 roundtrip->shutdown ();
72 orb->destroy ();
74 catch (const CORBA::Exception& ex)
76 ex._tao_print_exception ("");
77 return 1;
80 if(!received_expected_exception)
82 ACE_ERROR_RETURN ((LM_ERROR,
83 "ERROR, expecting a ServerOverload exception!!\n"),
84 1);
87 return 0;