| 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 1 : poatest-basic01.c
|
|---|
| 23 | * o Root POA.
|
|---|
| 24 | * o activated object with system assigned id.
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | #include <stdio.h>
|
|---|
| 28 | #include <string.h>
|
|---|
| 29 | #include <stdlib.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <orbit/orbit.h>
|
|---|
| 32 |
|
|---|
| 33 | #include "poatest-basic-shell.h"
|
|---|
| 34 |
|
|---|
| 35 | static void
|
|---|
| 36 | poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
|
|---|
| 37 |
|
|---|
| 38 | static PortableServer_ServantBase__epv base_epv = {
|
|---|
| 39 | NULL, /* _private */
|
|---|
| 40 | NULL, /* finalize */
|
|---|
| 41 | NULL /* default_POA */
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | static POA_poatest__epv poatest_epv = {
|
|---|
| 45 | NULL, /* _private */
|
|---|
| 46 | poatest_test_impl /* test */
|
|---|
| 47 | };
|
|---|
| 48 |
|
|---|
| 49 | static POA_poatest__vepv poatest_vepv = {
|
|---|
| 50 | &base_epv, /* _base_epv */
|
|---|
| 51 | &poatest_epv /* poatest_epv */
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | static POA_poatest poatest_servant = {
|
|---|
| 55 | NULL, /* _private */
|
|---|
| 56 | &poatest_vepv /* vepv */
|
|---|
| 57 | };
|
|---|
| 58 |
|
|---|
| 59 | poatest
|
|---|
| 60 | poatest_run (PortableServer_POA rootpoa,
|
|---|
| 61 | PortableServer_POAManager rootpoa_mgr )
|
|---|
| 62 | {
|
|---|
| 63 | CORBA_Environment ev;
|
|---|
| 64 | PortableServer_ObjectId *objid;
|
|---|
| 65 | PortableServer_ObjectId *objid_back;
|
|---|
| 66 | CORBA_char *objid_str;
|
|---|
| 67 | int objid_str_length;
|
|---|
| 68 |
|
|---|
| 69 | CORBA_exception_init( &ev );
|
|---|
| 70 |
|
|---|
| 71 | /*
|
|---|
| 72 | * Initialise the servant.
|
|---|
| 73 | */
|
|---|
| 74 | POA_poatest__init (&poatest_servant, &ev);
|
|---|
| 75 | if (POATEST_EX (&ev)) {
|
|---|
| 76 | POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
|
|---|
| 77 | return CORBA_OBJECT_NIL;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | /*
|
|---|
| 81 | * Activate object. POA will assign an ObjectId.
|
|---|
| 82 | */
|
|---|
| 83 | objid = PortableServer_POA_activate_object (rootpoa, &poatest_servant, &ev);
|
|---|
| 84 | if (POATEST_EX (&ev)) {
|
|---|
| 85 | POATEST_PRINT_EX ("activate_object : ", &ev);
|
|---|
| 86 | return CORBA_OBJECT_NIL;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | objid_str = PortableServer_ObjectId_to_string (objid, &ev);
|
|---|
| 90 | g_assert (objid_str != NULL);
|
|---|
| 91 | g_assert (strlen (objid_str) == objid->_length);
|
|---|
| 92 |
|
|---|
| 93 | objid_str_length = strlen (objid_str);
|
|---|
| 94 | objid_back = PortableServer_string_to_ObjectId (objid_str, &ev);
|
|---|
| 95 |
|
|---|
| 96 | g_assert (objid->_length == objid_back->_length);
|
|---|
| 97 | g_assert (!memcmp (objid->_buffer, objid_back->_buffer,
|
|---|
| 98 | objid->_length));
|
|---|
| 99 |
|
|---|
| 100 | CORBA_free (objid_back);
|
|---|
| 101 | CORBA_free (objid_str);
|
|---|
| 102 | CORBA_free (objid);
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 | return CORBA_OBJECT_NIL;
|
|---|
| 106 | }
|
|---|