Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Bug_2543_Regression / bug_2543_regression.cpp
blobc2535b1c46dc4d1a406894063d56228b88e57f75
1 #include "TestC.h"
2 #include "tao/CodecFactory/CodecFactory.h"
4 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
6 try
8 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
10 orb->register_value_factory(
11 Base::_tao_obv_static_repository_id(),
12 new Base_init);
13 orb->register_value_factory(
14 Value::_tao_obv_static_repository_id(),
15 new Value_init);
17 CORBA::Object_var object =
18 orb->resolve_initial_references("CodecFactory");
20 IOP::CodecFactory_var codec_factory =
21 IOP::CodecFactory::_narrow(object.in ());
22 IOP::Encoding e = {IOP::ENCODING_CDR_ENCAPS,1,2};
24 IOP::Codec_var codec = codec_factory->create_codec(e);
26 CORBA::Any any_o;
27 BaseSeq values;
28 values.length(1);
29 values[0] = new OBV_Value(1,"An instance of Value");
30 any_o <<= values;
31 any_o.type(_tc_BaseSeq);
33 CORBA::OctetSeq_var bin = codec->encode(any_o);
34 CORBA::Any_var any_n = codec->decode(bin.in ());
36 const BaseSeq * out = 0;
37 if (!(any_n.in () >>= out))
39 ACE_ERROR_RETURN ((LM_ERROR,
40 "Error: extract out of any failed\n"),
41 1);
43 if (ACE_OS::strcmp( (*out)[0]->_tao_obv_repository_id(),
44 Value::_tao_obv_static_repository_id()) != 0)
46 ACE_ERROR_RETURN ((LM_ERROR, "Error: wrong type!\n"), 1);
49 orb->destroy();
51 catch (const CORBA::Exception& ex)
53 ex._tao_print_exception ("Caught a CORBA exception\n");
54 return 1;
56 catch (...)
58 return 1;
61 return 0;