summaryrefslogtreecommitdiff
path: root/trunk/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp
blob: 346ca6ae926e31b6bb9e973eb4e32d2dc1e18827 (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

// @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 allready be seen in the multiple
// orb scenarios AB b isnt prompted for a new certificate password, MA
// ssliop isnt loaded at all etc


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

/// The combination of orb instances and their configurations to test
#define MORB_MA

ACE_RCSID (tests, server, "$Id$")


#include "Service_Configuration_Per_ORB.h"

const char argA[] = "AAA -ORBId ORB-A -ORBSvcConf a.conf";

// dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLAuthenticate SERVER_AND_CLIENT -SSLPrivateKey PEM:server_key.pem -SSLCertificate PEM:server_cert.pem";
// static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"

const char argB[] = "BBB -ORBSvcConf b.conf";

// dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLAuthenticate SERVER_AND_CLIENT -SSLPrivateKey PEM:client_key.pem -SSLCertificate PEM:client_cert.pem"
// static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"

const char argM[] = "MMM -ORBId ORB-M -ORBSvcConf m.conf";

// dynamic UIPMC_Factory Service_Object * TAO_PortableGroup:_make_TAO_UIPMC_Protocol_Factory() ""
// static Resource_Factory "-ORBProtocolFactory IIOP_Factory -ORBProtocolFactory UIPMC_Factory"
// #static PortableGroup_Loader ""
// dynamic PortableGroup_Loader Service_Object * TAO_PortableGroup:_make_TAO_PortableGroup_Loader() ""

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

  try
  {

#ifdef MORB_AB
    ACE_ARGV arg0(argA);
    int n = arg0.argc();
    CORBA::ORB_var ORBA = CORBA::ORB_init(n,arg0.argv());

    ACE_ARGV arg1(argB);
    n = arg1.argc();
    CORBA::ORB_var ORBB = CORBA::ORB_init(n,arg1.argv());
#else
    ACE_UNUSED_ARG (argA);
    ACE_UNUSED_ARG (argB);
#endif /* MORB_AB */



#ifdef MORB_AM
    ACE_ARGV arg0(argA);
    int n = arg0.argc();
    CORBA::ORB_var ORBA = CORBA::ORB_init(n,arg0.argv());

    ACE_ARGV arg1(argM);
    n = arg1.argc();
    CORBA::ORB_var ORBB = CORBA::ORB_init(n,arg1.argv());
#else
    ACE_UNUSED_ARG (argA);
    ACE_UNUSED_ARG (argM);
#endif /* MORB_AM */



#ifdef MORB_MA
    int n = 0;
    ACE_ARGV arg0(argM);
    n = arg0.argc();
    CORBA::ORB_var ORBA = CORBA::ORB_init(n, arg0.argv());
    if (ORBA.in () == 0)
      ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected to get an ORB\n")), -1);

    ACE_ARGV arg1(argA);
    n = arg1.argc();
    CORBA::ORB_var ORBB = CORBA::ORB_init(n, arg1.argv());
    if (ORBB.in () == 0)
      ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected to get a second ORB\n")), -1);

    if (ORBA.in () == ORBB.in ())
      ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Unexpected to find the two ORBs the same\n")), -1);

    // Look ma!! No ... services?!

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

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

    // 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

    ORBA->destroy();

    ORBB->destroy();

    if (error > 0)
      return -1;
#endif /* MORB_MA */

  }
  catch(const CORBA::Exception& ex)
    {
      ACE_PRINT_EXCEPTION (ex, "Unhandled exception caught");
      return -1;
    }
  catch(...)
    {
      ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Unexpected exception\n")), -1);
    }

  return 0;
}

// @brief the main driver

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