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 ParameterSelectorTestCase 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(ParameterSelectorTestCase.class); 42 return suite; 43 } 44 45 48 public void testParameterSelect() throws Exception { 49 final String parameterName = "parameterSelectorTestCase"; 50 51 Parameters parameters = new Parameters(); 52 parameters.setParameter( "parameter-selector-test", parameterName ); 53 boolean result; 54 55 result = this.select( "parameter", parameterName, parameters ); 57 System.out.println( result ); 58 assertTrue( "Test if a parameter is selected", result ); 59 60 result = this.select( "parameter", "unknownParameterName", parameters ); 62 System.out.println( result ); 63 assertTrue( "Test if a parameter is not selected", !result ); 64 } 65 66 69 public void testParameterSelectUndefined() throws Exception { 70 final String parameterName = "parameterSelectorTestCase"; 71 72 Parameters parameters = new Parameters(); 73 boolean result; 74 75 result = this.select( "parameter", parameterName, parameters ); 77 System.out.println( result ); 78 assertTrue( "Test if a parameter is not selected", !result ); 79 80 parameters.setParameter( "parameter-selector-test", "some-parameter-name" ); 81 result = this.select( "parameter", parameterName, parameters ); 82 System.out.println( result ); 83 assertTrue( "Test if a parameter is not selected", !result ); 84 } 85 } 86 | Popular Tags |