source: trunk/ORBit2-2.14.0/test/poa/poatest-basic04.c

Last change on this file was 92, checked in by cinc, 19 years ago

Orbit2 modified for use with NOM

File size: 3.6 KB
Line 
1/*
2 * CORBA POA tests
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Author: Mark McLoughlin <mark@skynet.ie>
19 */
20
21/*
22 * Test 4 : poatest-basic04.c
23 * o POA with USER_ID Id Assignment policy.
24 * o activated object with user assigned Id.
25 */
26
27#include <stdio.h>
28#include <stdlib.h>
29
30#include <orbit/orbit.h>
31
32#include "poatest-basic-shell.h"
33
34static void
35poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
36
37PortableServer_ServantBase__epv base_epv = {
38 NULL, /* _private */
39 NULL, /* finalize */
40 NULL /* default_POA */
41};
42
43POA_poatest__epv poatest_epv = {
44 NULL, /* _private */
45 poatest_test_impl /* test */
46};
47
48POA_poatest__vepv poatest_vepv = {
49 &base_epv, /* _base_epv */
50 &poatest_epv /* poatest_epv */
51};
52
53POA_poatest poatest_servant = {
54 NULL, /* _private */
55 &poatest_vepv /* vepv */
56};
57
58poatest
59poatest_run (PortableServer_POA rootpoa,
60 PortableServer_POAManager rootpoa_mgr)
61{
62 CORBA_Environment ev;
63 poatest poatest_obj;
64 CORBA_PolicyList *poa_policies;
65 PortableServer_ObjectId *objid;
66
67 CORBA_exception_init (&ev);
68
69 /*
70 * Create child POA with USER_ID Id Assignment policy.
71 */
72 poa_policies = CORBA_PolicyList__alloc ();
73 poa_policies->_maximum = 1;
74 poa_policies->_length = 1;
75 poa_policies->_buffer = CORBA_PolicyList_allocbuf (1);
76 CORBA_sequence_set_release (poa_policies, CORBA_TRUE);
77
78 poa_policies->_buffer[0] = (CORBA_Policy)
79 PortableServer_POA_create_id_assignment_policy (
80 rootpoa,
81 PortableServer_USER_ID,
82 &ev);
83
84 child_poa = PortableServer_POA_create_POA (rootpoa,
85 "User Id POA",
86 rootpoa_mgr,
87 poa_policies,
88 &ev);
89 if (POATEST_EX (&ev)) {
90 POATEST_PRINT_EX ("create_POA : ", &ev);
91 return CORBA_OBJECT_NIL;
92 }
93
94 CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
95 CORBA_free (poa_policies);
96
97 /*
98 * Initialise the servant.
99 */
100 POA_poatest__init (&poatest_servant, &ev);
101 if (POATEST_EX (&ev)) {
102 POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
103 return CORBA_OBJECT_NIL;
104 }
105
106 /*
107 * Set up the ObjectId.
108 */
109 objid = PortableServer_string_to_ObjectId ("Test Id", &ev);
110 if (POATEST_EX (&ev)) {
111 POATEST_PRINT_EX ("string_to_ObjectId : ", &ev);
112 return CORBA_OBJECT_NIL;
113 }
114
115 /*
116 * Activate object with user assigned Id.
117 */
118 PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev);
119 if (POATEST_EX (&ev)) {
120 POATEST_PRINT_EX ("activate_object_with_id : ", &ev);
121 return CORBA_OBJECT_NIL;
122 }
123
124 CORBA_free (objid);
125
126 poatest_obj = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev);
127 if (POATEST_EX (&ev)) {
128 POATEST_PRINT_EX ("servant_to_reference : ", &ev);
129 return CORBA_OBJECT_NIL;
130 }
131
132 /*
133 * Activate the POAManager. POA will now accept requests
134 */
135 PortableServer_POAManager_activate (rootpoa_mgr, &ev);
136 if (POATEST_EX (&ev)) {
137 POATEST_PRINT_EX ("POAManager_activate : ", &ev);
138 return CORBA_OBJECT_NIL;
139 }
140
141 return poatest_obj;
142}
Note: See TracBrowser for help on using the repository browser.