summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_1639_Regression
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:21 +0000
commit3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch)
tree197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tests/Bug_1639_Regression
parent6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff)
downloadATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz
Repo restructuring
Diffstat (limited to 'TAO/tests/Bug_1639_Regression')
-rw-r--r--TAO/tests/Bug_1639_Regression/.cvsignore1
-rwxr-xr-xTAO/tests/Bug_1639_Regression/run_test.pl26
-rw-r--r--TAO/tests/Bug_1639_Regression/struct.idl20
-rw-r--r--TAO/tests/Bug_1639_Regression/struct_client.cpp118
-rw-r--r--TAO/tests/Bug_1639_Regression/test.mpc16
5 files changed, 181 insertions, 0 deletions
diff --git a/TAO/tests/Bug_1639_Regression/.cvsignore b/TAO/tests/Bug_1639_Regression/.cvsignore
new file mode 100644
index 00000000000..b051c6c57fa
--- /dev/null
+++ b/TAO/tests/Bug_1639_Regression/.cvsignore
@@ -0,0 +1 @@
+client
diff --git a/TAO/tests/Bug_1639_Regression/run_test.pl b/TAO/tests/Bug_1639_Regression/run_test.pl
new file mode 100755
index 00000000000..7c101f09272
--- /dev/null
+++ b/TAO/tests/Bug_1639_Regression/run_test.pl
@@ -0,0 +1,26 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+use lib "../../../bin";
+use PerlACE::Run_Test;
+
+$status = 0;
+$type = "";
+
+print STDERR "\nDynamic Any struct and union alias tests\n";
+
+$CL = new PerlACE::Process ("client");
+
+$client = $CL->SpawnWaitKill (30);
+
+if ($client != 0)
+{
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+exit $status;
diff --git a/TAO/tests/Bug_1639_Regression/struct.idl b/TAO/tests/Bug_1639_Regression/struct.idl
new file mode 100644
index 00000000000..ab7ae27e229
--- /dev/null
+++ b/TAO/tests/Bug_1639_Regression/struct.idl
@@ -0,0 +1,20 @@
+//
+// $Id$
+//
+module StructTest {
+
+ struct MyStruct {
+ octet MyOctet;
+ unsigned long MyLong;
+ };
+
+ typedef MyStruct MyStructAlias;
+
+ union MyUnion switch (boolean) {
+ case TRUE :
+ unsigned short MyShort;
+ };
+
+ typedef MyUnion MyUnionAlias;
+
+};
diff --git a/TAO/tests/Bug_1639_Regression/struct_client.cpp b/TAO/tests/Bug_1639_Regression/struct_client.cpp
new file mode 100644
index 00000000000..fe0cc437893
--- /dev/null
+++ b/TAO/tests/Bug_1639_Regression/struct_client.cpp
@@ -0,0 +1,118 @@
+//
+// $Id$
+//
+#include "tao/AnyTypeCode/AnyTypeCode_methods.h"
+#include "tao/DynamicAny/DynAnyFactory.h"
+#include "structC.h"
+#include <ace/streams.h>
+
+using namespace StructTest;
+using namespace DynamicAny;
+
+//--------------------------------------------------------------------
+int main (int argc, char * argv[])
+//--------------------------------------------------------------------
+{
+
+ // Generic catch handler
+ try {
+
+ // Initialize the ORB
+ // ------------------
+ CORBA::ORB_var orb; // _var, so we don't need/may not CORBA::release(orb)
+ try {
+ orb = CORBA::ORB_init (argc, argv);
+ } catch (...) {
+ cerr << "Cannot initialize ORB" << endl;
+ throw;
+ }
+
+ // Get reference to the DynAny Factory
+ CORBA::Object_var obj = orb->resolve_initial_references("DynAnyFactory");
+
+ DynAnyFactory_var daf =
+ DynAnyFactory::_narrow(obj.in());
+
+ MyStruct my_struct;
+ MyStructAlias my_struct_alias;
+ MyUnion my_union;
+ MyUnionAlias my_union_alias;
+
+ CORBA::Any any_struct;
+ CORBA::Any any_struct_alias;
+ CORBA::Any any_union;
+ CORBA::Any any_union_alias;
+
+ // Write the structs and unions to anys so we can get the TypeCode info
+ any_struct <<= my_struct;
+ any_struct_alias <<= my_struct_alias;
+ any_union <<= my_union;
+ any_union_alias <<= my_union_alias;
+
+ // Explicitly set the TypeCode for the aliased types because the any
+ // doesn't take care of aliases
+ any_struct_alias.type(_tc_MyStructAlias);
+ any_union_alias.type(_tc_MyUnionAlias);
+
+ CORBA::TypeCode_var tc_struct = any_struct.type();
+ CORBA::TypeCode_var tc_struct_alias = any_struct_alias.type();
+ CORBA::TypeCode_var tc_union = any_union.type();
+ CORBA::TypeCode_var tc_union_alias = any_union_alias.type();
+
+ cout << "Type Code of the struct: " << tc_struct->kind() << endl;
+ cout << "Type Code of the struct alias: " << tc_struct_alias->kind() << endl;
+ cout << "Type Code of the union: " << tc_union->kind() << endl;
+ cout << "Type Code of the union alias: " << tc_union_alias->kind() << endl;
+
+ // equal returns true only when the TypeCodes are exactly the same.
+ if (tc_struct->equal(tc_struct_alias.in())) {
+ cout << "Type Codes are identical" << endl;
+ } else {
+ cout << "Type Codes are different" << endl;
+ }
+ // equivalent returns true when the TypeCode is an alias
+ if (tc_struct->equivalent(tc_struct_alias.in())) {
+ cout << "Type Codes are equivalent" << endl;
+ } else {
+ cout << "Type Codes are not equivalent" << endl;
+ }
+
+ DynAny_var da_struct = daf->create_dyn_any_from_type_code (tc_struct.in());
+
+ try {
+ DynAny_var da_struct_alias = daf->create_dyn_any_from_type_code (tc_struct_alias.in());
+ } catch ( const CORBA::UNKNOWN &) {
+ cout << "CORBA::UNKNOWN exception when calling create_dyn_any_from_type_code (tc_struct_alias)" << endl;
+ }
+
+ try {
+ DynAny_var da_struct_alias = daf->create_dyn_any (any_struct_alias);
+ } catch ( const CORBA::UNKNOWN &) {
+ cout << "CORBA::UNKNOWN exception when calling create_dyn_any (any_struct_alias)" << endl;
+ }
+
+ DynAny_var da_union = daf->create_dyn_any_from_type_code (tc_union.in());
+
+ try {
+ DynAny_var da_union_alias = daf->create_dyn_any_from_type_code (tc_union_alias.in());
+ } catch ( const CORBA::UNKNOWN &) {
+ cout << "CORBA::UNKNOWN exception when calling create_dyn_any_from_type_code (tc_union_alias)" << endl;
+ }
+
+ try {
+ DynAny_var da_union_alias = daf->create_dyn_any (any_union_alias);
+ } catch ( const CORBA::UNKNOWN &) {
+ cout << "CORBA::UNKNOWN exception when calling create_dyn_any (any_union_alias)" << endl;
+ }
+
+ } // end try
+
+ catch (const CORBA::Exception &) {
+ cerr << "Caught CORBA exception" << endl;
+ return 1;
+ }
+ catch (...) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/TAO/tests/Bug_1639_Regression/test.mpc b/TAO/tests/Bug_1639_Regression/test.mpc
new file mode 100644
index 00000000000..f0d95132c29
--- /dev/null
+++ b/TAO/tests/Bug_1639_Regression/test.mpc
@@ -0,0 +1,16 @@
+// -*- MPC -*-
+// $Id$
+
+project (Bug_1639_testclient) : taoserver, dynamicany, exceptions {
+ exename = client
+ Source_Files {
+ struct_client.cpp
+ structC.cpp
+ structS.cpp
+ }
+
+ IDL_Files {
+ struct.idl
+ }
+
+}