10_invalid.t 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. # Net::ZooKeeper - Perl extension for Apache ZooKeeper
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. use File::Spec;
  19. use Test::More tests => 107;
  20. BEGIN { use_ok('Net::ZooKeeper', qw(:all)) };
  21. my $test_dir;
  22. (undef, $test_dir, undef) = File::Spec->splitpath($0);
  23. require File::Spec->catfile($test_dir, 'util.pl');
  24. my($hosts, $root_path, $node_path) = zk_test_setup(1);
  25. ## new()
  26. eval {
  27. Net::ZooKeeper->new();
  28. };
  29. like($@, qr/Usage: Net::ZooKeeper::new\(package, hosts, \.\.\.\)/,
  30. 'new(): no hostname specified');
  31. eval {
  32. Net::ZooKeeper->new($hosts, 'bar');
  33. };
  34. like($@, qr/invalid number of arguments/,
  35. 'new(): invalid number of arguments');
  36. eval {
  37. Net::ZooKeeper->new($hosts, 'session_timeout' => -3);
  38. };
  39. like($@, qr/invalid session timeout/,
  40. 'new(): invalid session timeout');
  41. eval {
  42. Net::ZooKeeper->new($hosts, 'session_timeout' => 0x4000_0000);
  43. };
  44. like($@, qr/invalid session timeout/,
  45. 'new(): invalid session timeout');
  46. eval {
  47. Net::ZooKeeper->new($hosts, 'session_id' => 'abcdef');
  48. };
  49. like($@, qr/invalid session ID/,
  50. 'new(): invalid session ID');
  51. my $zkh = Net::ZooKeeper->new($hosts);
  52. isa_ok($zkh, 'Net::ZooKeeper',
  53. 'new(): created handle');
  54. ## DESTROY()
  55. eval {
  56. $zkh->DESTROY('foo');
  57. };
  58. like($@, qr/Usage: Net::ZooKeeper::DESTROY\(zkh\)/,
  59. 'DESTROY(): too many arguments');
  60. my $bad_zkh = {};
  61. $bad_zkh = bless($bad_zkh, 'Net::ZooKeeper');
  62. my $ret = $bad_zkh->DESTROY();
  63. ok(!$ret,
  64. 'DESTROY(): no action on invalid handle');
  65. ## add_auth()
  66. eval {
  67. $zkh->add_auth();
  68. };
  69. like($@, qr/Usage: Net::ZooKeeper::add_auth\(zkh, scheme, cert\)/,
  70. 'add_auth(): no scheme specified');
  71. eval {
  72. $zkh->add_auth('foo');
  73. };
  74. like($@, qr/Usage: Net::ZooKeeper::add_auth\(zkh, scheme, cert\)/,
  75. 'add_auth(): no certificate specified');
  76. eval {
  77. $zkh->add_auth('foo', 'foo', 'bar');
  78. };
  79. like($@, qr/Usage: Net::ZooKeeper::add_auth\(zkh, scheme, cert\)/,
  80. 'add_auth(): too many arguments');
  81. eval {
  82. $bad_zkh->add_auth('foo', 'foo');
  83. };
  84. like($@, qr/invalid handle/,
  85. 'add_auth(): invalid handle');
  86. eval {
  87. Net::ZooKeeper::add_auth(1, 'foo', 'foo');
  88. };
  89. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  90. 'add_auth(): invalid hash reference');
  91. ## create()
  92. eval {
  93. $zkh->create();
  94. };
  95. like($@, qr/Usage: Net::ZooKeeper::create\(zkh, path, buf, \.\.\.\)/,
  96. 'create(): no path specified');
  97. eval {
  98. $zkh->create($node_path);
  99. };
  100. like($@, qr/Usage: Net::ZooKeeper::create\(zkh, path, buf, \.\.\.\)/,
  101. 'create(): no data buffer specified');
  102. eval {
  103. $zkh->create($node_path, 'foo', 'bar');
  104. };
  105. like($@, qr/invalid number of arguments/,
  106. 'create(): invalid number of arguments');
  107. eval {
  108. $zkh->create($node_path, 'foo', 'path_read_len' => -3);
  109. };
  110. like($@, qr/invalid path read length/,
  111. 'create(): invalid path read length');
  112. eval {
  113. $zkh->create($node_path, 'foo', 'path_read_len' => 1);
  114. };
  115. like($@, qr/invalid path read length/,
  116. 'create(): invalid path read length');
  117. eval {
  118. $zkh->create($node_path, 'foo', 'flags' => 15);
  119. };
  120. like($@, qr/invalid create flags/,
  121. 'create(): invalid create flags');
  122. eval {
  123. $zkh->create($node_path, 'foo', 'flags' => ZOO_EPHEMERAL, 'acl', 'foo');
  124. };
  125. like($@, qr/invalid ACL array reference/,
  126. 'create(): invalid ACL array reference');
  127. eval {
  128. $zkh->create($node_path, 'foo', 'acl', {});
  129. };
  130. like($@, qr/invalid ACL array reference/,
  131. 'create(): invalid ACL array reference to hash');
  132. eval {
  133. my @acl = ('foo', 'bar');
  134. $zkh->create($node_path, 'foo', 'acl', \@acl);
  135. };
  136. like($@, qr/invalid ACL entry hash reference/,
  137. 'create(): invalid ACL entry hash reference');
  138. eval {
  139. my @acl = ({ 'foo' => 'bar' });
  140. $zkh->create($node_path, 'foo', 'acl', \@acl);
  141. };
  142. like($@, qr/no ACL entry perms element/,
  143. 'create(): no ACL entry perms element');
  144. eval {
  145. my @acl = (
  146. {
  147. 'perms' => -1
  148. }
  149. );
  150. $zkh->create($node_path, 'foo', 'acl', \@acl);
  151. };
  152. like($@, qr/invalid ACL entry perms/,
  153. 'create(): invalid ACL entry perms');
  154. eval {
  155. my @acl = (
  156. {
  157. 'perms' => ZOO_PERM_ALL
  158. }
  159. );
  160. $zkh->create($node_path, 'foo', 'acl', \@acl);
  161. };
  162. like($@, qr/no ACL entry scheme element/,
  163. 'create(): no ACL entry scheme element');
  164. eval {
  165. my @acl = (
  166. {
  167. 'perms' => ZOO_PERM_ALL,
  168. 'scheme' => 'foo'
  169. }
  170. );
  171. $zkh->create($node_path, 'foo', 'acl', \@acl);
  172. };
  173. like($@, qr/no ACL entry id element/,
  174. 'create(): no ACL entry id element');
  175. eval {
  176. my @acl = (
  177. {
  178. 'perms' => ZOO_PERM_ALL,
  179. 'scheme' => 'foo',
  180. 'id' => 'bar'
  181. },
  182. 'bar'
  183. );
  184. $zkh->create($node_path, 'foo', 'acl', \@acl);
  185. };
  186. like($@, qr/invalid ACL entry hash reference/,
  187. 'create(): invalid second ACL entry hash reference');
  188. eval {
  189. $bad_zkh->create($node_path, 'foo');
  190. };
  191. like($@, qr/invalid handle/,
  192. 'create(): invalid handle');
  193. eval {
  194. Net::ZooKeeper::create(1, $node_path, 'foo');
  195. };
  196. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  197. 'create(): invalid hash reference');
  198. ## delete()
  199. eval {
  200. $zkh->delete();
  201. };
  202. like($@, qr/Usage: Net::ZooKeeper::delete\(zkh, path, \.\.\.\)/,
  203. 'delete(): no path specified');
  204. eval {
  205. $zkh->delete($node_path, 'bar');
  206. };
  207. like($@, qr/invalid number of arguments/,
  208. 'delete(): invalid number of arguments');
  209. eval {
  210. $zkh->delete($node_path, 'version' => -3);
  211. };
  212. like($@, qr/invalid version requirement/,
  213. 'delete(): invalid version requirement');
  214. eval {
  215. $bad_zkh->delete($node_path);
  216. };
  217. like($@, qr/invalid handle/,
  218. 'delete(): invalid handle');
  219. eval {
  220. Net::ZooKeeper::delete(1, $node_path);
  221. };
  222. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  223. 'delete(): invalid hash reference');
  224. ## exists()
  225. eval {
  226. $zkh->exists();
  227. };
  228. like($@, qr/Usage: Net::ZooKeeper::exists\(zkh, path, \.\.\.\)/,
  229. 'exists(): no path specified');
  230. eval {
  231. $zkh->exists($node_path, 'bar');
  232. };
  233. like($@, qr/invalid number of arguments/,
  234. 'exists(): invalid number of arguments');
  235. eval {
  236. $zkh->exists($node_path, 'watch', 'bar');
  237. };
  238. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  239. 'exists(): invalid watch hash reference');
  240. eval {
  241. $zkh->exists($node_path, 'watch', []);
  242. };
  243. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  244. 'exists(): invalid watch hash reference to array');
  245. eval {
  246. $zkh->exists($node_path, 'stat', 'bar');
  247. };
  248. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  249. 'exists(): invalid stat hash reference');
  250. eval {
  251. $zkh->exists($node_path, 'stat', []);
  252. };
  253. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  254. 'exists(): invalid stat hash reference');
  255. eval {
  256. $bad_zkh->exists($node_path);
  257. };
  258. like($@, qr/invalid handle/,
  259. 'exists(): invalid handle');
  260. eval {
  261. Net::ZooKeeper::exists(1, $node_path);
  262. };
  263. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  264. 'exists(): invalid hash reference');
  265. ## get_children()
  266. eval {
  267. $zkh->get_children();
  268. };
  269. like($@, qr/Usage: Net::ZooKeeper::get_children\(zkh, path, \.\.\.\)/,
  270. 'get_children(): no path specified');
  271. eval {
  272. $zkh->get_children($node_path, 'bar');
  273. };
  274. like($@, qr/invalid number of arguments/,
  275. 'get_children(): invalid number of arguments');
  276. eval {
  277. $zkh->get_children($node_path, 'watch', 'bar');
  278. };
  279. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  280. 'get_children(): invalid watch hash reference');
  281. eval {
  282. $zkh->get_children($node_path, 'watch', []);
  283. };
  284. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  285. 'get_children(): invalid watch ash reference to array');
  286. eval {
  287. $bad_zkh->get_children($node_path);
  288. };
  289. like($@, qr/invalid handle/,
  290. 'get_children(): invalid handle');
  291. eval {
  292. Net::ZooKeeper::get_children(1, $node_path);
  293. };
  294. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  295. 'get_children(): invalid hash reference');
  296. ## get()
  297. eval {
  298. $zkh->get();
  299. };
  300. like($@, qr/Usage: Net::ZooKeeper::get\(zkh, path, \.\.\.\)/,
  301. 'get(): no path specified');
  302. eval {
  303. $zkh->get($node_path, 'bar');
  304. };
  305. like($@, qr/invalid number of arguments/,
  306. 'get(): invalid number of arguments');
  307. eval {
  308. $zkh->get($node_path, 'data_read_len' => -3);
  309. };
  310. like($@, qr/invalid data read length/,
  311. 'get(): invalid data read length');
  312. eval {
  313. $zkh->get($node_path, 'data_read_len' => 10, 'watch', 'bar');
  314. };
  315. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  316. 'get(): invalid watch hash reference');
  317. eval {
  318. $zkh->get($node_path, 'watch', []);
  319. };
  320. like($@, qr/watch is not a hash reference of type Net::ZooKeeper::Watch/,
  321. 'get(): invalid watch hash reference to array');
  322. eval {
  323. $zkh->get($node_path, 'stat', 'bar');
  324. };
  325. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  326. 'get(): invalid stat hash reference');
  327. eval {
  328. $zkh->get($node_path, 'stat', []);
  329. };
  330. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  331. 'get(): invalid stat hash reference');
  332. eval {
  333. $bad_zkh->get($node_path);
  334. };
  335. like($@, qr/invalid handle/,
  336. 'get(): invalid handle');
  337. eval {
  338. Net::ZooKeeper::get(1, $node_path);
  339. };
  340. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  341. 'get(): invalid hash reference');
  342. ## set()
  343. eval {
  344. $zkh->set();
  345. };
  346. like($@, qr/Usage: Net::ZooKeeper::set\(zkh, path, buf, \.\.\.\)/,
  347. 'set(): no path specified');
  348. eval {
  349. $zkh->set($node_path);
  350. };
  351. like($@, qr/Usage: Net::ZooKeeper::set\(zkh, path, buf, \.\.\.\)/,
  352. 'set(): no data buffer specified');
  353. eval {
  354. $zkh->set($node_path, 'foo', 'bar');
  355. };
  356. like($@, qr/invalid number of arguments/,
  357. 'set(): invalid number of arguments');
  358. eval {
  359. $zkh->set($node_path, 'foo', 'version' => -3);
  360. };
  361. like($@, qr/invalid version requirement/,
  362. 'set(): invalid version requirement');
  363. eval {
  364. $zkh->set($node_path, 'foo', 'version', 0, 'stat', 'bar');
  365. };
  366. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  367. 'set(): invalid stat hash reference');
  368. eval {
  369. $zkh->set($node_path, 'foo', 'stat', []);
  370. };
  371. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  372. 'set(): invalid stat hash reference');
  373. eval {
  374. $bad_zkh->set($node_path, 'foo');
  375. };
  376. like($@, qr/invalid handle/,
  377. 'set(): invalid handle');
  378. eval {
  379. Net::ZooKeeper::set(1, $node_path, 'foo');
  380. };
  381. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  382. 'set(): invalid hash reference');
  383. ## get_acl()
  384. eval {
  385. $zkh->get_acl();
  386. };
  387. like($@, qr/Usage: Net::ZooKeeper::get_acl\(zkh, path, \.\.\.\)/,
  388. 'get_acl(): no path specified');
  389. eval {
  390. $zkh->get_acl($node_path, 'bar');
  391. };
  392. like($@, qr/invalid number of arguments/,
  393. 'get_acl(): invalid number of arguments');
  394. eval {
  395. $zkh->get_acl($node_path, 'stat', 'bar');
  396. };
  397. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  398. 'get_acl(): invalid stat hash reference');
  399. eval {
  400. $zkh->get_acl($node_path, 'stat', []);
  401. };
  402. like($@, qr/stat is not a hash reference of type Net::ZooKeeper::Stat/,
  403. 'get_acl(): invalid stat hash reference');
  404. eval {
  405. $bad_zkh->get_acl($node_path);
  406. };
  407. like($@, qr/invalid handle/,
  408. 'get_acl(): invalid handle');
  409. eval {
  410. Net::ZooKeeper::get_acl(1, $node_path);
  411. };
  412. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  413. 'get_acl(): invalid hash reference');
  414. ## set_acl()
  415. eval {
  416. $zkh->set_acl();
  417. };
  418. like($@, qr/Usage: Net::ZooKeeper::set_acl\(zkh, path, acl_arr, \.\.\.\)/,
  419. 'set_acl(): no path specified');
  420. eval {
  421. $zkh->set_acl($node_path);
  422. };
  423. like($@, qr/Usage: Net::ZooKeeper::set_acl\(zkh, path, acl_arr, \.\.\.\)/,
  424. 'set_acl(): no data buffer specified');
  425. eval {
  426. $zkh->set_acl($node_path, 'foo');
  427. };
  428. like($@, qr/acl_arr is not an array reference/i,
  429. 'set_acl(): invalid ACL array reference');
  430. eval {
  431. $zkh->set_acl($node_path, {});
  432. };
  433. like($@, qr/acl_arr is not an array reference/i,
  434. 'set_acl(): invalid ACL array reference to hash');
  435. eval {
  436. my @acl = ('foo', 'bar');
  437. $zkh->set_acl($node_path, \@acl);
  438. };
  439. like($@, qr/invalid ACL entry hash reference/,
  440. 'set_acl(): invalid ACL entry hash reference');
  441. eval {
  442. my @acl = ({ 'foo' => 'bar' });
  443. $zkh->set_acl($node_path, \@acl);
  444. };
  445. like($@, qr/no ACL entry perms element/,
  446. 'set_acl(): no ACL entry perms element');
  447. eval {
  448. my @acl = (
  449. {
  450. 'perms' => -1
  451. }
  452. );
  453. $zkh->set_acl($node_path, \@acl);
  454. };
  455. like($@, qr/invalid ACL entry perms/,
  456. 'set_acl(): invalid ACL entry perms');
  457. eval {
  458. my @acl = (
  459. {
  460. 'perms' => ZOO_PERM_ALL
  461. }
  462. );
  463. $zkh->set_acl($node_path, \@acl);
  464. };
  465. like($@, qr/no ACL entry scheme element/,
  466. 'set_acl(): no ACL entry scheme element');
  467. eval {
  468. my @acl = (
  469. {
  470. 'perms' => ZOO_PERM_ALL,
  471. 'scheme' => 'foo'
  472. }
  473. );
  474. $zkh->set_acl($node_path, \@acl);
  475. };
  476. like($@, qr/no ACL entry id element/,
  477. 'set_acl(): no ACL entry id element');
  478. eval {
  479. my @acl = (
  480. {
  481. 'perms' => ZOO_PERM_ALL,
  482. 'scheme' => 'foo',
  483. 'id' => 'bar'
  484. },
  485. 'bar'
  486. );
  487. $zkh->set_acl($node_path, \@acl);
  488. };
  489. like($@, qr/invalid ACL entry hash reference/,
  490. 'set_acl(): invalid second ACL entry hash reference');
  491. eval {
  492. $zkh->set_acl($node_path, [], 'bar');
  493. };
  494. like($@, qr/invalid number of arguments/,
  495. 'set_acl(): invalid number of arguments');
  496. eval {
  497. $zkh->set_acl($node_path, [], 'version' => -3);
  498. };
  499. like($@, qr/invalid version requirement/,
  500. 'set_acl(): invalid version requirement');
  501. eval {
  502. $bad_zkh->set_acl($node_path, []);
  503. };
  504. like($@, qr/invalid handle/,
  505. 'set_acl(): invalid handle');
  506. eval {
  507. Net::ZooKeeper::set_acl(1, $node_path, []);
  508. };
  509. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  510. 'set_acl(): invalid hash reference');
  511. ## stat()
  512. eval {
  513. $zkh->stat('bar');
  514. };
  515. like($@, qr/Usage: Net::ZooKeeper::stat\(zkh\)/,
  516. 'stat(): too many arguments');
  517. eval {
  518. $bad_zkh->stat();
  519. };
  520. like($@, qr/invalid handle/,
  521. 'stat(): invalid handle');
  522. eval {
  523. Net::ZooKeeper::stat(1);
  524. };
  525. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  526. 'stat(): invalid hash reference');
  527. my $stat = $zkh->stat();
  528. isa_ok($stat, 'Net::ZooKeeper::Stat',
  529. 'stat(): created stat handle');
  530. ## stat DESTROY()
  531. eval {
  532. $stat->DESTROY('foo');
  533. };
  534. like($@, qr/Usage: Net::ZooKeeper::Stat::DESTROY\(zksh\)/,
  535. 'stat DESTROY(): too many arguments');
  536. my $bad_stat = {};
  537. $bad_stat = bless($bad_stat, 'Net::ZooKeeper::Stat');
  538. $ret = $bad_stat->DESTROY();
  539. ok(!$ret,
  540. 'stat DESTROY(): no action on invalid handle');
  541. ## watch()
  542. eval {
  543. $zkh->watch('bar');
  544. };
  545. like($@, qr/invalid number of arguments/,
  546. 'watch(): invalid number of arguments');
  547. eval {
  548. $bad_zkh->watch();
  549. };
  550. like($@, qr/invalid handle/,
  551. 'watch(): invalid handle');
  552. eval {
  553. Net::ZooKeeper::watch(1);
  554. };
  555. like($@, qr/zkh is not a hash reference of type Net::ZooKeeper/,
  556. 'watch(): invalid hash reference');
  557. my $watch = $zkh->watch();
  558. isa_ok($watch, 'Net::ZooKeeper::Watch',
  559. 'watch(): created watch handle');
  560. ## watch DESTROY()
  561. eval {
  562. $watch->DESTROY('foo');
  563. };
  564. like($@, qr/Usage: Net::ZooKeeper::Watch::DESTROY\(zkwh\)/,
  565. 'watch DESTROY(): too many arguments');
  566. my $bad_watch = {};
  567. $bad_watch = bless($bad_watch, 'Net::ZooKeeper::Watch');
  568. $ret = $bad_watch->DESTROY();
  569. ok(!$ret,
  570. 'watch DESTROY(): no action on invalid handle');
  571. ## wait()
  572. eval {
  573. $watch->wait('bar');
  574. };
  575. like($@, qr/invalid number of arguments/,
  576. 'wait(): invalid number of arguments');
  577. eval {
  578. $bad_watch->wait();
  579. };
  580. like($@, qr/invalid handle/,
  581. 'wait(): invalid watch handle');
  582. eval {
  583. Net::ZooKeeper::Watch::wait(1);
  584. };
  585. like($@, qr/zkwh is not a hash reference of type Net::ZooKeeper::Watch/,
  586. 'wait(): invalid watch hash reference');
  587. ## set_log_level()
  588. eval {
  589. my $f = \&Net::ZooKeeper::set_log_level;
  590. &$f();
  591. };
  592. like($@, qr/Usage: Net::ZooKeeper::set_log_level\(level\)/,
  593. 'set_log_level(): no level specified');
  594. eval {
  595. my $f = \&Net::ZooKeeper::set_log_level;
  596. &$f(ZOO_LOG_LEVEL_OFF, 'foo');
  597. };
  598. like($@, qr/Usage: Net::ZooKeeper::set_log_level\(level\)/,
  599. 'set_log_level(): too many arguments');
  600. eval {
  601. Net::ZooKeeper::set_log_level((ZOO_LOG_LEVEL_OFF) - 1);
  602. };
  603. like($@, qr/invalid log level/,
  604. 'set_log_level(): invalid low log level');
  605. eval {
  606. Net::ZooKeeper::set_log_level((ZOO_LOG_LEVEL_DEBUG) + 1);
  607. };
  608. like($@, qr/invalid log level/,
  609. 'set_log_level(): invalid high log level');
  610. ## set_deterministic_conn_order()
  611. eval {
  612. my $f = \&Net::ZooKeeper::set_deterministic_conn_order;
  613. &$f();
  614. };
  615. like($@, qr/Usage: Net::ZooKeeper::set_deterministic_conn_order\(flag\)/,
  616. 'set_deterministic_conn_order(): no flag specified');
  617. eval {
  618. my $f = \&Net::ZooKeeper::set_deterministic_conn_order;
  619. &$f(1, 'foo');
  620. };
  621. like($@, qr/Usage: Net::ZooKeeper::set_deterministic_conn_order\(flag\)/,
  622. 'set_deterministic_conn_order(): too many arguments');