cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [77/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/VirtualPipelineReaderTestCase.xconf
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/VirtualPipelineReaderTestCase.xconf?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/VirtualPipelineReaderTestCase.xconf (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/VirtualPipelineReaderTestCase.xconf Thu Nov  3 05:41:06 2005
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<cocoon version="2.2">
+
+  <include src="resource://org/apache/cocoon/cocoon.roles"/>
+
+  <xml-parser class="org.apache.excalibur.xml.impl.JaxpParser">
+    <parameter name="validate" value="false"/>
+    <parameter name="namespace-prefixes" value="false"/>
+    <parameter name="stop-on-warning" value="true"/>
+    <parameter name="stop-on-recoverable-error" value="true"/>
+    <parameter name="reuse-parsers" value="false"/>
+  </xml-parser>
+
+  <xmlizer/>
+
+  <input-modules>
+    <component-instance class="org.apache.cocoon.components.modules.input.EnvironmentAttributeModule" name="environment-attr"/>
+  </input-modules>
+
+  <source-factories>
+    <component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
+    <component-instance class="org.apache.cocoon.components.source.impl.ContextSourceFactory" name="context"/>
+    <component-instance class="org.apache.cocoon.components.source.impl.ModuleSourceFactory" name="module"/>
+    <component-instance class="org.apache.cocoon.components.source.impl.XModuleSourceFactory" name="xmodule"/>
+    <component-instance class="org.apache.excalibur.source.impl.FileSourceFactory" name="file"/>
+    <component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
+  </source-factories>
+
+  <!-- Relative sitemap path works during sitemap execution but
+       give exceptions during decommissioning -->
+  <sitemap file="resource://org/apache/cocoon/reading/vpc-sitemap.xmap"/>
+
+</cocoon>
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/VirtualPipelineReaderTestCase.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-sitemap.xmap?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-sitemap.xmap (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-sitemap.xmap Thu Nov  3 05:41:06 2005
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- SVN $Id$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+    <map:generators default="file">
+      <map:generator name="file" src="org.apache.cocoon.generation.FileGenerator"/>
+    </map:generators>
+
+    <map:transformers default="xslt">
+      <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
+        <xslt-processor-role>xalan</xslt-processor-role>
+      </map:transformer>
+    </map:transformers>
+
+    <map:serializers default="xml">
+      <map:serializer mime-type="text/xml" name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
+    </map:serializers>
+
+    <map:readers>
+      <map:reader name="virtual1" src="org.apache.cocoon.reading.VirtualPipelineReader">
+        <map:generate type="file" src="vpc-test.xml"/>
+        <map:serialize type="xml"/>
+      </map:reader>
+    </map:readers>
+
+    <map:matchers default="wildcard">
+      <map:matcher name="wildcard" src="org.apache.cocoon.matching.WildcardURIMatcher"/>
+    </map:matchers>
+
+    <map:pipes default="noncaching">
+      <map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline">
+      </map:pipe>
+    </map:pipes>
+  </map:components>
+
+  <map:pipelines>
+    <map:pipeline>
+
+      <map:match pattern="v1">
+        <map:read type="virtual1"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-test.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-test.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-test.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-test.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><test/>
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/reading/vpc-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,81 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class BrowserSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(BrowserSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple non-configured browser name test
+     */
+    public void testBrowserSelectMisconfigured() throws Exception {
+        final String userAgent = "Mozilla";
+        
+        getRequest().setHeader("User-Agent", userAgent );
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        result = this.select( "browser", "non-configured-browser-name", parameters );
+        System.out.println( result );
+        assertTrue( "Test is browser is a non-configured-browser-name", !result );
+    }
+
+    /**
+     * A simple netscape browser test
+     */
+    public void testBrowserSelectNetscape() throws Exception {
+        final String userAgent = "Mozilla";
+        String expectedBrowserName;
+        
+        getRequest().setHeader("User-Agent", userAgent );
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        expectedBrowserName = "netscape";
+        result = this.select( "browser", expectedBrowserName, parameters );
+        System.out.println(result);
+        assertTrue( "Test if browser is " + expectedBrowserName, result );
+        
+        expectedBrowserName = "explorer";
+        result = this.select( "browser", expectedBrowserName, parameters );
+        System.out.println( result );
+        assertTrue( "Test if browser is NOT " + expectedBrowserName, !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/BrowserSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,46 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.BrowserSelector" 
+                       name="browser">
+      <browser name="explorer" useragent="MSIE"/>
+      <browser name="pocketexplorer" useragent="MSPIE"/>
+      <browser name="handweb" useragent="HandHTTP"/>
+      <browser name="avantgo" useragent="AvantGo"/>
+      <browser name="imode" useragent="DoCoMo"/>
+      <browser name="opera" useragent="Opera"/>
+      <browser name="lynx" useragent="Lynx"/>
+      <browser name="java" useragent="Java"/>
+      <browser name="wap" useragent="Nokia"/>
+      <browser name="wap" useragent="UP"/>
+      <browser name="wap" useragent="Wapalizer"/>
+      <browser name="mozilla5" useragent="Mozilla/5"/>
+      <browser name="mozilla5" useragent="Netscape6/"/>
+      <browser name="netscape" useragent="Mozilla"/>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,116 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+import org.apache.cocoon.environment.mock.MockCookie;
+
+public class CookieSelectorTestCase extends SitemapComponentTestCase {
+
+    private final String COOKIE_SELECTOR = "cookie";
+    
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(CookieSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple cookie select test
+     */
+    public void testCookieSelect() throws Exception {
+        final String cookieName = "cookieSelectorTestCase";
+        final String cookieValue = "cookieValue";
+        // create a cookie
+        // setting name := cookieName, value := cookieValue
+        Map cookies = getRequest().getCookieMap();
+        MockCookie mockCookie = new MockCookie();
+        mockCookie.setName( cookieName);
+        mockCookie.setValue( cookieValue );
+        cookies.put( cookieName, mockCookie );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( COOKIE_SELECTOR, cookieValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a cookie is selected", result );
+        
+        // test selection failure
+        result = this.select( COOKIE_SELECTOR, "unknownCookieValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a cookie is not selected", !result );
+    }
+
+    /**
+     * A simple cookie select test
+     */
+    public void testCookieSelectUsingParameters() throws Exception {
+        final String cookieName = "cookieSelectorTestCase1";
+        final String cookieValue = "cookieValue";
+        
+        // create a cookie
+        // setting name := cookieName, value := cookieValue
+        Map cookies = getRequest().getCookieMap();
+        MockCookie mockCookie = new MockCookie();
+        // this cookie shall get selected
+        mockCookie.setName( cookieName);
+        mockCookie.setValue( cookieValue );
+        cookies.put( cookieName, mockCookie );
+        
+        // this cookie shall be ignored, as its name differs
+        // from the parameterized cookie name
+        mockCookie = new MockCookie();
+        mockCookie.setName( "cookieSelectorTestCase" );
+        mockCookie.setValue( "unknownCookieValue" );
+        cookies.put( "cookieSelectorTestCase", mockCookie );
+
+        // check the cookie as defined by this parameter, not as
+        // defined in the component configuration
+        Parameters parameters = new Parameters();
+        parameters.setParameter( "cookie-name", cookieName );
+        
+        boolean result;
+        
+        // test selection success
+        result = this.select( COOKIE_SELECTOR, cookieValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a cookie is selected", result );
+        
+        // test selection failure
+        result = this.select( COOKIE_SELECTOR, "unknownCookieValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a cookie is not selected", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/CookieSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.CookieSelector" 
+                       name="cookie">
+      <cookie-name>cookieSelectorTestCase</cookie-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,148 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.SitemapComponentTestCase;
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+public class ExceptionSelectorTestCase extends SitemapComponentTestCase {
+
+    private final String EXCEPTION_SELECTOR = "exception";    
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ExceptionSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple exception select test
+     */
+    public void testExceptionSelect() throws Exception {
+        
+        // create an exception
+        final java.lang.NullPointerException npe = new java.lang.NullPointerException( "ExceptionSelectorTestCase");
+
+        // put the exception into the objectModel
+        Map objectModel = this.getObjectModel();
+        objectModel.put( ObjectModelHelper.THROWABLE_OBJECT, npe );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( EXCEPTION_SELECTOR, "npe", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a npe is selected", result );
+        
+        // test selection failure
+        result = this.select( EXCEPTION_SELECTOR, "non-specified-exception", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a non specified exception is not selected", !result );
+    }
+
+    /**
+     * A simple exception select test
+     */
+    public void testExceptionSelectUnknownException() throws Exception {
+        
+        // create an exception
+        final java.lang.IllegalArgumentException iae = new IllegalArgumentException( "ExceptionSelectorTestCase");
+
+        // put the exception into the objectModel
+        Map objectModel = this.getObjectModel();
+        objectModel.put( ObjectModelHelper.THROWABLE_OBJECT, iae );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection failure
+        result = this.select( EXCEPTION_SELECTOR, "npe", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a npe is not selected selected", !result );
+    }
+    
+    /**
+     * A simple exception select test
+     * The causing exception is listed, thus selecting the unrolling
+     * exception fails, selecting the causing exception succeeds.
+     */
+    public void testExceptionSelectProcessingException() throws Exception {
+        
+        // create an exception
+        final java.lang.NullPointerException npe = new NullPointerException( "NullPointerExceptionSelectorTestCase" );
+        final ProcessingException pe = new ProcessingException( "ProcessingExceptionSelectorTestCase", npe );
+        
+        // put the exception into the objectModel
+        Map objectModel = this.getObjectModel();
+        objectModel.put( ObjectModelHelper.THROWABLE_OBJECT, pe );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( EXCEPTION_SELECTOR, "npe", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a npe is selected", result );
+        
+        // test selection failure
+        result = this.select( EXCEPTION_SELECTOR, "pe", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a pe is not selected", !result );
+    }
+    
+    /**
+     * A simple exception select test.
+     * The causing exception is not listed, thus matching the unrolling
+     * exception succeeds
+     */
+    public void testExceptionSelectProcessingException2() throws Exception {
+        
+        // create an exception
+        final java.lang.IllegalArgumentException iae = new IllegalArgumentException( "ExceptionSelectorTestCase");
+        final ProcessingException pe = new ProcessingException( "ProcessingExceptionSelectorTestCase", iae );
+        
+        // put the exception into the objectModel
+        Map objectModel = this.getObjectModel();
+        objectModel.put( ObjectModelHelper.THROWABLE_OBJECT, pe );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( EXCEPTION_SELECTOR, "pe", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a pe is not selected", result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ExceptionSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,35 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.ExceptionSelector" 
+                       name="exception">
+      <exception name="npe" class="java.lang.NullPointerException"/>
+      <exception name="not-found" class="org.apache.cocoon.ResourceNotFoundException"/>
+      <exception name="pe" class="org.apache.cocoon.ProcessingException" unroll="true"/>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,98 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class HeaderSelectorTestCase extends SitemapComponentTestCase {
+
+    private final String HEADER_SELECTOR = "header";
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(HeaderSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple header select test
+     */
+    public void testHeaderSelect() throws Exception {
+        final String headerName = "headerSelectorTestCase";
+        final String headerValue = "headerValue";
+        // create a header
+        // setting name := headerName, value := headerValue
+        getRequest().setHeader(headerName, headerValue);
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+
+        // test selection success
+        result = this.select( HEADER_SELECTOR, headerValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a header is selected", result );
+        
+        // test selection failure
+        result = this.select( HEADER_SELECTOR, "unknownHeaderValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a header is not selected", !result );
+    }
+
+    /**
+     * A simple header select test
+     */
+    public void testHeaderSelectUsingParameters() throws Exception {        
+        final String headerName = "headerSelectorTestCase1";
+        final String headerValue = "headerValue1";
+        // create a header
+        // setting name := headerName, value := headerValue
+        getRequest().setHeader(headerName, headerValue);
+
+        // check the header as defined by this parameter, not as
+        // defined in the component configuration
+        Parameters parameters = new Parameters();
+        parameters.setParameter( "header-name", headerName );
+        
+        boolean result;
+        
+        // test selection success
+        result = this.select( HEADER_SELECTOR, headerValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a header is selected", result );
+        
+        // test selection failure
+        result = this.select( HEADER_SELECTOR, "unknownHeaderValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a header is not selected", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HeaderSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.HeaderSelector" 
+                       name="header">
+      <header-name>headerSelectorTestCase</header-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,94 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class HostSelectorTestCase extends SitemapComponentTestCase {
+
+    private final String HOST_SELECTOR = "host";
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(HostSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple host selector test
+     */
+    public void testHostSelectEurope() throws Exception {
+        final String host = "myhost-dns-name-in-a-europe-country";
+        String expectedHostName;
+        
+        getRequest().setHeader("Host", host );
+        Parameters parameters = new Parameters();
+        boolean result;
+ 
+        // test selecting succeeds
+        expectedHostName = "myhost-eu";
+        result = this.select( HOST_SELECTOR, expectedHostName, parameters );
+        System.out.println(result);
+        assertTrue( "Test if host is " + expectedHostName, result );
+        
+        // test selecting fails
+        expectedHostName = "myhost-us";
+        result = this.select( HOST_SELECTOR, expectedHostName, parameters );
+        System.out.println(result);
+        assertTrue( "Test if host is not " + expectedHostName, !result );
+    }
+    
+    /**
+     * A simple host selector test
+     */
+    public void testHostSelectUnknownHost() throws Exception {
+        final String host = "myhost-dns-name-in-a-asia-country";
+        String expectedHostName;
+        
+        getRequest().setHeader("Host", host );
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selecting succeeds
+        expectedHostName = "myhost-eu";
+        result = this.select( HOST_SELECTOR, expectedHostName, parameters );
+        System.out.println(result);
+        assertTrue( "Test if host is not " + expectedHostName, !result );
+        
+        // test selecting fails
+        expectedHostName = "myhost-us";
+        result = this.select( HOST_SELECTOR, expectedHostName, parameters );
+        System.out.println(result);
+        assertTrue( "Test if host is not " + expectedHostName, !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/HostSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,34 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.HostSelector" 
+                       name="host">
+      <host name="myhost-eu" value="myhost-dns-name-in-a-europe-country"/>
+      <host name="myhost-us" value="myhost-dns-name-in-a-us-state"/>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,85 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class ParameterSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ParameterSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple parameter select test
+     */
+    public void testParameterSelect() throws Exception {
+        final String parameterName = "parameterSelectorTestCase";
+        
+        Parameters parameters = new Parameters();
+        parameters.setParameter( "parameter-selector-test", parameterName );
+        boolean result;
+        
+        // test selection success
+        result = this.select( "parameter", parameterName, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a parameter is selected", result );
+        
+        // test selection failure
+        result = this.select( "parameter", "unknownParameterName", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a parameter is not selected", !result );
+    }
+
+    /**
+     * A simple parameter select test
+     */
+    public void testParameterSelectUndefined() throws Exception {
+        final String parameterName = "parameterSelectorTestCase";
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection fails
+        result = this.select( "parameter", parameterName, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a parameter is not selected", !result );
+        
+        parameters.setParameter( "parameter-selector-test", "some-parameter-name" );
+        result = this.select( "parameter", parameterName, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a parameter is not selected", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ParameterSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.ParameterSelector" 
+                       name="parameter">
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,113 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+/**
+ * Test case for RegexpHeaderSelector.
+ * 
+ * @version CVS $Id: RegexpHeaderSelectorTestCase.java 124800 2005-01-10 14:34:31Z vgritsenko $
+ */
+public class RegexpHeaderSelectorTestCase extends SitemapComponentTestCase {
+
+    private final String REGEXP_HEADER_SELECTOR = "regexp-header";
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(RegexpHeaderSelectorTestCase.class);
+        return suite;
+    }
+    
+
+    /**
+     * A simple regexp-header selector test
+     */
+    public void testRegexpHeaderSelectEmpty() throws Exception {
+        // create a header
+        final String headerName = "headerSelectorTestCase";
+        getRequest().setHeader(headerName, "");
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        result = this.select( REGEXP_HEADER_SELECTOR, "empty", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " selects successfully", result );
+        
+        result = this.select( REGEXP_HEADER_SELECTOR, "number", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " does not select successfully", !result );
+        
+        result = this.select( REGEXP_HEADER_SELECTOR, "non-defined-name", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " does not select successfully", !result );
+    }
+
+    /**
+     * A simple regexp-header selector test
+     */
+    public void testRegexpHeaderSelectNumber() throws Exception {
+        // create a header
+        final String headerName = "headerSelectorTestCase";
+        final String headerName2 = "headerSelectorTestCase1";
+
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test w/o set request parameter
+        result = this.select( REGEXP_HEADER_SELECTOR, "empty", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " does not select successfully", !result );
+
+	// this time, set the header
+        getRequest().setHeader(headerName, "");
+
+	// create another header
+        getRequest().setHeader(headerName2, "123");
+
+        // override configured header name
+        parameters.setParameter( "header-name", headerName2 );
+        
+        result = this.select( REGEXP_HEADER_SELECTOR, "empty", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " does not select successfully", !result );
+
+        result = this.select( REGEXP_HEADER_SELECTOR, "number", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " selects successfully", result );
+
+        result = this.select( REGEXP_HEADER_SELECTOR, "non-defined-name", parameters );
+        System.out.println( result );
+        assertTrue( "Test is " + REGEXP_HEADER_SELECTOR + " does not select successfully", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpHeaderSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.RegexpHeaderSelector" 
+                       name="regexp-header">
+     <pattern name="empty">^$</pattern>
+      <pattern name="number">^[0-9]+$</pattern>
+      <pattern name="string">^.+$</pattern>
+      <header-name>headerSelectorTestCase</header-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,94 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class RegexpRequestParameterSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(RegexpRequestParameterSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A simple regexp-request-parameter selector test
+     */
+    public void testRegexpRequestParameterSelectEmpty() throws Exception {
+        // create a request parameter
+        getRequest().addParameter( "parameterRegexpRequestParameterSelector", "" );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        result = this.select( "regexp-request-parameter", "empty", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter selects successfully", result );
+        
+        result = this.select( "regexp-request-parameter", "number", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter does not select successfully", !result );
+        
+        result = this.select( "regexp-request-parameter", "non-defined-name", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter does not select successfully", !result );
+    }
+
+    /**
+     * A simple regexp-request-parameter selector test
+     */
+    public void testRegexpRequestParameterSelectNumber() throws Exception {
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test w/o set request parameter
+        result = this.select( "regexp-request-parameter", "number", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter does not select successfully", !result );
+        
+        // create a request parameter
+        getRequest().addParameter( "parameterRegexpRequestParameterSelector1", "123" );
+
+        // override configured parameter name
+        parameters.setParameter( "parameter-name", "parameterRegexpRequestParameterSelector1" );
+        
+        result = this.select( "regexp-request-parameter", "number", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter does not selects successfully", result );
+
+        result = this.select( "regexp-request-parameter", "non-defined-name", parameters );
+        System.out.println( result );
+        assertTrue( "Test is regexp-request-parameter does not select successfully", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RegexpRequestParameterSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.RegexpRequestParameterSelector" 
+                       name="regexp-request-parameter">
+      <pattern name="empty">^$</pattern>
+      <pattern name="number">^[0-9]+$</pattern>
+      <pattern name="string">^.+$</pattern>
+      <parameter-name>parameterRegexpRequestParameterSelector</parameter-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,92 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class RequestAttributeSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(RequestAttributeSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A request-attribute parameter select test
+     */
+    public void testRequestAttributeSelect() throws Exception {
+        final String attributeName = "requestAttributeSelector";
+        final String attributeValue = "requestAttributeSelectorValue";
+        getRequest().setAttribute( attributeName, attributeValue );        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( "request-attribute", attributeValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a request attribtue is selected", result );
+        
+        // test selection failure
+        result = this.select( "request-attribute", "unknownValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a request attribute is not selected", !result );
+    }
+
+    /**
+     * A request-attribute parameter select test
+     */
+    public void testRequestAttributeSelectOverridden() throws Exception {
+        final String attributeName = "requestAttributeSelector1";
+        final String attributeValue = "requestAttributeSelectorValue1";
+        getRequest().setAttribute( attributeName, attributeValue );
+        
+        final String attributeNameOverridden = "requestAttributeSelector";
+        final String attributeValueOverridden = "requestAttributeSelectorValue";
+        getRequest().setAttribute( attributeNameOverridden, attributeValueOverridden );
+        
+        Parameters parameters = new Parameters();
+        parameters.setParameter( "attribute-name", attributeName );
+        boolean result;
+        
+        // test selection success
+        result = this.select( "request-attribute", attributeValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a requst attribtue is selected", result );
+        
+        // test selection failure
+        result = this.select( "request-attribute", attributeValueOverridden, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a request attribute is not selected", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestAttributeSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.RequestAttributeSelector" 
+                       name="request-attribute">
+      <attribute-name>requestAttributeSelector</attribute-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,71 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class RequestMethodSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(RequestMethodSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A request-method select test
+     */
+    public void testRequestMethodSelect() throws Exception {
+        final String method = "POST";
+        getRequest().setMethod( "POST" );
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( "request-method", method, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a method is selected", result );
+        
+        // test selection failure
+        result = this.select( "request-method", "post", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a method is not selected", !result );
+        
+        // test selection failure
+        result = this.select( "request-method", "GET", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a method is not selected", !result );
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestMethodSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.RequestMethodSelector" 
+                       name="request-method">
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,92 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class RequestParameterSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(RequestParameterSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A request-parameter parameter select test
+     */
+    public void testRequestParameterSelect() throws Exception {
+        final String parameterName = "requestParameterSelector";
+        final String parameterValue = "requestParameterSelectorValue";
+        getRequest().addParameter( parameterName, parameterValue );        
+        Parameters parameters = new Parameters();
+        boolean result;
+        
+        // test selection success
+        result = this.select( "request-parameter", parameterValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a requst parameter is selected", result );
+        
+        // test selection failure
+        result = this.select( "request-parameter", "unknownValue", parameters );
+        System.out.println( result );
+        assertTrue( "Test if a request parameter is not selected", !result );
+    }
+
+    /**
+     * A request-parameter parameter select test
+     */
+    public void testRequestParameterSelectOverridden() throws Exception {
+        final String parameterName = "requestParameterSelector1";
+        final String parameterValue = "requestParameterSelectorValue1";
+        getRequest().addParameter( parameterName, parameterValue );
+        
+        final String parameterNameOverridden = "requestParameterSelector";
+        final String parameterValueOverridden = "requestParameterSelectorValue";
+        getRequest().addParameter( parameterNameOverridden, parameterValueOverridden );
+        
+        Parameters parameters = new Parameters();
+        parameters.setParameter( "parameter-name", parameterName );
+        boolean result;
+        
+        // test selection success
+        result = this.select( "request-parameter", parameterValue, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a requst attribtue is selected", result );
+        
+        // test selection failure
+        result = this.select( "request-parameter", parameterValueOverridden, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a request parameter is not selected", !result );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/RequestParameterSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.RequestParameterSelector" 
+                       name="request-parameter">
+      <parameter-name>requestParameterSelector</parameter-name>
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,92 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.cocoon.selection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.SitemapComponentTestCase;
+
+
+public class ResourceExistsSelectorTestCase extends SitemapComponentTestCase {
+
+    /**
+     * Run this test suite from commandline
+     *
+     * @param args commandline arguments (ignored)
+     */
+    public static void main( String[] args ) {
+        TestRunner.run(suite());
+    }
+    
+    /** Create a test suite.
+     * This test suite contains all test cases of this class.
+     * @return the Test object containing all test cases.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ResourceExistsSelectorTestCase.class);
+        return suite;
+    }
+    
+    /**
+     * A resource-exists parameter select test
+     */
+    public void testResourceExistsSelect() throws Exception {
+        
+        Parameters parameters = new Parameters();
+        boolean result;
+        String expression = "";
+
+        // test selection success
+        expression = "resource://org/apache/cocoon/selection/ResourceExistsSelectorTestCase.class";
+        result = this.select( "resource-exists", expression, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a exisitng resource is selected", result );
+        
+        // test selection failure
+        expression = "resource://org/apache/cocoon/selection/NonExistingResource.class";
+        result = this.select( "resource-exists", expression, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a non exisitng resource is not selected", !result );
+        
+    }
+
+    /**
+     * A resource-exists parameter select test using the parameter prefix option
+     */
+    public void testResourceExistsSelectPrefix() throws Exception {
+        
+        Parameters parameters = new Parameters();
+        final String prefix = "resource://org/apache/cocoon/selection/";
+        parameters.setParameter( "prefix", prefix );
+        boolean result;
+        String expression = "";
+
+        // test selection success
+        expression = "ResourceExistsSelectorTestCase.class";
+        result = this.select( "resource-exists", expression, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a exisitng resource is selected", result );
+        
+        // test selection failure
+        expression = "NonExistingResource.class";
+        result = this.select( "resource-exists", expression, parameters );
+        System.out.println( result );
+        assertTrue( "Test if a non exisitng resource is not selected", !result );
+        
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/test/java/org/apache/cocoon/selection/ResourceExistsSelectorTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,32 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testcase>
+ <roles>
+  <role name="org.apache.cocoon.selection.SelectorSelector"
+        shorthand="selectors"
+        default-class="org.apache.cocoon.core.container.StandaloneServiceSelector"/>
+ </roles>
+
+ <components>
+  <selectors logger="test">
+   <component-instance class="org.apache.cocoon.selection.ResourceExistsSelector" 
+                       name="resource-exists">
+    </component-instance>
+  </selectors>
+ </components>
+
+</testcase>



Mime
View raw message