summaryrefslogtreecommitdiff
path: root/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp
blob: f67164da137238aa5b2096a34c06863b4e989608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// $Id$
// @author Jeff Mirwaisi <jeff_mirwaisi@yahoo.com>
// @author Iliyan Jeliazkov <iliyan2ociweb.com>

// the following is a simplification of the above problems (see
// bugzilla 1459) and the different scenarios minus the creation of
// the servant the service manager or threads even without the servant
// to demonstrate that the server is capable of responding (which in
// some cases it isnt) problems can already be seen in the multiple
// orb scenarios


#include "tao/corba.h"
#include "ace/ARGV.h"
#include "ace/Dynamic_Service.h"
#include "Service_Configuration_Per_ORB.h"

// Currently there is no way to test SSLIOP in this test due to a problem
// described in bug 3418.
//#define DO_1459_SSLIOP_TEST 1

// UIOP
const ACE_TCHAR argStrA[] = ACE_TEXT ("AAA -ORBGestalt LOCAL -ORBId ORB-A -ORBSvcConf a.conf");

// SSLIOP
const ACE_TCHAR argStrB[] = ACE_TEXT ("BBB -ORBGestalt LOCAL -ORBId ORB-B -ORBSvcConf b.conf");

// UIPMC
const ACE_TCHAR argStrC[] = ACE_TEXT ("CCC -ORBGestalt LOCAL -ORBId ORB-C -ORBSvcConf m1.conf");

// DIOP
const ACE_TCHAR argStrD[] = ACE_TEXT ("DDD -ORBGestalt LOCAL -ORBId ORB-D -ORBSvcConf d.conf");

// empty file
const ACE_TCHAR argStrM[] = ACE_TEXT ("MMM -ORBGestalt LOCAL -ORBId ORB-M -ORBSvcConf m.conf");

int
testBug1459 (int, ACE_TCHAR *[])
{
  ACE_TRACE ("testBug1459");

  try
    {
      int n, error = 0;

      ACE_ARGV argM (argStrM);
      n = argM.argc ();
      CORBA::ORB_var ORBM =
        CORBA::ORB_init (n, argM.argv ());

      if (CORBA::is_nil (ORBM.in ()))
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Expected to get an ORB\n")),
                          -1);

#if TAO_HAS_UIOP == 1
      // UIOP
      ACE_ARGV argA (argStrA);
      n = argA.argc ();
      CORBA::ORB_var ORBA =
        CORBA::ORB_init (n, argA.argv ());

      if (CORBA::is_nil (ORBA.in ()))
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Expected to get an ORB\n")),
                          -1);
#endif /* TAO_HAS_UIOP */

#if defined (DO_1459_SSLIOP_TEST)
      // SSLIOP
      ACE_ARGV argB (argStrB);
      n = argB.argc ();
      CORBA::ORB_var ORBB =
        CORBA::ORB_init (n, argB.argv ());

      if (CORBA::is_nil (ORBB.in ()))
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Expected to get an ORB\n")),
                          -1);
#endif

      // MIOP
      ACE_ARGV argC (argStrC);
      n = argC.argc ();
      CORBA::ORB_var ORBC =
        CORBA::ORB_init (n, argC.argv ());

      if (CORBA::is_nil (ORBC.in ()))
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Expected to get an ORB\n")),
                          -1);

      // DIOP
      ACE_ARGV argD (argStrD);
      n = argD.argc ();
      CORBA::ORB_var ORBD =
        CORBA::ORB_init (n, argD.argv ());

      if (CORBA::is_nil (ORBD.in ()))
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Expected to get an ORB\n")),
                          -1);

      if (
// SSLIOP
#if defined (DO_1459_SSLIOP_TEST)
          ORBM.in () == ORBB.in () ||
#if TAO_HAS_UIOP == 1
          ORBA.in () == ORBB.in () ||
#endif
          ORBC.in () == ORBB.in () ||
          ORBD.in () == ORBB.in () ||
#endif
// UIOP
#if TAO_HAS_UIOP
          ORBM.in () == ORBA.in () ||
          ORBC.in () == ORBA.in () ||
          ORBD.in () == ORBA.in () ||
#endif
// MIOP
          ORBM.in () == ORBC.in () ||
          ORBD.in () == ORBC.in () ||
// DIOP
          ORBM.in () == ORBD.in ()
         )
        ACE_ERROR_RETURN ((LM_DEBUG,
                           ACE_TEXT("Unexpected to find the two ORBs are the same\n")),
                          -1);

      // Since each svc conf file causes the ORB to load the services in
      // its own service space no services are reachable through the
      // global service repo

#if TAO_HAS_UIOP == 1
      // UIOP
      ACE_Service_Object *uiop_so =
        ACE_Dynamic_Service<ACE_Service_Object>::instance ("UIOP_Factory");
      if (uiop_so != 0)
        {
          ++error;
          ACE_ERROR ((LM_DEBUG,
                      ACE_TEXT("Unexpected to find ")
                      ACE_TEXT("UIOP_Factory globally\n")));
        }
#endif /* TAO_HAS_UIOP */

#if defined (DO_1459_SSLIOP_TEST)
      // SSLIOP
      ACE_Service_Object *ssliop_so =
        ACE_Dynamic_Service<ACE_Service_Object>::instance ("SSLIOP_Factory");
      if (ssliop_so != 0)
        {
          ++error;
          ACE_ERROR ((LM_DEBUG,
                      ACE_TEXT("Unexpected to find ")
                      ACE_TEXT("SSLIOP_Factory globally\n")));
        }
#endif

      // MIOP
      ACE_Service_Object *uipmc_so =
        ACE_Dynamic_Service<ACE_Service_Object>::instance ("UIPMC_Factory");
      if (uipmc_so != 0)
        {
          ++error;
          ACE_ERROR ((LM_DEBUG,
                      ACE_TEXT("Unexpected to find ")
                      ACE_TEXT("UIPMC_Factory globally\n")));
        }

      // DIOP
      ACE_Service_Object *diop_so =
        ACE_Dynamic_Service<ACE_Service_Object>::instance ("DIOP_Factory");
      if (diop_so != 0)
        {
          ++error;
          ACE_ERROR ((LM_DEBUG,
                      ACE_TEXT("Unexpected to find ")
                      ACE_TEXT("DIOP_Factory globally\n")));
        }

      ORBM->destroy();

#if TAO_HAS_UIOP == 1
      ORBA->destroy();
#endif /* TAO_HAS_UIOP */

#if defined (DO_1459_SSLIOP_TEST)
      ORBB->destroy();
#endif

      ORBC->destroy();

      ORBD->destroy();

      if (error > 0)
        return -1;
    }
  catch(const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Unhandled exception caught");
      return -1;
    }

  return 0;
}

// @brief the main driver

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  return testBug1459(argc, argv);
}