Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

658 lines
13 KiB

  1. 'This script tests the ability to call "remoted" methods
  2. 'on a persisted and nonpersisted SWbemObject
  3. on error resume next
  4. testPassed = true
  5. WScript.Echo "************************************"
  6. WScript.Echo "PASS 1: Nonpersisted object "
  7. WScript.Echo "************************************"
  8. set obj = GetObject("winmgmts:root/default").Get
  9. set objSink = CreateObject ("WbemScripting.SWbemSink")
  10. WScript.Echo ""
  11. WScript.Echo "Associators_"
  12. set objAssoc = obj.Associators_
  13. if err <> 0 then
  14. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  15. err.clear
  16. else
  17. WScript.Echo "ERROR!"
  18. testPassed = false
  19. end if
  20. WScript.Echo ""
  21. WScript.Echo "AssociatorsAsync_"
  22. obj.AssociatorsAsync_ objSink
  23. if err <> 0 then
  24. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  25. err.clear
  26. else
  27. WScript.Echo "ERROR!"
  28. testPassed = false
  29. end if
  30. WScript.Echo ""
  31. WScript.Echo "Clone_"
  32. set objClone = obj.Clone_
  33. if err <> 0 then
  34. WScript.Echo "ERROR!"
  35. testPassed = false
  36. err.clear
  37. else
  38. WScript.Echo "Got No Error as expected - "
  39. end if
  40. WScript.Echo ""
  41. WScript.Echo "CompareTo_"
  42. set otherObj = GetObject ("winmgmts:root/default:__cimomidentification=@")
  43. bMatch = obj.CompareTo_ (otherObj)
  44. if err <> 0 then
  45. WScript.Echo "ERROR!"
  46. testPassed = false
  47. err.clear
  48. else
  49. WScript.Echo "Got No Error as expected - ", bMatch
  50. end if
  51. WScript.Echo ""
  52. WScript.Echo "Delete_"
  53. obj.Delete_
  54. if err <> 0 then
  55. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  56. err.clear
  57. else
  58. WScript.Echo "ERROR!"
  59. testPassed = false
  60. end if
  61. WScript.Echo ""
  62. WScript.Echo "DeleteAsync_"
  63. obj.DeleteAsync_ objSink
  64. if err <> 0 then
  65. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  66. err.clear
  67. else
  68. WScript.Echo "ERROR!"
  69. testPassed = false
  70. end if
  71. WScript.Echo ""
  72. WScript.Echo "ExecMethod_"
  73. obj.ExecMethod_ ("fred")
  74. if err <> 0 then
  75. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  76. err.clear
  77. else
  78. WScript.Echo "ERROR!"
  79. testPassed = false
  80. end if
  81. WScript.Echo ""
  82. WScript.Echo "ExecMethodAsync_"
  83. obj.ExecMethodAsync_ objSink, "fred"
  84. if err <> 0 then
  85. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  86. err.clear
  87. else
  88. WScript.Echo "ERROR!"
  89. testPassed = false
  90. end if
  91. WScript.Echo ""
  92. WScript.Echo "Derivation_"
  93. der = obj.Derivation_
  94. if err <> 0 then
  95. WScript.Echo "ERROR!"
  96. testPassed = false
  97. err.clear
  98. else
  99. WScript.Echo "Got No Error as expected - ", LBound(der), UBound(der)
  100. end if
  101. WScript.Echo ""
  102. WScript.Echo "Methods_"
  103. set methodSet = obj.Methods_
  104. if err <> 0 then
  105. WScript.Echo "ERROR!"
  106. testPassed = false
  107. err.clear
  108. else
  109. WScript.Echo "Got No Error as expected - ", methodSet.Count
  110. end if
  111. WScript.Echo ""
  112. WScript.Echo "Path_"
  113. set objPath = obj.Path_
  114. if err <> 0 then
  115. WScript.Echo "ERROR!"
  116. testPassed = false
  117. err.clear
  118. else
  119. WScript.Echo "Got No Error as expected - ", objPath.DisplayName
  120. end if
  121. WScript.Echo ""
  122. WScript.Echo "Properties_"
  123. set propSet = obj.Properties_
  124. if err <> 0 then
  125. WScript.Echo "ERROR!"
  126. testPassed = false
  127. err.clear
  128. else
  129. WScript.Echo "Got No Error as expected - ", propSet.Count
  130. end if
  131. WScript.Echo ""
  132. WScript.Echo "Qualifiers_"
  133. set qualSet = obj.Qualifiers_
  134. if err <> 0 then
  135. WScript.Echo "ERROR!"
  136. testPassed = false
  137. err.clear
  138. else
  139. WScript.Echo "Got No Error as expected - ", qualSet.Count
  140. end if
  141. WScript.Echo ""
  142. WScript.Echo "Security_"
  143. set security = obj.Security_
  144. if err <> 0 then
  145. WScript.Echo "ERROR!"
  146. testPassed = false
  147. err.clear
  148. else
  149. WScript.Echo "Got No Error as expected - ", security.authenticationLevel, security.impersonationLevel
  150. end if
  151. WScript.Echo ""
  152. WScript.Echo "GetObjectText_"
  153. objText = obj.GetObjectText_
  154. if err <> 0 then
  155. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  156. err.clear
  157. else
  158. WScript.Echo "ERROR!"
  159. testPassed = false
  160. end if
  161. WScript.Echo ""
  162. WScript.Echo "Instances_"
  163. set instanceSet = obj.Instances_
  164. if err <> 0 then
  165. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  166. err.clear
  167. else
  168. WScript.Echo "ERROR!"
  169. testPassed = false
  170. end if
  171. WScript.Echo ""
  172. WScript.Echo "InstancesAsync_"
  173. obj.InstancesAsync_ objSink
  174. if err <> 0 then
  175. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  176. err.clear
  177. else
  178. WScript.Echo "ERROR!"
  179. testPassed = false
  180. end if
  181. WScript.Echo ""
  182. WScript.Echo "Put_"
  183. set objPath = obj.Put_
  184. if err <> 0 then
  185. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  186. err.clear
  187. else
  188. WScript.Echo "ERROR!"
  189. testPassed = false
  190. end if
  191. WScript.Echo ""
  192. WScript.Echo "PutAsync_"
  193. obj.PutAsync_ objSink
  194. if err <> 0 then
  195. WScript.Echo "Got Error as expected"
  196. err.clear
  197. else
  198. WScript.Echo "ERROR!"
  199. testPassed = false
  200. end if
  201. WScript.Echo ""
  202. WScript.Echo "References_"
  203. set objSet = obj.References_
  204. if err <> 0 then
  205. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  206. err.clear
  207. else
  208. WScript.Echo "ERROR!"
  209. testPassed = false
  210. end if
  211. WScript.Echo ""
  212. WScript.Echo "ReferencesAsync_"
  213. obj.ReferencesAsync_ objSink
  214. if err <> 0 then
  215. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  216. err.clear
  217. else
  218. WScript.Echo "ERROR!"
  219. testPassed = false
  220. end if
  221. WScript.Echo ""
  222. WScript.Echo "SpawnDerivedClass_"
  223. set objSub = obj.SpawnDerivedClass_
  224. if err <> 0 then
  225. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  226. err.clear
  227. else
  228. WScript.Echo "ERROR!"
  229. testPassed = false
  230. end if
  231. WScript.Echo ""
  232. WScript.Echo "SpawnInstance_"
  233. set objSub = obj.SpawnInstance_
  234. if err <> 0 then
  235. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  236. err.clear
  237. else
  238. WScript.Echo "ERROR!"
  239. testPassed = false
  240. end if
  241. WScript.Echo ""
  242. WScript.Echo "Subclasses_"
  243. set objSet = obj.Subclasses_
  244. if err <> 0 then
  245. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  246. err.clear
  247. else
  248. WScript.Echo "ERROR!"
  249. testPassed = false
  250. end if
  251. WScript.Echo ""
  252. WScript.Echo "SubclassesAsync_"
  253. obj.SubclassesAsync_ objSink
  254. if err <> 0 then
  255. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  256. err.clear
  257. else
  258. WScript.Echo "ERROR!"
  259. testPassed = false
  260. end if
  261. if testPassed <> true then
  262. WScript.Echo ""
  263. WScript.Echo "*************************************"
  264. WScript.Echo "TEST FAILED!!!!!!!!!!!!!!!!!!!!!!!!!!"
  265. WScript.Echo "*************************************"
  266. else
  267. WScript.Echo ""
  268. WScript.Echo "*************************************"
  269. WScript.Echo "Test passed"
  270. WScript.Echo "*************************************"
  271. end if
  272. WScript.Echo "************************************"
  273. WScript.Echo "PASS 2: Persisted object "
  274. WScript.Echo "************************************"
  275. obj.Path_.Class = "TESTCLASSERR00"
  276. set Property = obj.Properties_.Add ("Fred", 19)
  277. Property.Qualifiers_.Add "key", true
  278. obj.Put_
  279. set obj = GetObject ("winmgmts:root/default:TESTCLASSERR00")
  280. if err <> 0 then
  281. WScript.Echo "ERROR! - ", Err.Description, Err.Number, Err.Source
  282. testPassed = false
  283. else
  284. WScript.Echo obj.Path_.RelPath
  285. end if
  286. WScript.Echo ""
  287. WScript.Echo "Associators_"
  288. set objAssoc = obj.Associators_
  289. if err <> 0 then
  290. WScript.Echo "ERROR!"
  291. testPassed = false
  292. err.clear
  293. else
  294. WScript.Echo "Got No Error as expected - "
  295. end if
  296. WScript.Echo ""
  297. WScript.Echo "AssociatorsAsync_"
  298. obj.AssociatorsAsync_ objSink
  299. if err <> 0 then
  300. WScript.Echo "ERROR!"
  301. testPassed = false
  302. err.clear
  303. else
  304. WScript.Echo "Got No Error as expected - "
  305. end if
  306. WScript.Echo ""
  307. WScript.Echo "Clone_"
  308. set objClone = obj.Clone_
  309. if err <> 0 then
  310. WScript.Echo "ERROR!"
  311. testPassed = false
  312. else
  313. WScript.Echo "Got No Error as expected - "
  314. err.clear
  315. end if
  316. WScript.Echo ""
  317. WScript.Echo "CompareTo_"
  318. set otherObj = GetObject ("winmgmts:root/default:__cimomidentification=@")
  319. bMatch = obj.CompareTo_ (otherObj)
  320. if err <> 0 then
  321. WScript.Echo "ERROR!"
  322. testPassed = false
  323. err.clear
  324. else
  325. WScript.Echo "Got No Error as expected - ", bMatch
  326. end if
  327. WScript.Echo ""
  328. WScript.Echo "ExecMethod_"
  329. obj.ExecMethod_ ("fred")
  330. if err <> 0 then
  331. WScript.Echo "Got Error as expected - ", Err.Description, Err.Number, Err.Source
  332. err.clear
  333. else
  334. WScript.Echo "ERROR!"
  335. testPassed = false
  336. end if
  337. WScript.Echo ""
  338. WScript.Echo "ExecMethodAsync_"
  339. obj.ExecMethodAsync_ objSink, "fred"
  340. if err <> 0 then
  341. WScript.Echo "ERROR!"
  342. testPassed = false
  343. err.clear
  344. else
  345. WScript.Echo "Got no error - as expected"
  346. end if
  347. WScript.Echo ""
  348. WScript.Echo "Derivation_"
  349. der = obj.Derivation_
  350. if err <> 0 then
  351. WScript.Echo "ERROR!"
  352. testPassed = false
  353. err.clear
  354. else
  355. WScript.Echo "Got No Error as expected - ", LBound(der), UBound(der)
  356. end if
  357. WScript.Echo ""
  358. WScript.Echo "Methods_"
  359. set methodSet = obj.Methods_
  360. if err <> 0 then
  361. WScript.Echo "ERROR!"
  362. testPassed = false
  363. err.clear
  364. else
  365. WScript.Echo "Got No Error as expected - ", methodSet.Count
  366. end if
  367. WScript.Echo ""
  368. WScript.Echo "Path_"
  369. set objPath = obj.Path_
  370. if err <> 0 then
  371. WScript.Echo "ERROR!"
  372. testPassed = false
  373. err.clear
  374. else
  375. WScript.Echo "Got No Error as expected - ", objPath.DisplayName
  376. end if
  377. WScript.Echo ""
  378. WScript.Echo "Properties_"
  379. set propSet = obj.Properties_
  380. if err <> 0 then
  381. WScript.Echo "ERROR!"
  382. testPassed = false
  383. err.clear
  384. else
  385. WScript.Echo "Got No Error as expected - ", propSet.Count
  386. end if
  387. WScript.Echo ""
  388. WScript.Echo "Qualifiers_"
  389. set qualSet = obj.Qualifiers_
  390. if err <> 0 then
  391. WScript.Echo "ERROR!"
  392. testPassed = false
  393. err.clear
  394. else
  395. WScript.Echo "Got No Error as expected - ", qualSet.Count
  396. end if
  397. WScript.Echo ""
  398. WScript.Echo "Security_"
  399. set security = obj.Security_
  400. if err <> 0 then
  401. WScript.Echo "ERROR!"
  402. testPassed = false
  403. err.clear
  404. else
  405. WScript.Echo "Got No Error as expected - ", security.authenticationLevel, security.impersonationLevel
  406. end if
  407. WScript.Echo ""
  408. WScript.Echo "GetObjectText_"
  409. objText = obj.GetObjectText_
  410. if err <> 0 then
  411. WScript.Echo "ERROR!"
  412. testPassed = false
  413. err.clear
  414. else
  415. WScript.Echo "Got No Error as expected - "
  416. end if
  417. WScript.Echo ""
  418. WScript.Echo "Instances_"
  419. set instanceSet = obj.Instances_
  420. if err <> 0 then
  421. WScript.Echo "ERROR!"
  422. testPassed = false
  423. err.clear
  424. else
  425. WScript.Echo "Got No Error as expected - "
  426. end if
  427. WScript.Echo ""
  428. WScript.Echo "InstancesAsync_"
  429. obj.InstancesAsync_ objSink
  430. if err <> 0 then
  431. WScript.Echo "ERROR!"
  432. testPassed = false
  433. err.clear
  434. else
  435. WScript.Echo "Got No Error as expected - "
  436. end if
  437. WScript.Echo ""
  438. WScript.Echo "Put_"
  439. set objPath = obj.Put_
  440. if err <> 0 then
  441. WScript.Echo "ERROR!"
  442. testPassed = false
  443. err.clear
  444. else
  445. WScript.Echo "Got No Error as expected - "
  446. end if
  447. WScript.Echo ""
  448. WScript.Echo "PutAsync_"
  449. obj.PutAsync_ objSink
  450. if err <> 0 then
  451. WScript.Echo "ERROR!"
  452. testPassed = false
  453. err.clear
  454. else
  455. WScript.Echo "Got no Error as expected"
  456. end if
  457. WScript.Echo ""
  458. WScript.Echo "References_"
  459. set objSet = obj.References_
  460. if err <> 0 then
  461. WScript.Echo "ERROR!"
  462. testPassed = false
  463. err.clear
  464. else
  465. WScript.Echo "Got No Error as expected - "
  466. end if
  467. WScript.Echo ""
  468. WScript.Echo "ReferencesAsync_"
  469. obj.ReferencesAsync_ objSink
  470. if err <> 0 then
  471. WScript.Echo "ERROR!"
  472. testPassed = false
  473. err.clear
  474. else
  475. WScript.Echo "Got No Error as expected - "
  476. end if
  477. WScript.Echo ""
  478. WScript.Echo "SpawnDerivedClass_"
  479. set objSub = obj.SpawnDerivedClass_
  480. if err <> 0 then
  481. WScript.Echo "ERROR!", Err.Number, Err.Description, Err.Source
  482. testPassed = false
  483. err.clear
  484. else
  485. WScript.Echo "Got No Error as expected - "
  486. end if
  487. WScript.Echo ""
  488. WScript.Echo "SpawnInstance_"
  489. set objSub = obj.SpawnInstance_
  490. if err <> 0 then
  491. WScript.Echo "ERROR!"
  492. testPassed = false
  493. err.clear
  494. else
  495. WScript.Echo "Got No Error as expected - "
  496. end if
  497. WScript.Echo ""
  498. WScript.Echo "Subclasses_"
  499. set objSet = obj.Subclasses_
  500. if err <> 0 then
  501. WScript.Echo "ERROR!"
  502. testPassed = false
  503. err.clear
  504. else
  505. WScript.Echo "Got No Error as expected - "
  506. end if
  507. WScript.Echo ""
  508. WScript.Echo "SubclassesAsync_"
  509. obj.SubclassesAsync_ objSink
  510. if err <> 0 then
  511. WScript.Echo "ERROR!"
  512. testPassed = false
  513. err.clear
  514. else
  515. WScript.Echo "Got No Error as expected - "
  516. end if
  517. WScript.Echo ""
  518. WScript.Echo "Delete_"
  519. obj.Delete_
  520. if err <> 0 then
  521. WScript.Echo "ERROR!"
  522. testPassed = false
  523. err.clear
  524. else
  525. WScript.Echo "No err as expected"
  526. end if
  527. obj.Put_
  528. WScript.Echo ""
  529. WScript.Echo "DeleteAsync_"
  530. obj.DeleteAsync_ objSink
  531. if err <> 0 then
  532. WScript.Echo "ERROR!"
  533. testPassed = false
  534. err.clear
  535. else
  536. WScript.Echo "Got No Error as expected"
  537. end if
  538. if testPassed <> true then
  539. WScript.Echo ""
  540. WScript.Echo "*************************************"
  541. WScript.Echo "TEST FAILED!!!!!!!!!!!!!!!!!!!!!!!!!!"
  542. WScript.Echo "*************************************"
  543. else
  544. WScript.Echo ""
  545. WScript.Echo "*************************************"
  546. WScript.Echo "Test passed"
  547. WScript.Echo "*************************************"
  548. end if