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.

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