Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_3630_Regression / server.cpp
blobdb7398f97c6cfe4df98fd11e52bc3c5cd64069a1
1 #include "tao/ORB.h"
2 #include "tao/ORB_Core.h"
4 int
5 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
7 int result = 0;
8 int extra_argc = 2;
9 int second_extra_argc = 2;
10 int largc = argc;
11 int second_largc = argc;
13 try
15 ACE_TCHAR **extra = 0;
16 ACE_NEW_RETURN (extra, ACE_TCHAR *[extra_argc], -1);
17 extra[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConf"));
18 extra[1] = ACE::strnew (ACE_TEXT ("TAO Conf File.conf"));
20 ACE_TCHAR **largv = new ACE_TCHAR *[largc+extra_argc];
21 for (int i = 0; i < largc; i++)
22 largv[i] = argv[i];
25 for (int i = 0; i < extra_argc; i++)
26 largv[argc+i] = extra[i];
28 largc += extra_argc;
30 CORBA::ORB_var orb = CORBA::ORB_init (largc, largv, "FirstORB");
31 if(CORBA::is_nil(orb.in ()))
33 ACE_ERROR((LM_ERROR,ACE_TEXT ("Test failed. CORBA::ORB_init returned NIL ORB\n"),1));
35 for (int i = 0; i < extra_argc; i++)
36 ACE::strdelete (extra[i]);
38 delete [] extra;
39 delete [] largv;
41 return -1;
44 orb->destroy ();
45 orb = CORBA::ORB::_nil ();
47 for (int i = 0; i < extra_argc; i++)
48 ACE::strdelete (extra[i]);
49 delete [] extra;
50 delete [] largv;
53 ACE_TCHAR **second_extra = 0;
54 ACE_NEW_RETURN (second_extra, ACE_TCHAR *[second_extra_argc], -1);
55 second_extra[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConf"));
56 second_extra[1] = ACE::strnew (ACE_TEXT ("TAO_Conf_File.conf"));
57 ACE_TCHAR **second_largv = new ACE_TCHAR *[second_largc+second_extra_argc];
58 for (int i = 0; i < second_largc; i++)
59 second_largv[i] = argv[i];
60 for (int i = 0; i < second_extra_argc; i++)
61 second_largv[second_largc + i] = second_extra[i];
63 second_largc += second_extra_argc;
65 CORBA::ORB_var second_orb = CORBA::ORB_init (second_largc, second_largv, "SecondORB");
66 if(CORBA::is_nil(second_orb.in ()))
68 ACE_ERROR((LM_ERROR,ACE_TEXT ("Test failed. CORBA::ORB_init returned NIL ORB\n"),1));
70 for (int i = 0; i < extra_argc; i++)
71 ACE::strdelete (second_extra[i]);
73 delete [] second_extra;
74 delete [] second_largv;
76 return -1;
79 second_orb->destroy ();
80 second_orb = CORBA::ORB::_nil ();
82 for (int i2 = 0; i2 < second_extra_argc; i2++)
83 ACE::strdelete (second_extra[i2]);
85 delete [] second_extra;
86 delete [] second_largv;
88 catch (const CORBA::Exception& ex)
90 ex._tao_print_exception ("Exception caught:");
93 if (result == 0)
94 ACE_DEBUG ((LM_DEBUG,
95 ACE_TEXT ("Test passed!\n")));
96 else
97 ACE_ERROR ((LM_ERROR,
98 ACE_TEXT ("Test failed. Result: %d\n"),
99 result));
100 return result;