Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Transport_Cache_Manager / Bug_3558_Regression.cpp
blob27c5a224c321b758079cf18d0a53a8fdbda2afb7
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 5 tran
33 size_t const transport_max = 10;
34 size_t const cache_maximum = 5;
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 if (my_cache.current_size () != cache_maximum)
51 ACE_ERROR ((LM_ERROR, "ERROR Incorrect cache size %d\n", my_cache.current_size ()));
52 ++result;
55 orb->destroy ();
58 catch (const CORBA::Exception&)
60 // Ignore exceptions..
62 return result;