Changeset 737

Show
Ignore:
Timestamp:
06/19/07 14:44:52 (1 year ago)
Author:
mikey
Message:

added possibility to configure interceptors depending on processors (fixes ticket #10)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/xml/processors.xml

    r447 r737  
    55  <defaultResolver default="xml"> 
    66    <pageFactory type="net.stubbles.websites.stubPageXJConfFactory" /> 
    7     <processor name="xml" type="net.stubbles.websites.xml.stubXMLProcessor" /> 
    8     <processor name="page" type="net.stubbles.websites.memphis.stubMemphisProcessor" /> 
    9     <processor name="jsonrpc" type="net.stubbles.websites.memphis.stubJsonRpcProcessor" /> 
     7    <processor name="xml" type="net.stubbles.websites.xml.stubXMLProcessor" interceptorDescriptor="interceptors" /> 
     8    <processor name="page" type="net.stubbles.websites.memphis.stubMemphisProcessor" interceptorDescriptor="interceptors" /> 
     9    <processor name="jsonrpc" type="net.stubbles.websites.memphis.stubJsonRpcProcessor" interceptorDescriptor="interceptors" /> 
    1010  </defaultResolver> 
    1111</xj:configuration> 
  • trunk/examples/config/xml/interceptors.xml

    r398 r737  
    33    xmlns:xj="http://xjconf.net/XJConf" 
    44    xmlns="http://stubbles.net/ipo/interceptors"> 
    5   <preInterceptors> 
    6     <preInterceptor type="net.stubbles.websites.xml.stubShowLastXMLInterceptor" /> 
    7   </preInterceptors> 
    8   <postInterceptors> 
    9     <postInterceptor type="net.stubbles.websites.xml.stubShowLastXMLInterceptor" /> 
    10     <postInterceptor type="net.stubbles.websites.xml.stubXMLPostInterceptor" /> 
    11   </postInterceptors> 
     5  <preInterceptors /> 
     6  <postInterceptors /> 
    127</xj:configuration> 
  • trunk/examples/config/xml/processors.xml

    r447 r737  
    55  <defaultResolver default="xml"> 
    66    <pageFactory type="net.stubbles.websites.stubPageXJConfFactory" /> 
    7     <processor name="xml" type="net.stubbles.websites.xml.stubXMLProcessor" /> 
    8     <processor name="page" type="net.stubbles.websites.memphis.stubMemphisProcessor" /> 
    9     <processor name="jsonrpc" type="net.stubbles.websites.memphis.stubJsonRpcProcessor" /> 
     7    <processor name="xml" type="net.stubbles.websites.xml.stubXMLProcessor" interceptorDescriptor="interceptors-xml" /> 
     8    <processor name="page" type="net.stubbles.websites.memphis.stubMemphisProcessor" interceptorDescriptor="interceptors" /> 
     9    <processor name="jsonrpc" type="net.stubbles.websites.memphis.stubJsonRpcProcessor" interceptorDescriptor="interceptors" /> 
    1010  </defaultResolver> 
    1111</xj:configuration> 
  • trunk/src/main/php/net/stubbles/ipo/interceptors/stubInterceptorInitializer.php

    r398 r737  
    2424     */ 
    2525    public function init(); 
    26      
     26 
     27    /** 
     28     * sets the descriptor that identifies the initializer 
     29     * 
     30     * @param  string  $descriptor 
     31     */ 
     32    public function setDescriptor($descriptor); 
     33 
    2734    /** 
    2835     * returns the list of pre interceptors 
     
    3138     */ 
    3239    public function getPreInterceptors(); 
    33      
     40 
    3441    /** 
    3542     * returns the list of post interceptors 
  • trunk/src/main/php/net/stubbles/ipo/interceptors/stubInterceptorXJConfInitializer.php

    r715 r737  
    88 */ 
    99stubClassLoader::load('net.stubbles.ipo.interceptors.stubInterceptorInitializer', 
    10                       'net.stubbles.util.xjconf.xjconf' 
     10                      'net.stubbles.util.xjconf.xjconf', 
     11                      'net.stubbles.util.exceptions.stubIllegalArgumentException' 
    1112); 
    1213/** 
     
    1920{ 
    2021    /** 
     22     * descriptor that identifies the initializer 
     23     * 
     24     * @var  string 
     25     */ 
     26    protected $descriptor       = 'interceptors'; 
     27    /** 
    2128     * list of pre interceptors 
    2229     * 
     
    3239 
    3340    /** 
    34      * returns the descriptor that identifies this initializer 
    35      * 
     41     * sets the descriptor that identifies this initializer 
     42     * 
     43     * @param  string  $descriptor 
     44     */ 
     45    public function setDescriptor($descriptor) 
     46    { 
     47        $this->descriptor = $descriptor; 
     48    } 
     49 
     50    /** 
     51     * returns the descriptor that identifies the initializer 
     52     * 
     53     * @param   string  $type  type of descriptor: config or definition 
    3654     * @return  string 
    37      */ 
    38     public function getDescriptor() 
    39     { 
    40         return 'interceptors'; 
     55     * @throws  stubIllegalArgumentException 
     56     */ 
     57    public function getDescriptor($type) 
     58    { 
     59        switch ($type) { 
     60            case stubXJConfInitializer::DESCRIPTOR_CONFIG: 
     61                return $this->descriptor; 
     62             
     63            case stubXJConfInitializer::DESCRIPTOR_DEFINITION: 
     64                return 'interceptors'; 
     65        } 
     66         
     67        throw new stubIllegalArgumentException('Invalid descriptor type.'); 
    4168    } 
    4269 
  • trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorXJConfFactory.php

    r585 r737  
    4848 
    4949    /** 
    50      * returns the descriptor that identifies this initializer 
     50     * returns the descriptor that identifies the initializer 
    5151     * 
     52     * @param   string  $type  type of descriptor: config or definition 
    5253     * @return  string 
    5354     */ 
    54     public function getDescriptor(
     55    public function getDescriptor($type
    5556    { 
    5657        return 'request'; 
  • trunk/src/main/php/net/stubbles/rdbms/stubDatabaseInitializer.php

    r584 r737  
    2020{ 
    2121    /** 
    22      * returns the descriptor that identifies this initializer 
     22     * returns the descriptor that identifies the initializer 
    2323     * 
     24     * @param   string  $type  type of descriptor: config or definition 
    2425     * @return  string 
    2526     */ 
    26     public function getDescriptor(
     27    public function getDescriptor($type
    2728    { 
    2829        return 'rdbms'; 
  • trunk/src/main/php/net/stubbles/util/log/stubLoggerXJConfFactory.php

    r584 r737  
    2121{ 
    2222    /** 
    23      * returns the descriptor that identifies this initializer 
     23     * returns the descriptor that identifies the initializer 
    2424     * 
     25     * @param   string  $type  type of descriptor: config or definition 
    2526     * @return  string 
    2627     */ 
    27     public function getDescriptor(
     28    public function getDescriptor($type
    2829    { 
    2930        return 'logging'; 
  • trunk/src/main/php/net/stubbles/util/stubRegistryXJConfInitializer.php

    r679 r737  
    3737 
    3838    /** 
    39      * returns the descriptor that identifies this initializer 
     39     * returns the descriptor that identifies the initializer 
    4040     * 
     41     * @param   string  $type  type of descriptor: config or definition 
    4142     * @return  string 
     43     * @throws  stubIllegalArgumentException 
    4244     */ 
    43     public function getDescriptor(
     45    public function getDescriptor($type
    4446    { 
    45         return $this->source; 
     47        switch ($type) { 
     48            case stubXJConfInitializer::DESCRIPTOR_CONFIG: 
     49                return $this->source; 
     50             
     51            case stubXJConfInitializer::DESCRIPTOR_DEFINITION: 
     52                return 'config'; 
     53        } 
     54         
     55        throw new stubIllegalArgumentException('Invalid descriptor type.'); 
    4656    } 
    4757 
  • trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfInitializer.php

    r584 r737  
    1818{ 
    1919    /** 
     20     * descriptor type: config 
     21     */ 
     22    const DESCRIPTOR_CONFIG     = 'config'; 
     23    /** 
     24     * descriptor type: definition 
     25     */ 
     26    const DESCRIPTOR_DEFINITION = 'definition'; 
     27 
     28    /** 
    2029     * returns the descriptor that identifies this initializer 
    2130     * 
     31     * @param   string  $type  type of descriptor: config or definition 
    2232     * @return  string 
     33     * @throws  stubIllegalArgumentException 
    2334     */ 
    24     public function getDescriptor(); 
     35    public function getDescriptor($type); 
    2536 
    2637    /** 
  • trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfProxy.php

    r584 r737  
    5353        } 
    5454         
    55         $this->configFile  = $configPath . '/' . $this->initializer->getDescriptor() . '.xml'; 
    56         $this->cacheFile   = $cachePath . '/' . $this->initializer->getDescriptor() . '.cache'; 
     55        $this->configFile  = $configPath . '/' . $this->initializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG) . '.xml'; 
     56        $this->cacheFile   = $cachePath . '/' . $this->initializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG) . '.cache'; 
    5757    } 
    5858 
     
    8686        stubClassLoader::load('net.stubbles.util.xjconf.xjconfReal'); 
    8787        $xjconf = new stubXJConfFacade(new XJConfFacade(array('__default' => stubXJConfLoader::getInstance()))); 
    88         $xjconf->addDefinitions(stubFactory::getResourceURIs('xjconf/' . $this->initializer->getDescriptor() . '.xml')); 
     88        $xjconf->addDefinitions(stubFactory::getResourceURIs('xjconf/' . $this->initializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION) . '.xml')); 
    8989        $xjconf->enableXIncludes(); 
    9090        foreach ($this->initializer->getExtensions() as $extension) { 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php

    r369 r737  
    4242     */ 
    4343    protected $pageFactory; 
     44    /** 
     45     * the interceptor descriptor 
     46     * 
     47     * @var  string 
     48     */ 
     49    protected $interceptorDescriptor = 'interceptors'; 
    4450 
    4551    /** 
     
    5864        $this->pageFactory = $pageFactory; 
    5965    } 
    60      
     66 
     67    /** 
     68     * sets the interceptor descriptor 
     69     * 
     70     * @param  string  $interceptorDescriptor 
     71     */ 
     72    public function setInterceptorDescriptor($interceptorDescriptor) 
     73    { 
     74        $this->interceptorDescriptor = $interceptorDescriptor; 
     75    } 
     76 
     77    /** 
     78     * returns the interceptor descriptor 
     79     * 
     80     * @return  string 
     81     */ 
     82    public function getInterceptorDescriptor() 
     83    { 
     84        return $this->interceptorDescriptor; 
     85    } 
     86 
    6187    /** 
    6288     * processes the request 
     
    6995        return $this; 
    7096    } 
    71      
     97 
    7298    /** 
    7399     * does the real processing 
     
    84110        return $this->response; 
    85111    } 
    86      
     112 
    87113    /** 
    88114     * retrieves the page name 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessorResolver.php

    r560 r737  
    3232        $this->pageFactory = $pageFactory; 
    3333    } 
    34      
     34 
    3535    /** 
    3636     * returns the page factory delivered within the constructor 
     
    6666        } 
    6767         
     68        $this->configureInterceptorDescriptor($processor); 
    6869        return $processor; 
    6970    } 
    70      
     71 
    7172    /** 
    7273     * does the real resolving work 
     
    7980     */ 
    8081    protected abstract function doResolve(stubRequest $request, stubSession $session, stubResponse $response); 
    81      
     82 
     83    /** 
     84     * configures the processor with the interceptor descriptor 
     85     * 
     86     * @param  stubProcessor  $processor 
     87     */ 
     88    protected abstract function configureInterceptorDescriptor(stubProcessor $processor); 
     89 
    8290    /** 
    8391     * ensure that all instances of stubSerializable are correctly serialized 
  • trunk/src/main/php/net/stubbles/websites/processors/stubDefaultProcessorResolver.php

    r557 r737  
    2424     * @var  string 
    2525     */ 
    26     protected $defaultProcessor = null; 
     26    protected $defaultProcessor       = null; 
    2727    /** 
    2828     * list of processors 
     
    3030     * @var  array<string,string> 
    3131     */ 
    32     protected $processors       = array(); 
     32    protected $processors             = array(); 
     33    /** 
     34     * list of interceptor descriptors 
     35     * 
     36     * @var  array<string,string> 
     37     */ 
     38    protected $interceptorDescriptors = array(); 
    3339 
    3440    /** 
    3541     * adds a processor to the list of available processors 
    3642     *  
    37      * @param  string  $paramValue   value of the request parameter that identifies this processor 
    38      * @param  string  $fqClassName  full qualified class name of the processor 
     43     * @param  string  $paramValue             value of the request parameter that identifies this processor 
     44     * @param  string  $fqClassName            full qualified class name of the processor 
     45     * @param  string  $interceptorDescriptor  the interceptor descriptor 
    3946     */ 
    40     public function addProcessor($paramValue, $fqClassName
     47    public function addProcessor($paramValue, $fqClassName, $interceptorDescriptor
    4148    { 
    42         $this->processors[$paramValue] = $fqClassName; 
     49        $this->processors[$paramValue]              = $fqClassName; 
     50        $this->interceptorDescriptors[$fqClassName] = $interceptorDescriptor; 
    4351    } 
    4452 
     
    8088        return $this->processors[$paramValue]; 
    8189    } 
     90 
     91    /** 
     92     * configures the processor with the interceptor descriptor 
     93     * 
     94     * @param  stubProcessor  $processor 
     95     */ 
     96    protected function configureInterceptorDescriptor(stubProcessor $processor) 
     97    { 
     98        if (isset($this->interceptorDescriptors[$processor->getClassName()]) == true && strlen($this->interceptorDescriptors[$processor->getClassName()]) > 0) { 
     99            $processor->setInterceptorDescriptor($this->interceptorDescriptors[$processor->getClassName()]); 
     100        } 
     101    } 
    82102} 
    83103?> 
  • trunk/src/main/php/net/stubbles/websites/processors/stubProcessor.php

    r315 r737  
    1818 * @subpackage  websites_processors 
    1919 */ 
    20 interface stubProcessor 
     20interface stubProcessor extends stubObject 
    2121{ 
    2222    /** 
     
    2929     */ 
    3030    #public function __construct(stubRequest $request, stubSession $session, , stubResponse $response, stubPageFactory $pageFactory); 
     31 
     32    /** 
     33     * sets the interceptor descriptor 
     34     * 
     35     * @param  string  $interceptorDescriptor 
     36     */ 
     37    public function setInterceptorDescriptor($interceptorDescriptor); 
     38 
     39    /** 
     40     * returns the interceptor descriptor 
     41     * 
     42     * @return  string 
     43     */ 
     44    public function getInterceptorDescriptor(); 
    3145 
    3246    /** 
  • trunk/src/main/php/net/stubbles/websites/processors/stubProcessorResolver.php

    r557 r737  
    1717 * Interface for processor resolvers. 
    1818 *  
    19  * @static 
    2019 * @package     stubbles 
    2120 * @subpackage  websites_processors 
  • trunk/src/main/php/net/stubbles/websites/processors/stubProcessorResolverXJConfFactory.php

    r584 r737  
    2626 
    2727    /** 
    28      * returns the descriptor that identifies this initializer 
     28     * returns the descriptor that identifies the initializer 
    2929     * 
     30     * @param   string  $type  type of descriptor: config or definition 
    3031     * @return  string 
    3132     */ 
    32     public function getDescriptor(
     33    public function getDescriptor($type
    3334    { 
    3435        return 'processors'; 
  • trunk/src/main/php/net/stubbles/websites/processors/stubSimpleProcessorResolver.php

    r557 r737  
    4545        return $this->processor; 
    4646    } 
     47 
     48    /** 
     49     * configures the processor with the interceptor descriptor 
     50     * 
     51     * @param  stubProcessor  $processor 
     52     */ 
     53    protected function configureInterceptorDescriptor(stubProcessor $processor) 
     54    { 
     55        $processor->setInterceptorDescriptor('interceptors'); 
     56    } 
    4757} 
    4858?> 
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r567 r737  
    3030    const SESSION_EVENT_NAME    = 'onSessionCreated'; 
    3131    /** 
    32      * list of interceptors to call at startup 
     32     * initializer for the interceptors 
    3333     * 
    34      * @var  array<stubPreInterceptor> 
     34     * @var  stubInterceptorInitializer 
    3535     */ 
    36     protected $preInterceptors  = array(); 
    37     /** 
    38      * list of interceptors to call at teardown 
    39      * 
    40      * @var  array<stubPostInterceptor> 
    41      */ 
    42     protected $postInterceptors = array(); 
     36    protected $interceptorInitializer  = array(); 
    4337    /** 
    4438     * the resolver to use for getting the correct processor 
     
    8377    { 
    8478        $registryInitializer->init(); 
    85         $interceptorInitializer->init(); 
    86         $this->preInterceptors  = $interceptorInitializer->getPreInterceptors(); 
    87         $this->postInterceptors = $interceptorInitializer->getPostInterceptors(); 
     79        $this->interceptorInitializer = $interceptorInitializer; 
    8880        $processorResolverFactory->init(); 
    8981        $this->resolver = $processorResolverFactory->getResolver(); 
     
    141133    public function process() 
    142134    { 
    143         foreach ($this->preInterceptors as $preInterceptor) { 
     135        $processor = $this->resolver->resolve($this->request, $this->session, $this->response); 
     136        $this->interceptorInitializer->setDescriptor($processor->getInterceptorDescriptor()); 
     137        $this->interceptorInitializer->init(); 
     138        foreach ($this->interceptorInitializer->getPreInterceptors() as $preInterceptor) { 
    144139            $preInterceptor->preProcess($this->request, $this->session, $this->response); 
    145140            if ($this->request->isCancelled() == true) { 
     
    149144        } 
    150145         
    151         $this->response = $this->resolver->resolve($this->request, $this->session, $this->response)->process()->getResponse(); 
     146        $this->response = $processor->process()->getResponse(); 
    152147        if ($this->request->isCancelled() == false) { 
    153             foreach ($this->postInterceptors as $postInterceptor) { 
     148            foreach ($this->interceptorInitializer->getPostInterceptors() as $postInterceptor) { 
    154149                $postInterceptor->postProcess($this->request, $this->session, $this->response); 
    155150                if ($this->request->isCancelled() == true) { 
  • trunk/src/main/php/net/stubbles/websites/variantmanager/stubVariantXJConfFactory.php

    r584 r737  
    3535 
    3636    /** 
    37      * returns the descriptor that identifies this initializer 
     37     * returns the descriptor that identifies the initializer 
    3838     * 
     39     * @param   string  $type  type of descriptor: config or definition 
    3940     * @return  string 
    4041     */ 
    41     public function getDescriptor(
     42    public function getDescriptor($type
    4243    { 
    4344        return 'variantmanager'; 
  • trunk/src/main/resources/xjconf/processors.xml

    r335 r737  
    77        <attribute name="name" type="string" /> 
    88        <attribute name="type" type="string" /> 
     9        <attribute name="interceptorDescriptor" type="string" /> 
    910      </methodCallTag> 
    1011    </tag> 
    1112    <tag name="simpleResolver" type="net.stubbles.websites.processors.stubSimpleProcessorResolver" key="resolver"> 
    1213      <attribute name="processor" type="string" /> 
     14      <attribute name="interceptorDescriptor" type="string" /> 
    1315    </tag> 
    1416    <abstractTag name="pageFactory" abstractType="net.stubbles.websites.stubPageFactory" concreteTypeAttribute="type" /> 
  • trunk/src/test/php/net/stubbles/ipo/interceptors/stubInterceptorXJConfInitializerTestCase.php

    r547 r737  
    7171    public function testDescriptor() 
    7272    { 
    73         $this->assertEqual($this->interceptorXJConfInitializer->getDescriptor(), 'interceptors'); 
     73        $this->assertEqual($this->interceptorXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'interceptors'); 
     74        $this->assertEqual($this->interceptorXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'interceptors'); 
     75        $this->interceptorXJConfInitializer->setDescriptor('foo'); 
     76        $this->assertEqual($this->interceptorXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'foo'); 
     77        $this->assertEqual($this->interceptorXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'interceptors'); 
     78        $this->expectException('stubIllegalArgumentException'); 
     79        $this->interceptorXJConfInitializer->getDescriptor('bar'); 
    7480    } 
    7581 
  • trunk/src/test/php/net/stubbles/rdbms/stubDatabaseInitializerTestCase.php

    r538 r737  
    5757    public function testDescriptor() 
    5858    { 
    59         $this->assertEqual($this->dbXJConfInitializer->getDescriptor(), 'rdbms'); 
     59        $this->assertEqual($this->dbXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'rdbms'); 
     60        $this->assertEqual($this->dbXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'rdbms'); 
    6061    } 
    6162 
  • trunk/src/test/php/net/stubbles/util/log/stubLoggerXJConfFactoryTestCase.php

    r562 r737  
    5959    public function testDescriptor() 
    6060    { 
    61         $this->assertEqual($this->loggerXJConfFactory->getDescriptor(), 'logging'); 
     61        $this->assertEqual($this->loggerXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'logging'); 
     62        $this->assertEqual($this->loggerXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'logging'); 
    6263    } 
    6364 
  • trunk/src/test/php/net/stubbles/util/stubRegistryXJConfInitializerTestCase.php

    r679 r737  
    4646    public function testDescriptor() 
    4747    { 
    48         $this->assertEqual($this->registryXJConfInitializer->getDescriptor(), 'config'); 
     48        $this->assertEqual($this->registryXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'config'); 
     49        $this->assertEqual($this->registryXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'config'); 
    4950        $this->registryXJConfInitializer->setConfigSource('test'); 
    50         $this->assertEqual($this->registryXJConfInitializer->getDescriptor(), 'test'); 
     51        $this->assertEqual($this->registryXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'test'); 
     52        $this->assertEqual($this->registryXJConfInitializer->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'config'); 
     53        $this->expectException('stubIllegalArgumentException'); 
     54        $this->registryXJConfInitializer->getDescriptor('bar'); 
    5155    } 
    5256 
  • trunk/src/test/php/net/stubbles/websites/TeststubFrontController.php

    r473 r737  
    1515class TeststubFrontController extends stubFrontController 
    1616{ 
    17     public function setPreInterceptors(array $preInterceptors) 
    18     { 
    19         $this->preInterceptors = $preInterceptors; 
    20     } 
    21      
    22     public function setPostInterceptors(array $postInterceptors) 
    23     { 
    24         $this->postInterceptors = $postInterceptors; 
    25     } 
    26  
    2717    public function setRequest(stubRequest $request) 
    2818    { 
  • trunk/src/test/php/net/stubbles/websites/processors/stubAbstractProcessorResolverTestCase.php

    r560 r737  
    1313Mock::generate('stubResponse'); 
    1414Mock::generate('stubSession'); 
    15 Mock::generatePartial('stubAbstractProcessorResolver', 'PartialMockstubAbstractProcessorResolver', array('doResolve')); 
     15Mock::generatePartial('stubAbstractProcessorResolver', 'PartialMockstubAbstractProcessorResolver', array('doResolve', 'configureInterceptorDescriptor')); 
    1616/** 
    1717 * Tests for net.stubbles.websites.processors.stubAbstractProcessorResolver 
  • trunk/src/test/php/net/stubbles/websites/processors/stubDefaultProcessorResolverTestCase.php

    r559 r737  
    6868    protected function addProcessors() 
    6969    { 
    70         $this->defaultProcessorResolver->addProcessor('foo', '_test.FooProcessor'); 
    71         $this->defaultProcessorResolver->addProcessor('bar', '_test.BarProcessor'); 
    72         $this->defaultProcessorResolver->addProcessor('baz', '_test.BazProcessor'); 
     70        $this->defaultProcessorResolver->addProcessor('foo', '_test.FooProcessor', 'interceptors-foo'); 
     71        $this->defaultProcessorResolver->addProcessor('bar', '_test.BarProcessor', 'interceptors-bar'); 
     72        $this->defaultProcessorResolver->addProcessor('baz', '_test.BazProcessor', 'interceptors-baz'); 
    7373        $this->defaultProcessorResolver->setDefaultProcessor('foo'); 
    7474    } 
  • trunk/src/test/php/net/stubbles/websites/processors/stubProcessorResolverXJConfFactoryTestCase.php

    r561 r737  
    3838    public function testDescriptor() 
    3939    { 
    40         $this->assertEqual($this->processorResolverXJConfFactory->getDescriptor(), 'processors'); 
     40        $this->assertEqual($this->processorResolverXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'processors'); 
     41        $this->assertEqual($this->processorResolverXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'processors'); 
    4142    } 
    4243 
  • trunk/src/test/php/net/stubbles/websites/stubFrontControllerProcessTestCase.php

    r580 r737  
    3333     */ 
    3434    protected $frontController; 
     35    /** 
     36     * mocked interceptor initializer 
     37     * 
     38     * @var  SimpleMock 
     39     */ 
     40    protected $mockInterceptorInitializer; 
    3541    /** 
    3642     * access to request 
     
    7884        $this->mockProcessorResolver  = new MockstubProcessorResolver(); 
    7985        $mockProcessorResolverFactory->setReturnValue('getResolver', $this->mockProcessorResolver); 
    80         $mockInterceptorInitializer = new MockstubInterceptorInitializer(); 
    81         $mockInterceptorInitializer->setReturnValue('getPreInterceptors', array()); 
    82         $mockInterceptorInitializer->setReturnValue('getPostInterceptors', array()); 
    83         $this->frontController = new TeststubFrontController(new MockstubRegistryInitializer(), $mockInterceptorInitializer, $mockProcessorResolverFactory); 
     86        $this->mockInterceptorInitializer = new MockstubInterceptorInitializer(); 
     87        $this->frontController = new TeststubFrontController(new MockstubRegistryInitializer(), $this->mockInterceptorInitializer, $mockProcessorResolverFactory); 
    8488        $this->mockRequest     = new MockstubRequest(); 
    8589        $this->frontController->setRequest($this->mockRequest); 
     
    104108        $preInterceptor2 = new MockstubPreInterceptor(); 
    105109        $preInterceptor2->expectNever('preProcess'); 
    106         $this->frontController->setPreInterceptors(array($preInterceptor1, $preInterceptor2)); 
     110        $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array($preInterceptor1, $preInterceptor2)); 
     111        $this->mockInterceptorInitializer->expectNever('getPostInterceptors'); 
    107112        $this->mockRequest->expectOnce('isCancelled'); 
    108113        $this->mockRequest->setReturnValue('isCancelled', true); 
    109114        $this->mockResponse->expectOnce('send'); 
    110         $this->mockProcessorResolver->expectNever('resolve'); 
     115        $this->mockProcessorResolver->expectOnce('resolve'); 
     116        $this->mockProcessor->expectOnce('getInterceptorDescriptor'); 
     117        $this->mockProcessor->setReturnValue('getInterceptorDescriptor', 'interceptors'); 
     118        $this->mockProcessor->expectNever('process'); 
    111119        $this->frontController->process(); 
    112120    } 
     
    121129        $postInterceptor2 = new MockstubPostInterceptor(); 
    122130        $postInterceptor2->expectNever('postProcess'); 
    123         $this->frontController->setPostInterceptors(array($postInterceptor1, $postInterceptor2)); 
     131        $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array()); 
     132        $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    124133        $this->mockRequest->expectOnce('isCancelled'); 
    125134        $this->mockRequest->setReturnValue('isCancelled', true); 
     
    138147        $postInterceptor2 = new MockstubPostInterceptor(); 
    139148        $postInterceptor2->expectNever('postProcess'); 
    140         $this->frontController->setPostInterceptors(array($postInterceptor1, $postInterceptor2)); 
     149        $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array()); 
     150        $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    141151        $this->mockRequest->expectCallcount('isCancelled', 2); 
    142152        $this->mockRequest->setReturnValueAt(0, 'isCancelled', false); 
     
    156166        $preInterceptor2 = new MockstubPreInterceptor(); 
    157167        $preInterceptor2->expectOnce('preProcess'); 
    158         $this->frontController->setPreInterceptors(array($preInterceptor1, $preInterceptor2)); 
     168        $this->mockInterceptorInitializer->setReturnValue('getPreInterceptors', array($preInterceptor1, $preInterceptor2)); 
    159169        $postInterceptor1 = new MockstubPostInterceptor(); 
    160170        $postInterceptor1->expectOnce('postProcess'); 
    161171        $postInterceptor2 = new MockstubPostInterceptor(); 
    162172        $postInterceptor2->expectOnce('postProcess'); 
    163         $this->frontController->setPostInterceptors(array($postInterceptor1, $postInterceptor2)); 
     173        $this->mockInterceptorInitializer->setReturnValue('getPostInterceptors', array($postInterceptor1, $postInterceptor2)); 
    164174        $this->mockRequest->setReturnValue('isCancelled', false); 
    165175        $this->mockResponse2->expectOnce('send'); 
  • trunk/src/test/php/net/stubbles/websites/variantmanager/stubVariantXJConfFactoryTestCase.php

    r551 r737  
    6666    public function testDescriptor() 
    6767    { 
    68         $this->assertEqual($this->variantXJConfFactory->getDescriptor(), 'variantmanager'); 
     68        $this->assertEqual($this->variantXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_CONFIG), 'variantmanager'); 
     69        $this->assertEqual($this->variantXJConfFactory->getDescriptor(stubXJConfInitializer::DESCRIPTOR_DEFINITION), 'variantmanager'); 
    6970    } 
    7071