Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / Transport_Cache_Manager / Bug_3549_Regression.cpp
blob1c81ed980bbc87adf0c566a5e79d7e265c3fed57
1 #include "ace/Get_Opt.h"
2 #include "ace/Argv_Type_Converter.h"
3 #include "ace/SString.h"
4 #include "ace/Manual_Event.h"
6 #include "tao/Transport_Cache_Manager_T.h"
7 #include "tao/ORB.h"
9 class mock_transport;
10 class mock_tdi;
11 class mock_ps;
13 static int global_purged_count = 0;
15 typedef TAO::Transport_Cache_Manager_T<mock_transport, mock_tdi, mock_ps> TCM;
17 #include "mock_tdi.h"
18 #include "mock_transport.h"
19 #include "mock_ps.h"
21 int
22 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
24 int result = 0;
26 try
28 // We need an ORB to get an ORB core
29 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
31 // We create 10 transports and have a max of 10 tran
33 size_t const transport_max = 10;
34 int cache_maximum = 10;
35 int purging_percentage = 20;
36 size_t i = 0;
37 mock_transport mytransport[transport_max];
38 mock_tdi mytdi[transport_max];
39 mock_ps* myps = new mock_ps(10);
40 TCM my_cache (purging_percentage, myps, cache_maximum, false, 0);
42 // Cache all transports in the cache
43 for (i = 0; i < transport_max; i++)
45 my_cache.cache_transport (&mytdi[i], &mytransport[i]);
46 mytransport[i].purging_order (i);
49 // Now purge the cache and see which one get removed. Only transport
50 // 0 and 1 should be purged in that order, 0 has the lowest purging
51 // count, 1 has the second lowest value.
52 my_cache.purge ();
54 for (i = 2; i < transport_max; i++)
56 if (mytransport[i].purged_count () != 0)
58 ACE_ERROR ((LM_ERROR, "ERROR Incorrect purged count %d for transport %d\n", mytransport[i].purged_count(), i));
59 ++result;
63 if (mytransport[0].purged_count () != 1)
65 ACE_ERROR ((LM_ERROR, "ERROR Incorrect purged count for transport 0: %d\n", mytransport[0].purged_count ()));
66 ++result;
69 if (mytransport[1].purged_count () != 2)
71 ACE_ERROR ((LM_ERROR, "ERROR Incorrect purged count for transport 1: %d\n", mytransport[1].purged_count ()));
72 ++result;
75 orb->destroy ();
77 catch (const CORBA::Exception&)
79 // Ignore exceptions..
81 return result;