Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Bug_1693_Test / client.cpp
blob6ce82f6dbf034cb1d5bf02a9192bd8b8af82aa40
1 // -*- C++ -*-
2 #include "tao/CodecFactory/CodecFactory.h"
3 #include "testC.h"
4 #include "ace/Log_Msg.h"
6 int
7 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
9 try
11 CORBA::ORB_var orb =
12 CORBA::ORB_init (argc,
13 argv,
14 "my_orb");
16 // Obtain a reference to the CodecFactory.
17 CORBA::Object_var obj =
18 orb->resolve_initial_references ("CodecFactory");
20 IOP::CodecFactory_var codec_factory =
21 IOP::CodecFactory::_narrow (obj.in ());
23 // ----------------------------------------------------------
25 // Set up a structure that contains information necessary to
26 // create a GIOP 1.1 CDR encapsulation Codec.
27 IOP::Encoding encoding;
28 encoding.format = IOP::ENCODING_CDR_ENCAPS;
29 encoding.major_version = 1;
30 encoding.minor_version = 1;
32 // Obtain the CDR encapsulation Codec.
33 IOP::Codec_var codec =
34 codec_factory->create_codec (encoding);
36 // ----------------------------------------------------------
38 CORBA::OctetSeq_var encoded_data;
39 CORBA::Any_var decoded_data;
41 Foo::type_ulong l = 9192631;
43 CORBA::Any tmp;
45 tmp <<= l;
47 encoded_data =
48 codec->encode_value (tmp);
50 decoded_data =
51 codec->decode_value (encoded_data.in (),
52 Foo::_tc_type_ulong);
54 Foo::type_ulong check = 0;
56 if (!(decoded_data >>= check))
57 ACE_ERROR_RETURN ((LM_ERROR,
58 "ERROR: Unable to extract typedefed decoded "
59 "data from Any\n"),
60 -1);
62 if (check != l)
63 ACE_ERROR_RETURN ((LM_ERROR,
64 "ERROR: Extracted value not equal "
65 "to the encoded value\n"),
66 -1);
69 ACE_DEBUG ((LM_DEBUG,
70 "(%P|%t) Test passed\n"));
72 catch (const CORBA::Exception& ex)
74 ex._tao_print_exception ("Bug_1693_Test test:");
75 return -1;
78 return 0;