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
|
// $Id$
// The following is required to be able to access
// ace_svc_desc_TAO_*_Parser, below
#include "tao/CORBALOC_Parser.h"
#include "tao/CORBANAME_Parser.h"
#include "ace/ARGV.h"
#include "ace/Service_Config.h"
#include "ace/Dynamic_Service.h"
ACE_RCSID (tests, server, "$Id$")
#include "Service_Configuration_Per_ORB.h"
// @brief The "new" interfaces must be compatible with the "old" ones
int
testCompatibility (int , ACE_TCHAR *[])
{
ACE_TRACE ("testCompatibility");
// This uses the same default ACE_Service_Repository
ACE_Service_Gestalt_Test glob;
// Use the "old" interface
if (0 != ACE_Service_Config::process_directive
(ace_svc_desc_TAO_CORBANAME_Parser))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Failed to process %s\n"), ace_svc_desc_TAO_CORBANAME_Parser), -1);
if(0 != ACE_Service_Config::process_directive
(ace_svc_desc_TAO_CORBALOC_Parser))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Failed to process %s\n"), ace_svc_desc_TAO_CORBALOC_Parser), -1);
const ACE_TCHAR * svcname = 0;
{
// This uses the same default ACE_Service_Repository
ACE_Service_Gestalt_Test one;
svcname = "CORBANAME_Parser";
ACE_Service_Object* p20 =
ACE_Dynamic_Service<ACE_Service_Object>::instance (&one, svcname);
if ((p20 == 0))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected %s locally, in one\n"), svcname), -1);
svcname = "CORBALOC_Parser";
ACE_Service_Object* p21 =
ACE_Dynamic_Service<ACE_Service_Object>::instance (&one, svcname);
if ((p21 == 0))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected %s locally, in one\n"), svcname), -1);
// Exiting this scope should fini all services in the glob ...
}
svcname = "CORBANAME_Parser";
ACE_Service_Object* p20 =
ACE_Dynamic_Service<ACE_Service_Object>::instance (&glob, svcname);
if ((p20 != 0))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected %s globally, too\n"), svcname), -1);
svcname = "CORBALOC_Parser";
ACE_Service_Object* p21 =
ACE_Dynamic_Service<ACE_Service_Object>::instance (&glob, svcname);
if ((p21 != 0))
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected %s globally, too\n"), svcname), -1);
return 0;
}
// @brief Test commandline processing
int
testCommandLineDirectives (int , ACE_TCHAR *[])
{
ACE_TRACE ("testCommandLineDirectives");
ACE_ARGV new_argv;
if (new_argv.add (ACE_TEXT ("-f")) == -1
|| new_argv.add (ACE_TEXT ("-S")) == -1
|| new_argv.add (ACE_TEXT ("d1")) == -1
|| new_argv.add (ACE_TEXT ("-S")) == -1
|| new_argv.add (ACE_TEXT ("d2")) == -1)
{
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Unable to create an argv\n")), -1);
}
ACE_Service_Gestalt_Test g(5);
if (g.parse_args (new_argv.argc (),
new_argv.argv ()) == -1
&& errno != ENOENT)
{
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Failed to parse the argv\n")), -1);
}
ACE_DEBUG ((LM_DEBUG, "\tg.command_line_directives_count () -> %d\n",
g.command_line_directives_count ()));
if (2 != g.command_line_directives_count ())
ACE_ERROR_RETURN ((LM_DEBUG,
ACE_TEXT("Expected %d, but found %d command line directives\n"),
2,
g.command_line_directives_count ()),
-1);
return 0;
}
// @brief Test the helper components used to implement the temporary
// substitution of the repository currently used as "global" for the
// sake of registering static services, which are dependent on a dynamic
// service
int
testTSSGestalt (int , ACE_TCHAR *[])
{
ACE_TRACE ("testTSSGestalt");
ACE_Service_Gestalt_Test one (10); // Localized ones go here
ACE_Service_Gestalt *global_instance = ACE_Service_Config::instance ();
// Sanity check
if (global_instance == &one)
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Invalid global gestalt\n")), -1);
{
// Make one be the ACE_Service_Config::instance () ...
ACE_Service_Config_Guard temporary (&one);
ACE_Service_Gestalt *global_instance2 = ACE_Service_Config::instance ();
if (global_instance == global_instance2)
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected to see a different global from before\n")), -1);
if (global_instance2 != &one)
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected one to be the global gestalt instance\n")), -1);
// The guard is dead! Long live the global gestalt that was previously global!
}
if (global_instance != ACE_Service_Config::instance ())
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Expected the original global gestalt\n")), -1);
if (global_instance == &one)
ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT("Found the wrong instance is still being global\n")), -1);
return 0;
}
// @brief the main driver
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
return
testCompatibility (argc, argv)
&& testCommandLineDirectives (argc, argv)
&& testTSSGestalt(argc, argv);
}
|