function test_start_stop_restart()
 {
     $this->test_register_service();
     //$this->assertFalse(Services::serviceRunning("DBHandler"));
     // start it!
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // stop it!
     $this->assertTrue(Services::stopService("DBHandler"));
     $this->assertFalse(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // restart it! (or, first start it, *then* restart it!)
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     $this->assertTrue(Services::restartService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
 }
 /**
  * The Require Service function checks for required service availability.
  * 
  * The function first checks for service availabilty, and then attempts to
  * start the service if it's available. If either action fails, it stops
  * script execution. If $start=false then the function will only check for 
  * availability.
  * @param string $name The name of the service.
  * @param boolean $start If we should attempt to start the service or not.
  * @access public
  * @static
  * @return ref object The started service object. (if start=true)
  * @deprecated 2004/07/28 Use {@link startManagerAsService()} and {@link getService()} instead.
  **/
 static function requireService($service, $start = true)
 {
     $backtrace = debug_backtrace();
     print "\n<br/><strong>Warning: Method call, Services::requireService(), is deprecated. Please use Services::startManagerAsService() and/or Services::getService() instead. ";
     print $backtrace[0]['file'] . " (Line " . $backtrace[0]['line'] . ")";
     print "</strong><br/>\n";
     $error = false;
     if (!Services::serviceAvailable($service)) {
         $error = true;
     } else {
         if ($start && !Services::serviceRunning($service) && !Services::startService($service)) {
             $error = true;
         }
     }
     if ($error) {
         // if we have the error Handler, throw a pretty error with that,
         // otherwise, use the die() function.
         if ($GLOBALS[SERVICES_OBJECT]->available('ErrorHandler')) {
             throwError(new Error("A required Service <b>\"{$service}\"</b> " . ($start ? "could not be started" : "is not available"), "Services", 1));
         } else {
             $debug = debug_backtrace();
             $str = "<B>FATAL ERROR</b><br /><br />";
             $str .= "A required Service <b>\"{$service}\"</b> ";
             $str .= $start ? "could not be started" : "is not available";
             $str .= ".<br /><br />\n";
             $str .= "<b>Debug backtrace:</b>\n";
             $str .= "<pre>\n";
             $str .= print_r($debug, true);
             $str .= "\n</pre>\n";
             die($str);
         }
     }
     if ($start) {
         return Services::getService($service);
     }
 }
Exemple #3
0
$timer = new Timer();
$timer->start();
$harmonyLoadupTimer = new Timer();
$harmonyLoadupTimer->start();
require_once dirname(__FILE__) . "/../../../../harmoni.inc.php";
$harmonyLoadupTimer->end();
require_once SIMPLE_TEST . 'simple_unit.php';
require_once SIMPLE_TEST . 'dobo_simple_html_test.php';
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
$errorHandler = Services::getService("ErrorHandler");
$dbHandler = Services::getService("DatabaseManager");
$dbIndex = $dbHandler->addDatabase(new MySQLDatabase("devo", "doboHarmoniTest", "test", "test"));
$dbHandler->pConnect($dbIndex);
Services::startService("Shared", $dbIndex, "doboHarmoniTest");
Services::startService("Hierarchy", $dbIndex, "doboHarmoniTest");
Services::startService("AuthN", $dbIndex, "doboHarmoniTest");
$errorHandler->setDebugMode(TRUE);
$test = new GroupTest('Authorization Tests');
$test->addTestFile(HARMONI . '/oki/authorization/tests/FunctionTestCase.class.php');
$test->addTestFile(HARMONI . '/oki/authorization/tests/QualifierTestCase.class.php');
$test->addTestFile(HARMONI . '/oki/authorization/tests/AuthorizationTestCase.class.php');
$test->addTestFile(HARMONI . '/oki/authorization/tests/AuthorizationManagerTestCase.class.php');
$test->attachObserver(new DoboTestHtmlDisplay());
$test->run();
$timer->end();
print "\n<br />Harmoni Load Time: " . $harmonyLoadupTimer->printTime();
print "\n<br />Overall Time: " . $timer->printTime();
print "\n</p>";
$num = $dbHandler->getTotalNumberOfQueries();
debug::output("Total # of queries: " . $num, 1, "DBHandler");
debug::printAll();