summaryrefslogtreecommitdiff
path: root/TAO/tests/CORBA_e_Implicit_Activation/server.cpp
blob: 524ff30f63f96ebff3b5bfd8e658f8ef363fdf19 (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
// $Id$

#include "Hello.h"
#include "ace/OS_NS_stdio.h"

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

int
main (int argc, char *argv[])
{
  int status = 1;
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

      Test::Hello_var hello = hello_impl->_this ();

      ACE_ERROR ((LM_ERROR,
                  "ERROR: Implicit activation should have "
                  "thrown an exception with CORBA e compact.\n"));

      root_poa->destroy (1, 1);
      orb->destroy ();
    }
  catch (const CORBA::INV_POLICY&)
    {
      ACE_DEBUG ((LM_DEBUG, "This test passes.\n"));
      status = 0;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
    }

  return status;
}