Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Bug_2494_Regression / client.cpp
blobf5c8e4f1fee830c087521b251d941e2013fa2603
1 #include "ace/Get_Opt.h"
2 #include "ace/Task.h"
3 #include "ace/OS_NS_string.h"
4 #include "testC.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int nthreads = 5;
8 int do_shutdown = 0;
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xk:n:"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'x':
20 do_shutdown = 1;
21 break;
23 case 'k':
24 ior = get_opts.opt_arg ();
25 break;
27 case 'n':
28 nthreads = ACE_OS::atoi (get_opts.opt_arg ());
29 break;
31 case '?':
32 default:
33 ACE_ERROR_RETURN ((LM_ERROR,
34 "usage: %s "
35 "-k <ior> "
36 "[-n <nthreads> | -x]"
37 "\n",
38 argv [0]),
39 -1);
41 // Indicates successful parsing of the command line
42 return 0;
45 namespace
47 const char *twohundredbytes =
48 "12345678901234567890123456789012345678901234567890"
49 "12345678901234567890123456789012345678901234567890"
50 "12345678901234567890123456789012345678901234567890"
51 "12345678901234567890123456789012345678901234567890"
55 struct Worker : ACE_Task_Base
57 Worker (Simple_Server_ptr srv)
58 : srv_(Simple_Server::_duplicate(srv))
62 Simple_Server_var srv_;
64 int svc ()
66 CORBA::String_var str = CORBA::string_alloc (200*2000 + 1);
67 if (str.in () == 0) return 1;
68 str.inout ()[0] = CORBA::Char ('\0');
69 for (int i=0; i < 2000; ++i)
71 ACE_OS::strcat (str.inout (), twohundredbytes);
74 while (1)
76 try
78 CORBA::String_var ret = srv_->test_method (str.in ());
79 if (0 != ACE_OS::strcmp (str.in (), ret.in ())) return 1;
81 catch (const CORBA::Exception& ex)
83 ACE_DEBUG ((LM_ERROR,
84 ACE_TEXT ("(%P|%t) Exception caught: \n%C\n"),
85 ex._info ().c_str ()));
86 return 1;
89 return 0;
93 int
94 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
96 try
98 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
100 if (parse_args (argc, argv) != 0)
101 return 1;
103 CORBA::Object_var object = orb->string_to_object (ior);
105 Simple_Server_var server = Simple_Server::_narrow (object.in ());
107 if (CORBA::is_nil (server.in ()))
109 ACE_ERROR_RETURN ((LM_ERROR,
110 "Object reference <%s> is nil.\n",
111 ior), 1);
114 if (do_shutdown)
116 server->shutdown ();
118 else
120 Worker wrk (server.in ());
121 wrk.activate (THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, nthreads);
122 wrk.thr_mgr ()->wait ();
125 catch (const CORBA::Exception& ex)
127 ACE_DEBUG ((LM_ERROR, ACE_TEXT ("(%P|%t) ERROR: Exception caught: \n%C\n"),
128 ex._info ().c_str ()));
129 return 1;
132 return 0;