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

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

Orbit2 modified for use with NOM

File size: 2.5 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#include <stdio.h>
22#include <stdlib.h>
23
24#include <orbit/orbit.h>
25
26#include "poatest-basic-shell.h"
27
28PortableServer_POA child_poa = CORBA_OBJECT_NIL;
29CORBA_ORB orb = CORBA_OBJECT_NIL;
30
31int
32main (int argc, char **argv)
33{
34 CORBA_Environment ev;
35 PortableServer_POA rootpoa;
36 PortableServer_POAManager poa_mgr;
37 poatest poatest_obj;
38
39 CORBA_exception_init (&ev);
40
41 orb = CORBA_ORB_init (&argc, argv, "", &ev);
42
43 /*
44 * Get the Root POA
45 */
46 rootpoa = (PortableServer_POA)
47 CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
48 if (POATEST_EX (&ev)) {
49 POATEST_PRINT_EX ("resolve_initial_references : ", &ev);
50 return 1;
51 }
52
53
54 /*
55 * Get the Root POA's POAManager
56 */
57 poa_mgr = PortableServer_POA__get_the_POAManager (rootpoa, &ev);
58 if (POATEST_EX (&ev)) {
59 POATEST_PRINT_EX ("the_POAManager : ", &ev);
60 return 1;
61 }
62
63 /*
64 * Run the test
65 */
66 poatest_obj = poatest_run (rootpoa, poa_mgr);
67 if (poatest_obj == CORBA_OBJECT_NIL)
68 return 1;
69
70 /*
71 * Call 'test' method and print out execption.
72 */
73 poatest_test (poatest_obj, &ev);
74 if (POATEST_EX (&ev)) {
75 POATEST_PRINT_EX ("test : ", &ev);
76 return 1;
77 }
78
79 CORBA_Object_release ((CORBA_Object) poatest_obj, &ev);
80 CORBA_Object_release ((CORBA_Object) poa_mgr, &ev);
81 CORBA_Object_release ((CORBA_Object) rootpoa, &ev);
82
83 if (child_poa != CORBA_OBJECT_NIL) {
84 PortableServer_POA_destroy (
85 child_poa, CORBA_FALSE, CORBA_FALSE, &ev);
86 CORBA_Object_release ((CORBA_Object) child_poa, &ev);
87 }
88
89 CORBA_ORB_shutdown (orb, CORBA_TRUE, &ev);
90 if (POATEST_EX (&ev)) {
91 POATEST_PRINT_EX ("ORB_shutdown : ", &ev);
92 return 1;
93 }
94
95 CORBA_ORB_destroy (orb, &ev);
96 if (POATEST_EX (&ev)) {
97 POATEST_PRINT_EX ("ORB_destroy : ", &ev);
98 return 1;
99 }
100
101 CORBA_Object_release ((CORBA_Object) orb, &ev);
102
103 return 0;
104}
Note: See TracBrowser for help on using the repository browser.