~ubuntu-branches/ubuntu/trusty/opendrim-lmp-ssh/trusty

« back to all changes in this revision

Viewing changes to test/testOpenDRIM_SSHSessionSettingData.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Guillaume BOTTEX
  • Date: 2010-07-07 11:04:10 UTC
  • Revision ID: james.westby@ubuntu.com-20100707110410-2bojrtqjp582wiy8
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*###############################################################################
 
2
# Linux Management Providers (LMP), SSH provider package
 
3
# Copyright (C) 2010 Feng Zhanlei, REDFLAG <fengzhanlei@redflag-linux.com>
 
4
 
5
# This program is being developed under the "OpenDRIM" project.
 
6
# The "OpenDRIM" project web page: http://opendrim.sourceforge.net
 
7
# The "OpenDRIM" project mailing list: opendrim@googlegroups.com
 
8
 
9
# This program is free software; you can redistribute it and/or
 
10
# modify it under the terms of the GNU General Public License
 
11
# as published by the Free Software Foundation; version 2
 
12
# of the License.
 
13
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program; if not, write to the Free Software
 
21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
22
#################################################################################
 
23
 
 
24
#################################################################################
 
25
# To contributors, please leave your contact information in this section
 
26
# AND comment your changes in the source code.
 
27
 
28
# Modified by Guillaume BOTTEX <guillaumebottex@uxsystem.net>, UXSystem, 2010
 
29
###############################################################################*/
 
30
 
 
31
#include "cmpiOpenDRIM_SSHSessionSettingData.h"
 
32
#include "OpenDRIM_SSHSessionSettingDataAccess.h"
 
33
 
 
34
#include <iostream>
 
35
 
 
36
#define ToString(name, value, condition) os << (string) "      " + name + (string) "="; instance.condition ? os << "NULL" : os << instance.value; os << endl
 
37
#define ToStringInt(name, value, condition) os << (string) "      " + name + (string) "="; instance.condition ? os << "NULL" : os << (long) instance.value; os << endl
 
38
#define ToStringRef(name, value, condition) os << (string) "      " + name + (string) "="; instance.condition ? os << "NULL" : os << instance.value.toString(); os << endl
 
39
#define ToStringArray(name, value, condition) os << (string) "      " + name + (string) "=["; for (size_t i = 0; i < instance.value.size(); i++) { os << instance.value[i]; if (i < instance.value.size()-1) os << ","; } os << "]" << endl
 
40
#define ToStringArrayInt(name, value, condition) os << (string) "      " + name + (string) "=["; for (size_t i = 0; i < instance.value.size(); i++) { os << (long) instance.value[i]; if (i < instance.value.size()-1) os << ","; } os << "]" << endl
 
41
#define ToStringRefArray(name, value, condition) os << (string) "      " + name + (string) "=["; for (size_t i = 0; i < instance.value.size(); i++) { os << instance.value[i].toString(); if (i < instance.value.size()-1) os << ","; } os << "]" << endl
 
42
 
 
43
ostream& operator<<(ostream& os, OpenDRIM_SSHSessionSettingData& instance) {
 
44
        os << "   [OpenDRIM_SSHSessionSettingData]" << endl;
 
45
        ToStringRef("ManagedElement", ManagedElement, ManagedElement_isNULL);
 
46
        ToStringRef("SettingData", SettingData, SettingData_isNULL);
 
47
        ToStringInt("IsDefault", IsDefault, IsDefault_isNULL);
 
48
        ToStringInt("IsCurrent", IsCurrent, IsCurrent_isNULL);
 
49
        ToStringInt("IsNext", IsNext, IsNext_isNULL);
 
50
        ToStringInt("IsMinimum", IsMinimum, IsMinimum_isNULL);
 
51
        ToStringInt("IsMaximum", IsMaximum, IsMaximum_isNULL);
 
52
        ToStringInt("IsPending", IsPending, IsPending_isNULL);
 
53
        os << "   [\\OpenDRIM_SSHSessionSettingData]" << endl;
 
54
        return os;
 
55
}
 
56
 
 
57
int main() {
 
58
        
 
59
        string errorMessage;
 
60
 
 
61
        int errorCode = SSH_OpenDRIM_SSHSessionSettingData_load(NULL, errorMessage);
 
62
        if (errorCode != OK) {
 
63
                cout << "ERROR " << errorCode << ": " << errorMessage << endl;
 
64
                return -1;
 
65
        }
 
66
 
 
67
        cout << endl << "[enumInstances]" << endl;
 
68
        vector<OpenDRIM_SSHSessionSettingData> instances;
 
69
        
 
70
        errorCode = SSH_OpenDRIM_SSHSessionSettingData_retrieve(NULL, NULL, instances, NULL, errorMessage, "ei");
 
71
        if (errorCode != OK) {
 
72
                cout << "ERROR " << errorCode << ": " << errorMessage << endl;
 
73
                return -1;
 
74
        }
 
75
        
 
76
        vector<OpenDRIM_SSHSessionSettingData>::iterator it = instances.begin();
 
77
        for (; it != instances.end(); ++it) {
 
78
                cout << *it;
 
79
        }
 
80
        
 
81
        cout << "[\\enumInstances]" << endl;
 
82
        cout << endl << "[enumInstanceNames & getInstance]" << endl;
 
83
        
 
84
        instances.clear();
 
85
        errorCode = SSH_OpenDRIM_SSHSessionSettingData_retrieve(NULL, NULL, instances, NULL, errorMessage, "ein");
 
86
        if (errorCode != OK) {
 
87
                cout << "ERROR " << errorCode << ": " << errorMessage << endl;
 
88
                return -1;
 
89
        }
 
90
        
 
91
        it = instances.begin();
 
92
        for (; it != instances.end(); ++it) {
 
93
                errorCode = SSH_OpenDRIM_SSHSessionSettingData_getInstance(NULL, NULL, *it, NULL, errorMessage);
 
94
                if (errorCode != OK) {
 
95
                        cout << "ERROR " << errorCode << ": " << errorMessage << endl;
 
96
                        return -1;
 
97
                }
 
98
                cout << *it;
 
99
        }
 
100
        
 
101
        cout << "[\\enumInstanceNames & getInstance]" << endl;
 
102
        cout << endl;
 
103
 
 
104
        errorCode = SSH_OpenDRIM_SSHSessionSettingData_unload(errorMessage);
 
105
        if (errorCode != OK) {
 
106
                cout << "ERROR " << errorCode << ": " << errorMessage << endl;
 
107
                return -1;
 
108
        }
 
109
        return 0;
 
110
}