summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_2085_Regression/Bug_2085_Regression.cpp
blob: 2eae4fa635cb0302ef32c7f917fc8c3141916b3a (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// $Id$


#include "ace/Task.h"
#include "ace/Auto_Event.h"
#include "tao/ORB.h"
#include "tao/Object.h"
#include "tao/SystemException.h"

bool
test_string_to_object (CORBA::ORB_ptr orb, const char* ior, CORBA::ULong minor)
{
  bool succeed = false;
  try
    {
      // Get the object reference with the IOR
      CORBA::Object_var object = orb->string_to_object (ior);
    }
  catch (const CORBA::BAD_PARAM& ex)
    {
      if ((ex.minor() & 0xFFFU) == minor)
        {
          succeed = true;
        }
    }
  catch (const CORBA::Exception&)
    {
    }

  if (!succeed)
  {
    ACE_ERROR ((LM_ERROR,
                "(%t) ERROR, test_string_to_object for <%C> didn't result in minor code %d\n",
                ior,
                minor));
  }

  return succeed;
}

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int retval = 0;

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      // string_to_object conversion failed due to bad scheme name
      if (!test_string_to_object (orb.in (), "", 7))
        ++retval;
      // string_to_object conversion failed due to bad address
      if (!test_string_to_object (orb.in (), "", 8))
        ++retval;
      // string_to_object conversion failed due to bad bad schema specific part
      if (!test_string_to_object (orb.in (), "", 9))
        ++retval;
      // string_to_object conversion failed due to non specific reason
      if (!test_string_to_object (orb.in (), "", 10))
        ++retval;

      orb->destroy ();

      ACE_DEBUG ((LM_DEBUG,
                  "%s successful\n",
                  argv[0]));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught");
      retval = -1;
    }

  return retval;
}