Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / Bug_3695_Regression / Bug_3695.cpp
blob86381fa1184f89549e80b2566ae5262ad2e3f152
1 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP == 0)
3 #include "ace/OS_main.h"
5 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
7 return 0;
10 #else /* TAO_HAS_IIOP */
12 #include "tao/IIOP_Profile.h"
14 struct IIOP_Profile_var
16 explicit IIOP_Profile_var (TAO_IIOP_Profile *pro)
17 : pro_ (pro)
20 ~IIOP_Profile_var ()
22 this->pro_->_decr_refcnt ();
25 TAO_IIOP_Profile *operator->()
27 return this->pro_;
30 TAO_IIOP_Profile *get()
32 return this->pro_;
35 TAO_IIOP_Profile *pro_;
39 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
41 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
42 TAO_ORB_Core *orb_core = orb->orb_core ();
44 // 1. Construct a profile with at least 2 *alternate* endpoints
46 ACE_INET_Addr addr (9238, "localhost"), addr2 (9239, "localhost"),
47 addr3 (9240, "localhost");
48 TAO::ObjectKey okey;
49 TAO_GIOP_Message_Version version;
50 IIOP_Profile_var test_profile (
51 new TAO_IIOP_Profile ("localhost", 9238, okey,
52 addr, version, orb_core));
53 test_profile->add_endpoint (new TAO_IIOP_Endpoint (addr2, 0));
54 test_profile->add_endpoint (new TAO_IIOP_Endpoint (addr3, 0));
55 test_profile->encode_alternate_endpoints ();
58 // 2. Marshal and demarshal it
60 TAO_OutputCDR stream;
61 test_profile->encode (stream);
62 TAO_InputCDR in_stream (stream);
63 in_stream.skip_ulong (); // tag
64 in_stream.skip_ulong (); // length
65 in_stream.skip_octet (); // byte order
66 IIOP_Profile_var test_profile2 (new TAO_IIOP_Profile (orb_core));
67 test_profile2->decode (in_stream);
70 // 3. The result of demarshalling should be equivalent to the original
72 return (test_profile->is_equivalent (test_profile2.get ()) ? 0 : 1);
75 #endif /* TAO_HAS_IIOP */