1 //%2003////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //==============================================================================
26 // Author: Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
28 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
29 // (carolann_graves@hp.com)
31 //%/////////////////////////////////////////////////////////////////////////////
33 #include <Pegasus/Common/Config.h>
35 #include <Pegasus/Repository/CIMRepository.h>
36 #include <Pegasus/Client/CIMClient.h>
37 #include <Pegasus/Server/ProviderRegistrationManager/ProviderRegistrationManager.h>
39 PEGASUS_USING_PEGASUS;
42 const CIMNamespaceName NAMESPACE = CIMNamespaceName ("root/test");
43 const CIMName CLASSNAME = CIMName ("PG_ProviderModule");
44 const CIMName CLASSNAME2 = CIMName ("PG_Provider");
45 const CIMName CLASSNAME3 = CIMName ("PG_ProviderCapabilities");
47 Boolean TestLookupMethodProvider(ProviderRegistrationManager & prmanager)
51 // create Provider module instances
53 CIMObjectPath returnRef;
55 CIMClass cimClass(CLASSNAME);
57 CIMInstance cimInstance(CLASSNAME);
59 cimInstance.addProperty(CIMProperty(CIMName ("Name"),
60 String("providersModule1")));
61 cimInstance.addProperty(CIMProperty(CIMName ("Vendor"), String("HP")));
62 cimInstance.addProperty(CIMProperty(CIMName ("Version"), String("2.0")));
63 cimInstance.addProperty(CIMProperty(CIMName ("InterfaceType"),
64 String("PG_DefaultC++")));
65 cimInstance.addProperty(CIMProperty(CIMName ("InterfaceVersion"),
67 cimInstance.addProperty(CIMProperty(CIMName ("Location"),
68 String("/tmp/module1")));
70 CIMObjectPath instanceName = cimInstance.buildPath(cimClass);
72 instanceName.setNameSpace(NAMESPACE);
73 instanceName.setClassName(CLASSNAME);
77 returnRef = prmanager.createInstance(instanceName, cimInstance);
79 catch(CIMException& e)
84 // create PG_Provider instances
86 CIMObjectPath returnRef2;
88 CIMClass cimClass2(CLASSNAME2);
90 CIMInstance cimInstance2(CLASSNAME2);
92 cimInstance2.addProperty(CIMProperty(CIMName ("ProviderModuleName"),
93 String("providersModule1")));
94 cimInstance2.addProperty(CIMProperty(CIMName ("Name"),
95 String("PG_ProviderInstance1")));
97 CIMObjectPath instanceName2 = cimInstance2.buildPath(cimClass2);
99 instanceName2.setNameSpace(NAMESPACE);
100 instanceName2.setClassName(CLASSNAME2);
104 returnRef2 = prmanager.createInstance(instanceName2, cimInstance2);
106 catch(CIMException& e)
112 // create provider capability instances
115 Array <String> namespaces;
116 Array <Uint16> providerType;
117 Array <String> supportedMethods;
119 namespaces.append("test_namespace1");
120 namespaces.append("test_namespace2");
122 providerType.append(2);
123 providerType.append(5);
125 supportedMethods.append("test_method1");
126 supportedMethods.append("test_method2");
128 CIMObjectPath returnRef3;
130 CIMClass cimClass3(CLASSNAME3);
132 CIMInstance cimInstance3(CLASSNAME3);
134 cimInstance3.addProperty(CIMProperty(CIMName ("ProviderModuleName"),
135 String("providersModule1")));
136 cimInstance3.addProperty(CIMProperty(CIMName ("ProviderName"),
137 String("PG_ProviderInstance1")));
138 cimInstance3.addProperty(CIMProperty(CIMName ("CapabilityID"),
139 String("capability1")));
140 cimInstance3.addProperty(CIMProperty(CIMName ("ClassName"),
141 String("test_class1")));
142 cimInstance3.addProperty(CIMProperty(CIMName ("Namespaces"), namespaces));
143 cimInstance3.addProperty(CIMProperty(CIMName ("ProviderType"),
145 cimInstance3.addProperty(CIMProperty(CIMName ("SupportedMethods"),
148 CIMObjectPath instanceName3 = cimInstance3.buildPath(cimClass3);
150 instanceName3.setNameSpace(NAMESPACE);
151 instanceName3.setClassName(CLASSNAME3);
155 returnRef3 = prmanager.createInstance(instanceName3, cimInstance3);
157 catch(CIMException& e)
163 // test lookupMethodProvider Interface
165 String _providerModuleName;
166 String _providerModuleName2;
168 CIMInstance providerIns;
169 CIMInstance providerModuleIns;
171 if (prmanager.lookupMethodProvider(CIMNamespaceName ("test_namespace1"),
172 CIMName ("test_class1"), CIMName ("test_method2"),
173 providerIns, providerModuleIns))
175 providerIns.getProperty(providerIns.findProperty
176 (CIMName ("ProviderModuleName"))).getValue().get
177 (_providerModuleName);
179 providerModuleIns.getProperty(providerModuleIns.findProperty
180 (CIMName ("Name"))).getValue().get(_providerModuleName2);
182 if (String::equal(_providerModuleName, _providerModuleName2))
197 int main(int argc, char** argv)
199 const char* tmpDir = getenv ("PEGASUS_TMP");
200 String repositoryRoot;
203 repositoryRoot = ".";
207 repositoryRoot = tmpDir;
209 repositoryRoot.append("/repository");
210 CIMRepository r (repositoryRoot) ;
211 ProviderRegistrationManager prmanager(&r);
215 if (!TestLookupMethodProvider(prmanager))
217 PEGASUS_STD(cerr) << "Error: lookupMethodProvider Failed" << PEGASUS_STD(endl);
224 PEGASUS_STD(cerr) << "Error: " << e.getMessage() << PEGASUS_STD(endl);
225 PEGASUS_STD (cout) << "+++++ lookup method provider failed"
226 << PEGASUS_STD (endl);
230 PEGASUS_STD(cout) << "+++++ passed all tests" << PEGASUS_STD(endl);