Changeset 1425
- Timestamp:
- 04/02/08 17:18:13 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/branches/exp/kindlund-simpler_agent/lib/HoneyClient/Agent.pm
r1423 r1425 112 112 113 113 # Make sure the module loads properly, with the exportable 114 A115 114 # functions shared. 116 115 BEGIN { use_ok('HoneyClient::Agent') or diag("Can't load HoneyClient::Agent package. Check to make sure the package library is correctly listed within the path."); } … … 251 250 =begin testing 252 251 253 # XXX: Test init() method.254 252 our $URL = HoneyClient::Agent->init(); 255 253 our $PORT = getVar(name => "port", … … 309 307 my $pid = undef; 310 308 if ($pid = fork()) { 309 # Wait at least a second, in order to initialize the daemon. 310 sleep (1); 311 311 # We use a local variable to get the pid, and then we set the global 312 312 # DAEMON_PID variable after the fork(). This is intentional, because … … 314 314 # operation. 315 315 $DAEMON_PID = $pid; 316 $LOG->debug("Initializing Agent daemon at PID: " . $DAEMON_PID); 316 317 return $URL; 317 318 … … 357 358 =begin testing 358 359 359 # XXX: Test destroy() method.360 360 is(HoneyClient::Agent->destroy(), 1, "destroy()") or diag("Unable to terminate Agent SOAP server. Be sure to check for any stale or lingering processes."); 361 362 # TODO: delete this.363 #exit;364 361 365 362 =end testing … … 381 378 # the parent process... 382 379 if (defined($DAEMON_PID) && $DAEMON_PID) { 383 $LOG-> info("Destroying Agent daemon at PID: " . $DAEMON_PID);380 $LOG->debug("Destroying Agent daemon at PID: " . $DAEMON_PID); 384 381 385 382 # TODO: Need unit tests. … … 450 447 =back 451 448 452 #=begin testing 453 # 454 # XXX: Fill this in. 455 # 456 #=end testing 449 =begin testing 450 451 # Shared test variables. 452 my ($stub, $som, $URL); 453 454 # Catch all errors, in order to make sure child processes are 455 # properly killed. 456 eval { 457 458 $URL = HoneyClient::Agent->init(); 459 460 # Connect to daemon as a client. 461 $stub = getClientHandle(namespace => "HoneyClient::Agent", 462 address => "localhost"); 463 464 # Drive the Agent using IE. 465 $stub->drive(driver_name => "HoneyClient::Agent::Driver::Browser::IE", 466 parameters => "http://www.google.com"); 467 468 # Make sure the test VM is stopped. 469 #$som = $stub->stopVM(config => $testVM); 470 471 # Test isRegisteredVM() method. 472 #$som = $stub->isRegisteredVM(config => $testVM); 473 474 # The test VM should be registered. 475 #ok($som->result, "isRegisteredVM(config => '$testVM')") or diag("The isRegisteredVM() call failed. If ($testVM) is still registered, be sure to unregister it manually."); 476 477 # Make sure the test VM is unregistered. 478 #$som = $stub->unregisterVM(config => $testVM); 479 480 # Test isRegisteredVM() method. 481 #$som = $stub->isRegisteredVM(config => $testVM); 482 483 # The test VM should not be registered. 484 #ok(!$som->result, "isRegisteredVM(config => '$testVM')") or diag("The isRegisteredVM() call failed. If ($testVM) is still registered, be sure to unregister it manually."); 485 }; 486 487 # Kill the child daemon, if it still exists. 488 HoneyClient::Agent->destroy(); 489 490 # Report any failure found. 491 if ($@) { 492 fail($@); 493 } 494 495 =end testing 457 496 458 497 =cut honeyclient/branches/exp/kindlund-simpler_agent/t/honeyclient_agent.t
r751 r1425 30 30 use HoneyClient::Util::Config qw(getVar); 31 31 32 # TODO: Include FF33 # Make sure HoneyClient::Agent::Driver::Browser::IE loads.34 BEGIN { use_ok('HoneyClient::Agent::Driver::Browser::IE') or diag("Can't load HoneyClient::Agent::Driver::Browser::IE package. Check to make sure the package library is correctly listed within the path."); }35 require_ok('HoneyClient::Agent::Driver::Browser::IE');36 # TODO: Update this list of function names.37 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'new');38 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'drive');39 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'getNextLink');40 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'next');41 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'isFinished');42 can_ok('HoneyClient::Agent::Driver::Browser::IE', 'status');43 use HoneyClient::Agent::Driver::Browser::IE;44 45 32 # Make sure Storable loads. 46 33 BEGIN { use_ok('Storable', qw(freeze nfreeze thaw dclone)) or diag("Can't load Storable package. Check to make sure the package library is correctly listed within the path."); } … … 59 46 use MIME::Base64 qw(encode_base64 decode_base64); 60 47 61 #XXX: Check to see if the port number should be externalized. 48 # Make sure Win32::Job loads. 49 BEGIN { use_ok('Win32::Job') or diag("Can't load Win32::Job package. Check to make sure the package library is correctly listed within the path."); } 50 require_ok('Win32::Job'); 51 use Win32::Job; 52 62 53 # Global test variables. 63 54 our $PORT = getVar(name => "port", … … 70 61 # =begin testing 71 62 { 72 # XXX: Test init() method.73 63 our $URL = HoneyClient::Agent->init(); 74 64 our $PORT = getVar(name => "port", … … 83 73 # =begin testing 84 74 { 85 # XXX: Test destroy() method.86 75 is(HoneyClient::Agent->destroy(), 1, "destroy()") or diag("Unable to terminate Agent SOAP server. Be sure to check for any stale or lingering processes."); 76 } 87 77 88 # TODO: delete this. 89 #exit; 78 79 80 # =begin testing 81 { 82 # Shared test variables. 83 my ($stub, $som, $URL); 84 85 # Catch all errors, in order to make sure child processes are 86 # properly killed. 87 eval { 88 89 $URL = HoneyClient::Agent->init(); 90 91 # Connect to daemon as a client. 92 $stub = getClientHandle(namespace => "HoneyClient::Agent", 93 address => "localhost"); 94 95 # Drive the Agent using IE. 96 $stub->drive(driver_name => "HoneyClient::Agent::Driver::Browser::IE", 97 parameters => "http://www.google.com"); 98 99 # Make sure the test VM is stopped. 100 #$som = $stub->stopVM(config => $testVM); 101 102 # Test isRegisteredVM() method. 103 #$som = $stub->isRegisteredVM(config => $testVM); 104 105 # The test VM should be registered. 106 #ok($som->result, "isRegisteredVM(config => '$testVM')") or diag("The isRegisteredVM() call failed. If ($testVM) is still registered, be sure to unregister it manually."); 107 108 # Make sure the test VM is unregistered. 109 #$som = $stub->unregisterVM(config => $testVM); 110 111 # Test isRegisteredVM() method. 112 #$som = $stub->isRegisteredVM(config => $testVM); 113 114 # The test VM should not be registered. 115 #ok(!$som->result, "isRegisteredVM(config => '$testVM')") or diag("The isRegisteredVM() call failed. If ($testVM) is still registered, be sure to unregister it manually."); 116 }; 117 118 # Kill the child daemon, if it still exists. 119 HoneyClient::Agent->destroy(); 120 121 # Report any failure found. 122 if ($@) { 123 fail($@); 124 } 90 125 } 91 126 honeyclient/branches/exp/kindlund-simpler_agent/t/honeyclient_manager_database.t
r1282 r1425 78 78 use Data::Dumper; 79 79 80 # Make sure LWP::UserAgent loads. 81 BEGIN { use_ok('LWP::UserAgent') or diag("Can't load LWP::UserAgent package. Check to make sure the package library is correctly listed within the path."); } 82 require_ok('LWP::UserAgent'); 83 use LWP::UserAgent; 84 80 85 # Make sure Data::Structure::Util loads. 81 86 BEGIN { use_ok('Data::Structure::Util', qw(unbless)) or diag("Can't load Data::Structure::Util package. Check to make sure the package library is correctly listed within the path."); }
