1 16 package org.apache.cocoon.selection; 17 18 import junit.framework.Test; 19 import junit.framework.TestSuite; 20 import junit.textui.TestRunner; 21 import org.apache.avalon.framework.parameters.Parameters; 22 import org.apache.cocoon.SitemapComponentTestCase; 23 24 25 public class RequestParameterSelectorTestCase extends SitemapComponentTestCase { 26 27 32 public static void main( String [] args ) { 33 TestRunner.run(suite()); 34 } 35 36 40 public static Test suite() { 41 TestSuite suite = new TestSuite(RequestParameterSelectorTestCase.class); 42 return suite; 43 } 44 45 48 public void testRequestParameterSelect() throws Exception { 49 final String parameterName = "requestParameterSelector"; 50 final String parameterValue = "requestParameterSelectorValue"; 51 getRequest().addParameter( parameterName, parameterValue ); 52 Parameters parameters = new Parameters(); 53 boolean result; 54 55 result = this.select( "request-parameter", parameterValue, parameters ); 57 System.out.println( result ); 58 assertTrue( "Test if a requst parameter is selected", result ); 59 60 result = this.select( "request-parameter", "unknownValue", parameters ); 62 System.out.println( result ); 63 assertTrue( "Test if a request parameter is not selected", !result ); 64 } 65 66 69 public void testRequestParameterSelectOverridden() throws Exception { 70 final String parameterName = "requestParameterSelector1"; 71 final String parameterValue = "requestParameterSelectorValue1"; 72 getRequest().addParameter( parameterName, parameterValue ); 73 74 final String parameterNameOverridden = "requestParameterSelector"; 75 final String parameterValueOverridden = "requestParameterSelectorValue"; 76 getRequest().addParameter( parameterNameOverridden, parameterValueOverridden ); 77 78 Parameters parameters = new Parameters(); 79 parameters.setParameter( "parameter-name", parameterName ); 80 boolean result; 81 82 result = this.select( "request-parameter", parameterValue, parameters ); 84 System.out.println( result ); 85 assertTrue( "Test if a requst attribtue is selected", result ); 86 87 result = this.select( "request-parameter", parameterValueOverridden, parameters ); 89 System.out.println( result ); 90 assertTrue( "Test if a request parameter is not selected", !result ); 91 } 92 } 93 | Popular Tags |