summaryrefslogtreecommitdiff
path: root/cpp/test/IceBox/configuration/AllTests.cpp
blob: 4b5e3f5d8150a4738d412608c7b619e5e44aa880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>

using namespace std;
using namespace Test;

void
allTests(const Ice::CommunicatorPtr& communicator)
{
    TestIntfPrx service1 = TestIntfPrx::uncheckedCast(communicator->stringToProxy("test:tcp -p 12010"));
    TestIntfPrx service2 = TestIntfPrx::uncheckedCast(communicator->stringToProxy("test:tcp -p 12011"));
    TestIntfPrx service3 = TestIntfPrx::uncheckedCast(communicator->stringToProxy("test:tcp -p 12012"));
    TestIntfPrx service4 = TestIntfPrx::uncheckedCast(communicator->stringToProxy("test:tcp -p 12013"));

    if(service1->getProperty("IceBox.InheritProperties") == "")
    {
        cout << "testing service properties... " << flush;

        test(service1->getProperty("Ice.ProgramName") == "IceBox-Service1");
        test(service1->getProperty("Service") == "1");
        test(service1->getProperty("Service1.Ovrd") == "2");
        test(service1->getProperty("Service1.Unset") == "");
        test(service1->getProperty("Arg") == "1");

        Ice::StringSeq args1;
        args1.push_back("-a");
        args1.push_back("--Arg=2");
        test(service1->getArgs() == args1);

        test(service2->getProperty("Ice.ProgramName") == "Test");
        test(service2->getProperty("Service") == "2");
        test(service2->getProperty("Service1.ArgProp") == "");
        test(service2->getProperty("IceBox.InheritProperties") == "1");

        Ice::StringSeq args2;
        args2.push_back("--Service1.ArgProp=1");
        test(service2->getArgs() == args2);

        cout << "ok" << endl;

        cout << "testing with shared communicator... " << flush;

        test(service3->getProperty("Ice.ProgramName") == "IceBox-SharedCommunicator");
        test(service3->getProperty("Service") == "4");
        test(service3->getProperty("Prop") == "");
        test(service3->getProperty("Service3.Prop") == "1");
        test(service3->getProperty("Ice.Trace.Slicing") == "3");

        test(service4->getProperty("Ice.ProgramName") == "IceBox-SharedCommunicator");
        test(service4->getProperty("Service") == "4");
        test(service4->getProperty("Prop") == "");
        test(service4->getProperty("Service3.Prop") == "1");
        test(service4->getProperty("Ice.Trace.Slicing") == "3");

        Ice::StringSeq args4;
        args4.push_back("--Service3.Prop=2");
        test(service4->getArgs() == args4);

        cout << "ok" << endl;
    }
    else
    {
        cout << "testing property inheritance... " << flush;

        test(service1->getProperty("Ice.ProgramName") == "IceBox2-Service1");
        test(service1->getProperty("ServerProp") == "1");
        test(service1->getProperty("OverrideMe") == "2");
        test(service1->getProperty("UnsetMe") == "");
        test(service1->getProperty("Service1.Prop") == "1");
        test(service1->getProperty("Service1.ArgProp") == "2");

        test(service2->getProperty("Ice.ProgramName") == "IceBox2-SharedCommunicator");
        test(service2->getProperty("ServerProp") == "1");
        test(service2->getProperty("OverrideMe") == "3");
        test(service2->getProperty("UnsetMe") == "");
        test(service2->getProperty("Service2.Prop") == "1");

        cout << "ok" << endl;
    }
}