summaryrefslogtreecommitdiff
path: root/TAO/tests
diff options
context:
space:
mode:
authormarina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-06-08 01:06:31 +0000
committermarina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-06-08 01:06:31 +0000
commitaed98ca00461b995980d71dd7a4ac1788ac704cf (patch)
treeb9bca5e83636962ac293561b4d960602721630d9 /TAO/tests
parentd7c947662ccd15255a6097e97a7172bac87bae86 (diff)
downloadATCD-aed98ca00461b995980d71dd7a4ac1788ac704cf.tar.gz
ChangeLogTag:Wed Jun 7 20:04:11 2000 Marina Spivak <marina@cs.wustl.edu>
Diffstat (limited to 'TAO/tests')
-rw-r--r--TAO/tests/ExposedPolicies/Client.cpp43
-rw-r--r--TAO/tests/ExposedPolicies/Counter.idl8
-rw-r--r--TAO/tests/ExposedPolicies/Counter_i.cpp14
-rw-r--r--TAO/tests/ExposedPolicies/Counter_i.h28
-rw-r--r--TAO/tests/ExposedPolicies/server.cpp48
5 files changed, 86 insertions, 55 deletions
diff --git a/TAO/tests/ExposedPolicies/Client.cpp b/TAO/tests/ExposedPolicies/Client.cpp
index 72bc193e144..3369db1c66c 100644
--- a/TAO/tests/ExposedPolicies/Client.cpp
+++ b/TAO/tests/ExposedPolicies/Client.cpp
@@ -2,11 +2,13 @@
#include "CounterC.h"
+// @@ Angelo, please name files consistently, i.e., you have
+// server.cpp, so this file should be client.cpp not Client.cpp
int
main (int argc, char *argv[])
{
ACE_DECLARE_NEW_CORBA_ENV;
-
+
ACE_TRY
{
@@ -14,40 +16,51 @@ main (int argc, char *argv[])
int argc = 1;
char * argv[] = {"RemoteEventDispatcher"};
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
+
+ // @@ Angelo, we don't need POA on the client. Also, make sure
+ // your comments are correct.
+
// Get Reference to the Naming Service
CORBA::Object_var object;
-
+
object = orb->resolve_initial_references("RootPOA", ACE_TRY_ENV);
ACE_TRY_CHECK;
-
- PortableServer::POA_var poa
+
+ PortableServer::POA_var poa
= PortableServer::POA::_narrow(object.in(), ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
// Get the POAManager
- PortableServer::POAManager_var poa_manager
+ PortableServer::POAManager_var poa_manager
= poa->the_POAManager(ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
// Activate the POAManager
poa_manager->activate(ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
object = orb->string_to_object ("file://ec.ior", ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
+ // @@ Angelo, you always need to check for error conditions in
+ // all your methods/invocations. Below you need to check that
+ // return value isn't nil, and use ACE_TRY_ENV to detect exceptions!
Counter_var counter = Counter::_narrow (object.in());
CORBA::ULong i;
-
+
for (i = 0; i < 10; i++)
counter->increment();
-
+ // @@ Angelo, make sure to always use ACE_TRY & friends to
+ // detect exception conditions, especially on idl method invocations.
+
cout << "The Counter Value is: " << counter->get_count() << endl;
-
+ // @@ Angelo, use ACE_DEBUG instead of cout.
+
TAO_Stub* stub = counter->_stubobj ();
TAO_Profile *profile = stub->next_profile ();
+ // Use <_get_policy> and friends methods that are defined on
+ // CORBA::Object to access the policies.
CORBA::PolicyList &policy_list = profile->policies ();
@@ -58,12 +71,12 @@ main (int argc, char *argv[])
}
- ACE_CATCHANY
+ ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "CORBA Excaption Raised");
return 1;
}
-
+
ACE_ENDTRY;
return 0;
diff --git a/TAO/tests/ExposedPolicies/Counter.idl b/TAO/tests/ExposedPolicies/Counter.idl
index 879a0e031ad..76815d61f02 100644
--- a/TAO/tests/ExposedPolicies/Counter.idl
+++ b/TAO/tests/ExposedPolicies/Counter.idl
@@ -1,11 +1,13 @@
//$Id$
-interface Counter {
-
+interface Counter
+{
void increment ();
void decrement ();
long get_count ();
void reset ();
-
+ // @@ Angelo, please don't use more code than you need to. For this
+ // test you only need one method, if that much.
};
+// @@ Angelo, please add README file.
diff --git a/TAO/tests/ExposedPolicies/Counter_i.cpp b/TAO/tests/ExposedPolicies/Counter_i.cpp
index 1b39b0c43be..c7babb8a120 100644
--- a/TAO/tests/ExposedPolicies/Counter_i.cpp
+++ b/TAO/tests/ExposedPolicies/Counter_i.cpp
@@ -2,22 +2,23 @@
#include "Counter_i.h"
+// @@ Angelo, please add rcsid string here.
// Dtor-Ctor Implementation
-CounterServant::CounterServant ( void ) : count_ (0)
+CounterServant::CounterServant ( void )
+ : count_ (0)
+ // @@ Angelo, remove extra spaces in paranthesis.
{
-
}
CounterServant::~CounterServant ( void )
{
-
}
// Counter Interface Methods Implementation
-
-void
+// @@ Angelo, please fix the class name.
+void
CounterServant::increment ( void )
{
++this->count_;
@@ -29,7 +30,7 @@ CounterServant::decrement ( void )
--this->count_;
}
-void
+void
CounterServant::reset ( void )
{
this->count_ = 0;
@@ -40,4 +41,3 @@ CounterServant::get_count ( void )
{
return this->count_;
}
-
diff --git a/TAO/tests/ExposedPolicies/Counter_i.h b/TAO/tests/ExposedPolicies/Counter_i.h
index 814ae1fa135..f092cb55a94 100644
--- a/TAO/tests/ExposedPolicies/Counter_i.h
+++ b/TAO/tests/ExposedPolicies/Counter_i.h
@@ -1,23 +1,27 @@
//$Id$
+// @@ Angelo, please put header with author, file name, etc. here.
+
#ifndef COUNTER_I_H_
#define COUNTER_I_H_
#include "CounterS.h"
-class CounterServant : public POA_Counter {
-
+class Counter_Servant : public POA_Counter
+{
public:
-
- // Ctor-Dtor Declaration
- CounterServant ( void );
- virtual ~CounterServant ( void );
-
- // Counter Interface Methods Overloading.
- virtual void increment ( void );
- virtual void decrement ( void );
- virtual void reset ( void );
- virtual CORBA::Long get_count ( void );
+
+ // = Ctor-Dtor Declaration
+
+ Counter_Servant (void);
+ virtual ~Counter_Servant (void);
+
+ // = Counter Interface Methods Overloading.
+
+ virtual void increment (void);
+ virtual void decrement (void);
+ virtual void reset (void);
+ virtual CORBA::Long get_count (void);
protected:
CORBA::Long count_;
diff --git a/TAO/tests/ExposedPolicies/server.cpp b/TAO/tests/ExposedPolicies/server.cpp
index d7eccacef9f..f59380625bb 100644
--- a/TAO/tests/ExposedPolicies/server.cpp
+++ b/TAO/tests/ExposedPolicies/server.cpp
@@ -8,44 +8,55 @@ int
main (int argc, char *argv[])
{
ACE_DECLARE_NEW_CORBA_ENV;
-
+
ACE_TRY
{
- // ORB Initialization
+ // ORB Initialization.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
CORBA::Object_var object;
-
+
object = orb->resolve_initial_references ("RootPoa", ACE_TRY_ENV);
ACE_CHECK;
-
- PortableServer::POA_var poa
+
+ PortableServer::POA_var poa
= PortableServer::POA::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
+ // @@ Remove after poa interface is supported.
TAO_POA *tao_poa = orb->orb_core ()->root_poa ();
- PortableServer::POAManager_var poa_manager
+ PortableServer::POAManager_var poa_manager
= poa->the_POAManager(ACE_TRY_ENV);
- ACE_TRY_CHECK
+ ACE_TRY_CHECK;
+ // @@ Angelo, activate when you are ready to receive requests.
poa_manager->activate (ACE_TRY_ENV);
ACE_TRY_CHECK;
RTCORBA::Priority priority = 256;
object = tao_poa->create_reference_with_priority ("IDL:Counter:1.0", priority);
-
- Counter_var counter = Counter::_narrow (object.in ());
+
+ // @@ Angelo, please create child poa with RT policies, and
+ // register two objects under it...
+ // Also, please include all the test code in the file, and just
+ // comment out what's not working at the moment.
+
+ Counter_var counter = Counter::_narrow (object.in ());
CounterServant servant;
counter = servant._this ();
-
+ // Angelo, use activate_object_with_priority instead of the
+ // things you are doing above. Then you can use
+ // poa->id_to_reference or something like that to obtain the
+ // object reference for your servant.
+
CORBA::String_var ior = orb->object_to_string (counter.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));
- FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
+ FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
@@ -53,16 +64,17 @@ main (int argc, char *argv[])
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
-
+
orb->run ();
+ // @@ Angelo, check if this method needs ACE_TRY_ENV argument.
}
-
- ACE_CATCHANY {
+
+ ACE_CATCHANY
+ {
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "CORBA Exception Raised.");
return 1;
}
ACE_ENDTRY;
-
+
return 0;
}
-