summaryrefslogtreecommitdiff
path: root/tests/Bug_3695_Regression/Bug_3695.cpp
blob: 3d1ee4218f55e5f0031d2ad49b6fb1fba5c9b633 (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$

#if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP == 0)

#include "ace/OS_main.h"

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  return 0;
}

#else /* TAO_HAS_IIOP */

#include "tao/IIOP_Profile.h"

struct IIOP_Profile_var
{
  explicit IIOP_Profile_var (TAO_IIOP_Profile *pro)
    : pro_ (pro)
  {}

  ~IIOP_Profile_var ()
  {
    this->pro_->_decr_refcnt ();
  }

  TAO_IIOP_Profile *operator->()
  {
    return this->pro_;
  }

  TAO_IIOP_Profile *get()
  {
    return this->pro_;
  }

  TAO_IIOP_Profile *pro_;
};


int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
  TAO_ORB_Core *orb_core = orb->orb_core ();

  // 1. Construct a profile with at least 2 *alternate* endpoints

  ACE_INET_Addr addr (9238, "localhost"), addr2 (9239, "localhost"),
    addr3 (9240, "localhost");
  TAO::ObjectKey okey;
  TAO_GIOP_Message_Version version;
  IIOP_Profile_var test_profile (
    new TAO_IIOP_Profile ("localhost", 9238, okey,
                          addr, version, orb_core));
  test_profile->add_endpoint (new TAO_IIOP_Endpoint (addr2, 0));
  test_profile->add_endpoint (new TAO_IIOP_Endpoint (addr3, 0));
  test_profile->encode_alternate_endpoints ();


  // 2. Marshal and demarshal it

  TAO_OutputCDR stream;
  test_profile->encode (stream);
  TAO_InputCDR in_stream (stream);
  in_stream.skip_ulong (); // tag
  in_stream.skip_ulong (); // length
  in_stream.skip_octet (); // byte order
  IIOP_Profile_var test_profile2 (new TAO_IIOP_Profile (orb_core));
  test_profile2->decode (in_stream);


  // 3. The result of demarshalling should be equivalent to the original

  return (test_profile->is_equivalent (test_profile2.get ()) ? 0 : 1);
}

#endif /* TAO_HAS_IIOP */