Changeset 1425

Show
Ignore:
Timestamp:
04/02/08 17:18:13 (3 months ago)
Author:
kindlund
Message:

Updated initial unit tests for Agent.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-simpler_agent/lib/HoneyClient/Agent.pm

    r1423 r1425  
    112112 
    113113# Make sure the module loads properly, with the exportable 
    114 A 
    115114# functions shared. 
    116115BEGIN { 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."); } 
     
    251250=begin testing 
    252251 
    253 # XXX: Test init() method. 
    254252our $URL = HoneyClient::Agent->init(); 
    255253our $PORT = getVar(name      => "port",  
     
    309307    my $pid = undef; 
    310308    if ($pid = fork()) { 
     309        # Wait at least a second, in order to initialize the daemon. 
     310        sleep (1); 
    311311        # We use a local variable to get the pid, and then we set the global 
    312312        # DAEMON_PID variable after the fork().  This is intentional, because 
     
    314314        # operation. 
    315315        $DAEMON_PID = $pid; 
     316        $LOG->debug("Initializing Agent daemon at PID: " . $DAEMON_PID); 
    316317        return $URL; 
    317318    
     
    357358=begin testing 
    358359 
    359 # XXX: Test destroy() method. 
    360360is(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; 
    364361 
    365362=end testing 
     
    381378    # the parent process... 
    382379    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); 
    384381         
    385382        # TODO: Need unit tests. 
     
    450447=back 
    451448 
    452 #=begin testing 
    453 
    454 # XXX: Fill this in. 
    455 
    456 #=end testing 
     449=begin testing 
     450 
     451# Shared test variables. 
     452my ($stub, $som, $URL); 
     453 
     454# Catch all errors, in order to make sure child processes are 
     455# properly killed. 
     456eval { 
     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. 
     488HoneyClient::Agent->destroy(); 
     489 
     490# Report any failure found. 
     491if ($@) { 
     492    fail($@); 
     493
     494 
     495=end testing 
    457496 
    458497=cut 
  • honeyclient/branches/exp/kindlund-simpler_agent/t/honeyclient_agent.t

    r751 r1425  
    3030use HoneyClient::Util::Config qw(getVar); 
    3131 
    32 # TODO: Include FF 
    33 # 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  
    4532# Make sure Storable loads. 
    4633BEGIN { 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."); } 
     
    5946use MIME::Base64 qw(encode_base64 decode_base64); 
    6047 
    61 #XXX: Check to see if the port number should be externalized. 
     48# Make sure Win32::Job loads. 
     49BEGIN { 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."); } 
     50require_ok('Win32::Job'); 
     51use Win32::Job; 
     52 
    6253# Global test variables. 
    6354our $PORT = getVar(name      => "port", 
     
    7061# =begin testing 
    7162{ 
    72 # XXX: Test init() method. 
    7363our $URL = HoneyClient::Agent->init(); 
    7464our $PORT = getVar(name      => "port",  
     
    8373# =begin testing 
    8474{ 
    85 # XXX: Test destroy() method. 
    8675is(HoneyClient::Agent->destroy(), 1, "destroy()") or diag("Unable to terminate Agent SOAP server.  Be sure to check for any stale or lingering processes."); 
     76} 
    8777 
    88 # TODO: delete this. 
    89 #exit; 
     78 
     79 
     80# =begin testing 
     81
     82# Shared test variables. 
     83my ($stub, $som, $URL); 
     84 
     85# Catch all errors, in order to make sure child processes are 
     86# properly killed. 
     87eval { 
     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. 
     119HoneyClient::Agent->destroy(); 
     120 
     121# Report any failure found. 
     122if ($@) { 
     123    fail($@); 
     124
    90125} 
    91126 
  • honeyclient/branches/exp/kindlund-simpler_agent/t/honeyclient_manager_database.t

    r1282 r1425  
    7878use Data::Dumper; 
    7979 
     80# Make sure LWP::UserAgent loads. 
     81BEGIN { 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."); } 
     82require_ok('LWP::UserAgent'); 
     83use LWP::UserAgent; 
     84 
    8085# Make sure Data::Structure::Util loads. 
    8186BEGIN { 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."); }