summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/tests/objref_comparison_test/foo.idl3
-rw-r--r--TAO/tests/objref_comparison_test/main.cpp145
-rw-r--r--TAO/tests/objref_comparison_test/objref_comparison_test.mpc5
-rw-r--r--TAO/tests/objref_comparison_test/server.conf4
-rw-r--r--TAO/tests/objref_comparison_test/server_cert.pem16
-rw-r--r--TAO/tests/objref_comparison_test/server_key.pem15
6 files changed, 188 insertions, 0 deletions
diff --git a/TAO/tests/objref_comparison_test/foo.idl b/TAO/tests/objref_comparison_test/foo.idl
new file mode 100644
index 00000000000..11ecffcf4c4
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/foo.idl
@@ -0,0 +1,3 @@
+interface foo {
+ boolean match_references ();
+};
diff --git a/TAO/tests/objref_comparison_test/main.cpp b/TAO/tests/objref_comparison_test/main.cpp
new file mode 100644
index 00000000000..39245167a57
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/main.cpp
@@ -0,0 +1,145 @@
+#include <iostream>
+#include <fstream>
+#include <tao/corba.h>
+#include <ace/Functor.h>
+#include <ace/Task.h>
+#include "fooS.h"
+
+/*
+ This isn't too complicated, but it is a little convoluted. So, here's the
+ explanation:
+
+ 1. Two threads. One thread is a CORBA server, the other a CORBA
+ client to that CORBA server.
+
+ 2. the main thread sets up the server-side stuff, and then fires off
+ a task to run the server.
+
+ 3. once the server thread/task is running, the main thread makes
+ invocations to "match_references()" and reports the outcome.
+
+ The CORBA Object compares the stringified representation of two IORs
+ both generated from the ORB but in different contexts, and returns the
+ result of the comparison as a boolean.
+ */
+
+class Foo_Impl : public virtual POA_foo
+{
+public:
+ CORBA::Boolean match_references ();
+
+ CORBA::String_var ior_from_main_;
+ ACE_Equal_To<const char*> equal_func;
+ ACE_Hash<const char*> hash_func;
+};
+
+CORBA::Boolean
+Foo_Impl::match_references ()
+{
+ CORBA::Object_var o = _this ();
+ CORBA::ORB_var orb = o->_get_orb ();
+ CORBA::String_var ior_from_upcall = orb->object_to_string (o);
+
+ CORBA::Boolean r1 = equal_func (this->ior_from_main_.in(), ior_from_upcall.in());
+#if 0
+ if (! r1)
+ {
+ std::ofstream f1("ior_from_main", std::ios::app);
+ f1 << ior_from_main_.in() << std::endl;
+
+ std::ofstream f2("ior_from_upcall", std::ios::app);
+ f2 << ior_from_upcall.in() << std::endl;
+ }
+#endif
+
+ return r1;
+}
+
+class Server_Task : public ACE_Task_Base
+{
+public:
+ Server_Task (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ {
+ }
+ virtual ~Server_Task ();
+
+ virtual int svc ();
+private:
+ CORBA::ORB_var orb_;
+};
+
+Server_Task::~Server_Task() { }
+
+int
+Server_Task::svc ()
+{
+ this->orb_->run ();
+ return 0;
+}
+
+int
+main (int argc, char * argv[])
+{
+ CORBA::ORB_var s_orb;
+ try
+ {
+ s_orb = CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var o = s_orb->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var rootpoa = PortableServer::POA::_narrow (o.in());
+ if (CORBA::is_nil (rootpoa.in()))
+ ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t): failed to get root poa\n"), 1);
+
+ PortableServer::POAManager_var poamgr = rootpoa->the_POAManager();
+
+ Foo_Impl* foo = 0;
+ ACE_NEW_RETURN (foo, Foo_Impl, 1);
+ PortableServer::ServantBase_var owner_transfer (foo);
+ PortableServer::ObjectId_var id = rootpoa->activate_object (foo);
+ o = rootpoa->id_to_reference (id.in());
+
+ Foo_Impl* foo2 = 0;
+ ACE_NEW_RETURN (foo2, Foo_Impl, 1);
+ PortableServer::ServantBase_var foo_owner (foo2);
+ foo_var f2 = foo2->_this (); // implicit activation
+
+ poamgr->activate ();
+
+ foo->ior_from_main_ = s_orb->object_to_string (o.in());
+ foo2->ior_from_main_ = foo->ior_from_main_;
+
+ Server_Task server(s_orb.in());
+ server.activate(1); // activate one thread running the task
+
+ foo_var f = foo::_narrow (o.in()); // ignore the possibility that
+ // it's not a 'foo' since we
+ // created it above
+
+ int const iterations = 10;
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) client: next %d iterations should match\n",
+ iterations));
+ for (int i = 0; i < iterations; ++i)
+ {
+ CORBA::Boolean b = f->match_references ();
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) client: iteration %d, match = %d\n",
+ i, b));
+ }
+
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) client: next %d iterations should NOT match\n",
+ iterations));
+ for (int i = 0; i < iterations; ++i)
+ {
+ CORBA::Boolean b = f2->match_references ();
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) client: iteration %d, match = %d\n",
+ i, b));
+ }
+
+ }
+ catch (...)
+ {
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/objref_comparison_test/objref_comparison_test.mpc b/TAO/tests/objref_comparison_test/objref_comparison_test.mpc
new file mode 100644
index 00000000000..23690b2be8c
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/objref_comparison_test.mpc
@@ -0,0 +1,5 @@
+project : taoserver {
+ Source_Files {
+ main.cpp
+ }
+}
diff --git a/TAO/tests/objref_comparison_test/server.conf b/TAO/tests/objref_comparison_test/server.conf
new file mode 100644
index 00000000000..e178933feb9
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/server.conf
@@ -0,0 +1,4 @@
+# $Id$
+
+dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLAuthenticate SERVER_AND_CLIENT -SSLPrivateKey PEM:server_key.pem -SSLCertificate PEM:server_cert.pem -SSLNoProtection"
+static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"
diff --git a/TAO/tests/objref_comparison_test/server_cert.pem b/TAO/tests/objref_comparison_test/server_cert.pem
new file mode 100644
index 00000000000..0fc394c24d7
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/server_cert.pem
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICgzCCAewCAQMwDQYJKoZIhvcNAQEEBQAwgYwxCzAJBgNVBAYTAlVTMQswCQYD
+VQQIEwJDQTEPMA0GA1UEBxMGSXJ2aW5lMRIwEAYDVQQKEwlET0MgR3JvdXAxEDAO
+BgNVBAsWB1VDSV9ET0MxETAPBgNVBAMTCFByaXlhbmthMSYwJAYJKoZIhvcNAQkB
+FhdwZ29udGxhQGRvYy5lY2UudWNpLmVkdTAeFw0wMTA2MTExNzQ4NTVaFw0xMTA2
+MDkxNzQ4NTVaMIGGMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExDzANBgNVBAcT
+BklydmluZTEMMAoGA1UEChMDT0NJMRAwDgYDVQQLEwdUQU8rT0NJMREwDwYDVQQD
+EwhQcml5YW5rYTEmMCQGCSqGSIb3DQEJARYXcGdvbnRsYUBkb2MuZWNlLnVjaS5l
+ZHUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANKXmudWiLVu/zdBlSr0/dlr
+pRe+Ie26cPyMo5lKiYNY77tABTiOXe5qLUEryjQ/fZ74gmBe4AYFwb7nu/f58X4A
+0tzSg2M4spWM7N4tzf+YbcUipRt9sEISxwfUxNNWTKnLxvCmkzOsISisukdzTkqJ
+fdzEcPfhO2BZKOdmlg1hAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAjUl3ami01tPY
+P1vMp2642dsIKLZis0TmeWp6HNpm52TbiGZOCqDrvtSQ9+2vGz0BkHvGqWKtD+wv
+zJH23fNnqFuzy1C1xtjoeqhXECTsWVTVdoEox8hSWxPiYRE2dioraZQQ5ENDosh+
+V9YcqJJpnKDUOSGVGuyaU7DpR8yK0pc=
+-----END CERTIFICATE-----
diff --git a/TAO/tests/objref_comparison_test/server_key.pem b/TAO/tests/objref_comparison_test/server_key.pem
new file mode 100644
index 00000000000..567a41da6dc
--- /dev/null
+++ b/TAO/tests/objref_comparison_test/server_key.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDSl5rnVoi1bv83QZUq9P3Za6UXviHtunD8jKOZSomDWO+7QAU4
+jl3uai1BK8o0P32e+IJgXuAGBcG+57v3+fF+ANLc0oNjOLKVjOzeLc3/mG3FIqUb
+fbBCEscH1MTTVkypy8bwppMzrCEorLpHc05KiX3cxHD34TtgWSjnZpYNYQIDAQAB
+AoGAC/TxpZrjLjH8KZ3+oy6/zv1upTd1Y7MHQT+W9lgmEKAXFHGhGkHzEVtT8HRV
+CbxlHIaNmH0qiQ0AoB82K/E0BdIMvE+y2qQwlpMfBMX6/TACORReJN3NXGsXwHP4
+/pNlS4LX7/NZbxlReAlDNP+FO8sdKZTyM3VXHFWJbmm4wsECQQD06zQ4uthp0zI9
+WTZiiAUgYwOcnLnXwfWOLAr8RCnYgwiS7MBCcmhZAgWX5SZJYVCwEJ12DAHy02NJ
+EhiSgo+JAkEA3B7PcS5FqZFi6wVjEG6yF8OuSb/rl+FZfV6utZdCVdMPxacEVxlD
+q7H/dk23O4WwASBriU0PR9/KG3T/LvKBGQJAaYRn1EUTdcxKqcmkt6CYbNKbvL59
+BqqGq4DoHrUTPjd92ybq0fXOZQKM/Fr6OsUVaTVPUYtsz3wpG1MTiRN82QJACX6+
+vggb8yuVU8QAuPW9cu769q1zsTKEVLcf3C9xKhiXppQEyOkLFT3xYh4KGGQ06meG
+m/6Z+SS7KCIM2+6UCQJBANHIzgxDWtrLuWJviNh9EbCsdMioxBH+LGaqFKLC70xD
+Pyoqn+QJQu/ekT+FUb0BeFJfGPzFjh1mFYn4tXxWqMs=
+-----END RSA PRIVATE KEY-----