Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Bug_3826_Regression / server.cpp
blobefb2cee071b0ad33d4648a9b6241a9b270f998ba
1 #include "ace/Get_Opt.h"
2 #include "ace/ARGV.h"
3 #include "tao/ORB.h"
4 #include "tao/ORB_Core.h"
5 #include "tao/Resource_Factory.h"
7 ACE_TCHAR const *orb1_args =
8 ACE_TEXT ("AAA -ORBGestalt LOCAL -ORBSvcConf MY_TEST_ORB_1.conf");
9 ACE_TCHAR const *orb2_args =
10 ACE_TEXT ("BBB");
11 int expected_value = 0;
13 int
14 parse_args (int argc, ACE_TCHAR *argv[])
16 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("a:b:e:"));
17 int c;
19 while ((c = get_opts ()) != -1)
20 switch (c)
22 case 'a':
23 orb1_args = get_opts.opt_arg ();
24 break;
25 case 'b':
26 orb2_args = get_opts.opt_arg ();
27 break;
28 case 'e':
29 expected_value = ACE_OS::atoi (get_opts.opt_arg ());
30 break;
31 case '?':
32 default:
33 ACE_ERROR_RETURN ((LM_ERROR,
34 ACE_TEXT ("usage: %s")
35 ACE_TEXT (" -a <orb1_args>")
36 ACE_TEXT (" -b <orb2_args>")
37 ACE_TEXT (" -e <expected value of ORBConnectionCacheMax>")
38 ACE_TEXT ("\n"),
39 argv [0]),
40 -1);
42 // Indicates successful parsing of the command line
43 return 0;
46 int
47 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
49 try
51 if (parse_args (argc, argv) != 0)
53 return 1;
56 ACE_ARGV orb1_argv (orb1_args);
57 int orb1_argc = orb1_argv.argc ();
59 ACE_ARGV orb2_argv (orb2_args);
60 int orb2_argc = orb2_argv.argc ();
62 ACE_DEBUG ((LM_DEBUG,
63 "Initialize ORB instances...\n"));
65 CORBA::ORB_var orb1 =
66 CORBA::ORB_init (orb1_argc, orb1_argv.argv (), "AAA");
68 CORBA::ORB_var orb2 =
69 CORBA::ORB_init (orb2_argc, orb2_argv.argv (), "BBB");
71 ACE_DEBUG ((LM_DEBUG,
72 "After ORB_init...\n"));
74 TAO_Resource_Factory *trf1 = orb1->orb_core ()->resource_factory ();
76 if (trf1 == 0)
78 ACE_ERROR_RETURN ((LM_ERROR,
79 ACE_TEXT ("ERROR: Can not resolve ")
80 ACE_TEXT ("Resource Factory for orb1.\n")),
81 -1);
84 TAO_Resource_Factory *trf2 = orb2->orb_core ()->resource_factory ();
86 if (trf2 == 0)
88 ACE_ERROR_RETURN ((LM_ERROR,
89 ACE_TEXT ("ERROR: Can not resolve ")
90 ACE_TEXT ("Resource Factory for orb2.\n")),
91 -1);
94 if (trf1->cache_maximum () == trf2->cache_maximum () ||
95 (0 != expected_value && trf1->cache_maximum () != expected_value))
97 ACE_ERROR_RETURN ((LM_ERROR,
98 ACE_TEXT ("ERROR: '-ORBConnectionCacheMax' is ")
99 ACE_TEXT ("applied globally while it's expected ")
100 ACE_TEXT ("to apply to the first ORB only.\n")),
101 -1);
104 orb1->destroy ();
105 orb2->destroy ();
107 ACE_DEBUG ((LM_DEBUG,
108 ACE_TEXT ("'-ORBConnectionCacheMax' is applied to the first ")
109 ACE_TEXT ("ORB only as expected.\n")));
111 catch (const CORBA::Exception& ex)
113 ex._tao_print_exception ("Caught Exception in main:\n");
114 return 1;
117 return 0;