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 ResourceExistsSelectorTestCase 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(ResourceExistsSelectorTestCase.class); 42 return suite; 43 } 44 45 48 public void testResourceExistsSelect() throws Exception { 49 50 Parameters parameters = new Parameters(); 51 boolean result; 52 String expression = ""; 53 54 expression = "resource://org/apache/cocoon/selection/ResourceExistsSelectorTestCase.class"; 56 result = this.select( "resource-exists", expression, parameters ); 57 System.out.println( result ); 58 assertTrue( "Test if a exisitng resource is selected", result ); 59 60 expression = "resource://org/apache/cocoon/selection/NonExistingResource.class"; 62 result = this.select( "resource-exists", expression, parameters ); 63 System.out.println( result ); 64 assertTrue( "Test if a non exisitng resource is not selected", !result ); 65 66 } 67 68 71 public void testResourceExistsSelectPrefix() throws Exception { 72 73 Parameters parameters = new Parameters(); 74 final String prefix = "resource://org/apache/cocoon/selection/"; 75 parameters.setParameter( "prefix", prefix ); 76 boolean result; 77 String expression = ""; 78 79 expression = "ResourceExistsSelectorTestCase.class"; 81 result = this.select( "resource-exists", expression, parameters ); 82 System.out.println( result ); 83 assertTrue( "Test if a exisitng resource is selected", result ); 84 85 expression = "NonExistingResource.class"; 87 result = this.select( "resource-exists", expression, parameters ); 88 System.out.println( result ); 89 assertTrue( "Test if a non exisitng resource is not selected", !result ); 90 91 } 92 } 93 | Popular Tags |