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"
13 static int global_purged_count
= 0;
15 typedef TAO::Transport_Cache_Manager_T
<mock_transport
, mock_tdi
, mock_ps
> TCM
;
18 #include "mock_transport.h"
22 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
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;
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.
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
));
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 ()));
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 ()));
77 catch (const CORBA::Exception
&)
79 // Ignore exceptions..