Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Bug_1254_Regression / client.cpp
blob8f87a04bac8d985db32374bb34251c9696a2944d
1 #include "testC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
33 int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
35 try
37 CORBA::ORB_var orb =
38 CORBA::ORB_init (argc, argv);
40 if (parse_args (argc, argv) != 0)
41 return 1;
43 CORBA::Object_var tmp =
44 orb->string_to_object (ior);
46 BlobServer_var blobServer = BlobServer::_narrow(tmp.in());
47 if(CORBA::is_nil(blobServer.in()))
49 ACE_ERROR_RETURN ((LM_DEBUG,
50 "Nil Test::Hello reference <%s>\n",
51 ior),
52 1);
55 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - test\n"));
57 BlobType1 blob1;
59 blob1.length(16384);
60 for(CORBA::ULong i = 0; i < blob1.length(); i++)
62 blob1[i] = i & 255;
65 BlobType2 blob2;
67 blobServer->test(blob1, blob2);
69 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - checking reply for ABCDEFGHIJ\n"));
71 for(CORBA::ULong i = 0; i < blob1.length(); i++)
73 if (blob1[i] != static_cast <CORBA::Octet> ('A' + i))
75 ACE_ERROR ((LM_ERROR,
76 "Error invalid value detected on position <%d> in blob1\n",
77 i));
81 for(CORBA::ULong i = 0; i < blob2.length(); i++)
83 if (blob2[i] != static_cast <CORBA::Octet> ('A' + i))
85 ACE_ERROR ((LM_ERROR,
86 "Error invalid value detected on position <%d> in blob2\n",
87 i));
91 ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - shutdown\n"));
93 blobServer->shutdown ();
95 orb->destroy ();
97 catch (const CORBA::Exception& ex)
99 ex._tao_print_exception ("Exception caught:");
100 return 1;
103 return 0;