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 RegexpRequestParameterSelectorTestCase 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(RegexpRequestParameterSelectorTestCase.class); 42 return suite; 43 } 44 45 48 public void testRegexpRequestParameterSelectEmpty() throws Exception { 49 getRequest().addParameter( "parameterRegexpRequestParameterSelector", "" ); 51 52 Parameters parameters = new Parameters(); 53 boolean result; 54 55 result = this.select( "regexp-request-parameter", "empty", parameters ); 56 System.out.println( result ); 57 assertTrue( "Test is regexp-request-parameter selects successfully", result ); 58 59 result = this.select( "regexp-request-parameter", "number", parameters ); 60 System.out.println( result ); 61 assertTrue( "Test is regexp-request-parameter does not select successfully", !result ); 62 63 result = this.select( "regexp-request-parameter", "non-defined-name", parameters ); 64 System.out.println( result ); 65 assertTrue( "Test is regexp-request-parameter does not select successfully", !result ); 66 } 67 68 71 public void testRegexpRequestParameterSelectNumber() throws Exception { 72 Parameters parameters = new Parameters(); 73 boolean result; 74 75 result = this.select( "regexp-request-parameter", "number", parameters ); 77 System.out.println( result ); 78 assertTrue( "Test is regexp-request-parameter does not select successfully", !result ); 79 80 getRequest().addParameter( "parameterRegexpRequestParameterSelector1", "123" ); 82 83 parameters.setParameter( "parameter-name", "parameterRegexpRequestParameterSelector1" ); 85 86 result = this.select( "regexp-request-parameter", "number", parameters ); 87 System.out.println( result ); 88 assertTrue( "Test is regexp-request-parameter does not selects successfully", result ); 89 90 result = this.select( "regexp-request-parameter", "non-defined-name", parameters ); 91 System.out.println( result ); 92 assertTrue( "Test is regexp-request-parameter does not select successfully", !result ); 93 } 94 } 95 | Popular Tags |