Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Smart_Proxies / dtor / client.cpp
blobcd5d62b9c3ae32179974ae244ae17ae26c3caca7
1 #include "ace/OS_NS_string.h"
2 #include "ace/OS_NS_unistd.h"
3 #include "ace/Get_Opt.h"
4 #include "testC.h"
5 #include "Smart_Proxy_Impl.h"
7 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
8 bool dtor_called;
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("i:"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'i':
20 ior = get_opts.opt_arg ();
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-i "
27 "\n",
28 argv [0]),
29 -1);
31 return 0;
34 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
36 try
38 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
40 if (parse_args (argc, argv) != 0)
41 return 1;
43 CORBA::Object_var obj = orb->string_to_object (ior);
45 // force a scope to see the destruction of the server object
47 Test_Smart_Factory *test_factory = 0;
48 ACE_NEW_RETURN (test_factory,
49 Test_Smart_Factory,
50 -1);
52 ACE_UNUSED_ARG (test_factory);
54 Test_var server =
55 Test::_narrow(obj.in());
57 if (CORBA::is_nil (server.in())) {
58 ACE_ERROR_RETURN ((LM_ERROR,
59 "Object reference <%s> is nil.\n",
60 ior),
61 1);
64 server->hello(3);
66 #if (TAO_HAS_MINIMUM_CORBA == 0)
67 // Testing the _non_existent function
68 ACE_DEBUG ((LM_DEBUG, "Testing _non_existent()\n"));
69 CORBA::Boolean ne =
70 server->_non_existent();
71 if (ne)
72 ACE_ERROR_RETURN ((LM_ERROR,
73 "Not a Messenger object reference\n"),
74 1);
75 else
76 ACE_DEBUG ((LM_DEBUG,"Successfully called _non_existent()\n"));
77 #endif /* TAO_HAS_MINIMUM_CORBA */
79 server->shutdown();
81 // The following sleep is a hack to make sure the above oneway
82 // request gets sent before we exit. Otherwise, at least on
83 // Windows XP, the server may not even get the request.
84 ACE_Time_Value tv (0, 100000);
85 ACE_OS::sleep(tv);
87 // here we should get the smart proxy destructor printout
88 if (!dtor_called) {
89 ACE_ERROR_RETURN((LM_ERROR,
90 "The Smart proxy is not deleted\n"),1);
93 orb->destroy();
95 catch (const CORBA::Exception& ex)
97 ex._tao_print_exception ("Client-side exception:");
98 return 1;
101 return 0;