Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / TAO / tests / Dynamic_TP / POA_Loader / Test.cpp
blob9ebe6503e003ba01578622edb14a2ac9f9046f0d
1 #include "tao/Dynamic_TP/DTP_POA_Strategy.h"
2 #include "tao/CSD_Framework/CSD_Strategy_Repository.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/Service_Config.h"
6 #include "ace/Dynamic_Service.h"
7 #include <iostream>
8 #include "tao/debug.h"
10 void
11 show_tp_config (const ACE_CString &name, const TAO_DTP_Definition &entry)
13 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Config set for %C:\n"), name.c_str()));
14 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Initial threads: %d:\n"), entry.init_threads_));
15 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Min threads: %d:\n"), entry.min_threads_));
16 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Max threads: %d:\n"), entry.max_threads_));
17 if (entry.min_threads_ > -1)
18 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Idle Timeout: %d (sec)\n"), entry.timeout_.sec()));
19 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Stack Size: %d:\n"), entry.stack_size_));
20 ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Request queue max depth: %d\n"), entry.queue_depth_));
23 //void
24 //show_poa_config (const ACE_CString &name, TAO_DTP_POA_Strategy * strat)
25 //{
26 //ACE_DEBUG ((LM_INFO, ACE_TEXT ("POA [%C] has the configuration key [%C]\n"), name.c_str(),strat->get_tp_config().c_str()));
27 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Initial threads: %d:\n"), entry.init_threads_));
28 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Min threads: %d:\n"), entry.min_threads_));
29 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Max threads: %d:\n"), entry.max_threads_));
30 //if (entry.min_threads_ > -1)
31 // ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Idle Timeout: %d (sec)\n"), entry.timeout_));
32 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Stack Size: %d:\n"), entry.stack_size_));
33 //ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Request queue max depth: %d\n"), entry.queue_depth_));
34 //}
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 TAO_debug_level = 1;
41 ACE_Service_Config::open (argc, argv);
43 // Dump the POA to Strategy map
44 TAO_CSD_Strategy_Repository* dtp_poa_strat_repo =
45 ACE_Dynamic_Service<TAO_CSD_Strategy_Repository>::instance
46 ("TAO_CSD_Strategy_Repository");
48 if (dtp_poa_strat_repo == 0)
50 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Unable to load configuration\n")));
51 return -1;
53 else
55 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("TAO_CSD_Strategy_Repository found\n")));
59 // Now iterate through the repository and attempt to find sample POA configurations
61 const ACE_TCHAR *poa_list [] =
62 { ACE_TEXT ("MyPOA"), // should find this one
63 ACE_TEXT ("POA2"), // shouldn't find this one
64 ACE_TEXT ("MyPOA3"), // should find this one
65 ACE_TEXT ("MyPOA1"), // should find this one
69 TAO_DTP_POA_Strategy * mapped_strategy;
71 for (int i = 0; poa_list[i] != 0; i++)
73 mapped_strategy = 0;
74 ACE_DEBUG ((LM_INFO, ACE_TEXT("Config definition for %C\n"), poa_list[i]));
75 mapped_strategy = dynamic_cast <TAO_DTP_POA_Strategy*>
76 (dtp_poa_strat_repo->find (ACE_TEXT_ALWAYS_CHAR (poa_list[i])));
77 if ((mapped_strategy == 0) && (i != 1) && (i != 3))
79 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Cannot find TP Config definition for %C\n"), poa_list[i]));
80 continue;
82 if (i == 1 || i == 3)
84 if (mapped_strategy)
86 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Found TP Config definition for %C which should have failed\n"), poa_list[i]));
88 else
90 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Config definition for %C not found as expected\n"), poa_list[i]));
93 else
95 //show_poa_config (poa_list[i], mapped_strategy);
100 return 0;