Changeset 416

Show
Ignore:
Timestamp:
03/23/07 16:27:50 (1 year ago)
Author:
mikey
Message:

added unit test for net.stubbles.util.log.stubLogDataFactory

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/log/stubLogDataFactory.php

    r359 r416  
    77 * @subpackage  util_log 
    88 */ 
     9stubClassLoader::load('net.stubbles.ipo.session.stubSession', 
     10                      'net.stubbles.util.log.stubLogData', 
     11                      'net.stubbles.util.log.stubLogger', 
     12                      'net.stubbles.util.stubRegistry' 
     13); 
    914/** 
    1015 * Factory to create log data objects. 
    1116 * 
     17 * @static 
    1218 * @package     stubbles 
    1319 * @subpackage  util_log 
    14  * @static 
    1520 */ 
    1621class stubLogDataFactory 
     
    1924     * creates a stubLogData object 
    2025     * 
    21      * @param   stubSession  $session  the session of the current user 
    22      * @param   string       $target   target where the log data should go to 
    23      * @param   int          $level    optional  log level of the log data 
     26     * @param   stubSession    $session  the session of the current user 
     27     * @param   string         $target   target where the log data should go to 
     28     * @param   int            $level    optional  log level of the log data 
    2429     * @return  stubLogData 
     30     * @throws  stubException  in case the created class is not an instance of stubLogData 
    2531     */ 
    2632    public static function create(stubSession $session, $target, $level = stubLogger::LEVEL_INFO) 
    2733    { 
    28         $class = stubRegistry::getConfig('net.stubbles.util.log.class', 'net.stubbles.util.log.stubBaseLogData'); 
    29         stubClassLoader::load($class); 
    30         $className = stubClassLoader::getNonQualifiedClassName($class); 
    31         $logData   = new $className($session, $target, $level); 
     34        $fqClassName = stubRegistry::getConfig('net.stubbles.util.log.class', 'net.stubbles.util.log.stubBaseLogData'); 
     35        $nqClassName = stubClassLoader::getNonQualifiedClassName($fqClassName); 
     36        if (class_exists($nqClassName, false) == false) { 
     37            stubClassLoader::load($fqClassName); 
     38        } 
     39         
     40        $logData = new $nqClassName($session, $target, $level); 
     41        if (($logData instanceof stubLogData) == false) { 
     42            throw new stubException('Configured net.stubbles.util.log.class is not an instance of stubLogData.'); 
     43        } 
     44         
    3245        return $logData; 
    3346    } 
  • trunk/src/test/php/net/stubbles/util/UtilTestSuite.php

    r415 r416  
    3333        $this->addTestFile($dir . '/log/stubFileLogAppenderTestCase.php'); 
    3434        $this->addTestFile($dir . '/log/stubBaseLogDataTestCase.php'); 
     35        $this->addTestFile($dir . '/log/stubLogDataFactoryTestCase.php'); 
    3536         
    3637        // now all the validators