Example #1
0
 public function testConstructException()
 {
     $workingdir = getcwd();
     try {
         $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testSystemInvalid.xml');
         $this->assertTrue(false, 'It is invalid, should throw an exception');
     } catch (Xinc_Config_Exception_InvalidEntry $invalidEntry) {
         $this->assertTrue(true, 'Correct exception thrown');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should have caught ' . 'Xinc_Config_Exception_InvalidEntry ' . 'but caught: ' . get_class($e));
     }
 }
Example #2
0
 public function testNonEmpty()
 {
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testNonEmptySystem.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $settings = $parser->getConfigSettings();
     $this->assertTrue($settings->count() > 0, 'Settings should be detected');
     $plugins = $parser->getPlugins();
     $this->assertTrue($plugins->count() > 0, 'Plugins should be detected');
     $engines = $parser->getEngines();
     $this->assertTrue($engines->count() > 0, 'Engines should be detected');
 }
Example #3
0
 public function testNonEmpty()
 {
     return;
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testNonEmptySystem.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $plugins = $parser->getPlugins();
     $this->assertTrue($plugins->count() == 1, 'One plugin should be detected');
     $pluginParser = new Xinc_Plugin_Parser();
     $pluginParser->parse($plugins);
     $repository = Xinc_Plugin_Repository::getInstance();
     $plugins = $repository->getPlugins();
     $this->assertTrue($plugins->count() == 1, 'Should have one plugin');
 }
 public function testEngineCannotValidate()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testEngineCannotValidate.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
         $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), 'cannot load engine') !== false, 'We should have a log message about the engine not being able to load');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     try {
         $engine = Xinc_Engine_Repository::getInstance()->getEngine('SunriseCannotValidate');
         $this->assertTrue(false, 'Should throw an exception');
     } catch (Xinc_Engine_Exception_NotFound $e) {
         $this->assertTrue(true, 'Right Exception caught');
     } catch (Exception $pe) {
         $this->assertTrue(false, 'Should catch a NotFound exception but caught: ' . get_class($e));
     }
 }
Example #5
0
 /**
  * Set the plugin.xml file and parse it
  * to load the plugins and register the Widgets with the
  * Xinc_Gui_Widget_Repository
  *
  * @param string $fileName
  */
 private function setSystemConfigFile($fileName)
 {
     $fileName = realpath($fileName);
     try {
         //Xinc_Config::parse($fileName);
         $configFile = Xinc_Config_File::load($fileName);
         $configParser = new Xinc_Config_Parser($configFile);
         $plugins = $configParser->getPlugins();
         $pluginParser = new Xinc_Plugin_Parser();
         $pluginParser->parse($plugins);
         $widgets = Xinc_Gui_Widget_Repository::getInstance()->getWidgets();
         foreach ($widgets as $path => $widget) {
             Xinc_Logger::getInstance()->debug('Calling init on: ' . get_class($widget));
             $widget->init();
         }
         Xinc_Logger::getInstance()->debug('INIT calls done.');
         $configSettings = $configParser->getConfigSettings();
         while ($configSettings->hasNext()) {
             $setting = $configSettings->next();
             $attributes = $setting->attributes();
             $name = (string) $attributes->name;
             $value = (string) $attributes->value;
             if ($name == 'loglevel' && Xinc_Logger::getInstance()->logLevelSet()) {
                 $value = Xinc_Logger::getInstance()->getLogLevel();
             }
             $this->setConfigDirective($name, $value);
         }
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error('error parsing system:' . $e->getMessage());
     }
 }
Example #6
0
 public function testEngineRegistered()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testSystem.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     $engines = Xinc_Engine_Repository::getInstance()->getEngines();
     /**
      * Engines are registered by their name and classname
      * therefore we expect 2 engines
      */
     $this->assertEquals($engines->count(), 2, 'There should be a registered engine');
     $engine = Xinc_Engine_Repository::getInstance()->getEngine(Xinc_Engine_Sunrise::NAME);
     $this->assertTrue($engine instanceof Xinc_Engine_Sunrise, 'Engine should be a Xinc_engine_Sunrise');
 }