1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #include <Ice/Ice.h>
6 #include <TestHelper.h>
7 #include <Test.h>
8 
9 using namespace std;
10 using namespace Test;
11 
12 void
allTests(Test::TestHelper * helper)13 allTests(Test::TestHelper* helper)
14 {
15     Ice::CommunicatorPtr com = helper->communicator();
16     TestIntfPrxPtr service1 = ICE_UNCHECKED_CAST(TestIntfPrx, com->stringToProxy("test:" + helper->getTestEndpoint(0)));
17     TestIntfPrxPtr service2 = ICE_UNCHECKED_CAST(TestIntfPrx, com->stringToProxy("test:" + helper->getTestEndpoint(1)));
18     TestIntfPrxPtr service3 = ICE_UNCHECKED_CAST(TestIntfPrx, com->stringToProxy("test:" + helper->getTestEndpoint(2)));
19     TestIntfPrxPtr service4 = ICE_UNCHECKED_CAST(TestIntfPrx, com->stringToProxy("test:" + helper->getTestEndpoint(3)));
20 
21     if(service1->getProperty("IceBox.InheritProperties") == "")
22     {
23         cout << "testing service properties... " << flush;
24 
25         test(service1->getProperty("Ice.ProgramName") == "IceBox-Service1");
26         test(service1->getProperty("Service") == "1");
27         test(service1->getProperty("Service1.Ovrd") == "2");
28         test(service1->getProperty("Service1.Unset") == "");
29         test(service1->getProperty("Arg") == "1");
30 
31         Ice::StringSeq args1;
32         args1.push_back("-a");
33         args1.push_back("--Arg=2");
34         test(service1->getArgs() == args1);
35 
36         test(service2->getProperty("Ice.ProgramName") == "Test");
37         test(service2->getProperty("Service") == "2");
38         test(service2->getProperty("Service1.ArgProp") == "");
39         test(service2->getProperty("IceBox.InheritProperties") == "1");
40 
41         Ice::StringSeq args2;
42         args2.push_back("--Service1.ArgProp=1");
43         test(service2->getArgs() == args2);
44 
45         cout << "ok" << endl;
46 
47         cout << "testing with shared communicator... " << flush;
48 
49         test(service3->getProperty("Ice.ProgramName") == "IceBox-SharedCommunicator");
50         test(service3->getProperty("Service") == "4");
51         test(service3->getProperty("Prop") == "");
52         test(service3->getProperty("Service3.Prop") == "1");
53         test(service3->getProperty("Ice.Trace.Slicing") == "3");
54 
55         test(service4->getProperty("Ice.ProgramName") == "IceBox-SharedCommunicator");
56         test(service4->getProperty("Service") == "4");
57         test(service4->getProperty("Prop") == "");
58         test(service4->getProperty("Service3.Prop") == "1");
59         test(service4->getProperty("Ice.Trace.Slicing") == "3");
60 
61         Ice::StringSeq args4;
62         args4.push_back("--Service3.Prop=2");
63         test(service4->getArgs() == args4);
64 
65         cout << "ok" << endl;
66     }
67     else
68     {
69         cout << "testing property inheritance... " << flush;
70 
71         test(service1->getProperty("Ice.ProgramName") == "IceBox2-Service1");
72         test(service1->getProperty("ServerProp") == "1");
73         test(service1->getProperty("OverrideMe") == "2");
74         test(service1->getProperty("UnsetMe") == "");
75         test(service1->getProperty("Service1.Prop") == "1");
76         test(service1->getProperty("Service1.ArgProp") == "2");
77 
78         test(service2->getProperty("Ice.ProgramName") == "IceBox2-SharedCommunicator");
79         test(service2->getProperty("ServerProp") == "1");
80         test(service2->getProperty("OverrideMe") == "3");
81         test(service2->getProperty("UnsetMe") == "");
82         test(service2->getProperty("Service2.Prop") == "1");
83 
84         cout << "ok" << endl;
85     }
86 }
87