summaryrefslogtreecommitdiff
path: root/TAO/tests/ORB_Local_Config/Bug_3049/Test.cpp
blob: 48e7bb9082bd18e1ed734d74b1a21ae8705b4f95 (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

// @author Phil Mesnier <mesnier_p@ociweb.com>

// This test scenario is documented in bugzilla bug 3049. This test
// creates 3 ORBs. ORB-A becomes the default ORB, which shares the
// global config context, ORB-B initializes a local configuration
// context which loads a service. ORB-C finally shares the configuration
// from ORB-B. The demonstration is to show that a service is avialable
// to ORB-C from the configuration initalized by ORB-B.

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

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


#include "Service_Configuration_Per_ORB.h"

const ACE_TCHAR argA[] = ACE_TEXT ("AAA -ORBGestalt LOCAL -ORBId ORB-A");
const ACE_TCHAR argB[] = ACE_TEXT ("BBB -ORBGestalt LOCAL -ORBId ORB-B -ORBSvcConf a.conf");
const ACE_TCHAR argC[] = ACE_TEXT ("BBB -ORBGestalt ORB:ORB-B -ORBId ORB-C");

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

  try
  {
    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());

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

    // Confirm that ORBC has SHMIOP, which it inherits from ORBB, and
    // that SHMIOP is not available in the global context

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

    so = ACE_Dynamic_Service<ACE_Service_Object>::instance
      (ORBC->orb_core()->configuration(), "SHMIOP_Factory");
    if (so == 0)
      {
        error++;
        ACE_ERROR ((LM_DEBUG,
                    ACE_TEXT("Failed to find ")
                    ACE_TEXT("SHMIOP_Factory in ORBC\n")));
      }

    ORBA->destroy();

    ORBB->destroy();

    ORBC->destroy();

    if (error > 0)
      return -1;

  }
  catch(const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("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 testBug3049(argc, argv);
}