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 BrowserSelectorTestCase 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(BrowserSelectorTestCase.class); 42 return suite; 43 } 44 45 48 public void testBrowserSelectMisconfigured() throws Exception { 49 final String userAgent = "Mozilla"; 50 51 getRequest().setHeader("User-Agent", userAgent ); 52 Parameters parameters = new Parameters(); 53 boolean result; 54 55 result = this.select( "browser", "non-configured-browser-name", parameters ); 56 System.out.println( result ); 57 assertTrue( "Test is browser is a non-configured-browser-name", !result ); 58 } 59 60 63 public void testBrowserSelectNetscape() throws Exception { 64 final String userAgent = "Mozilla"; 65 String expectedBrowserName; 66 67 getRequest().setHeader("User-Agent", userAgent ); 68 Parameters parameters = new Parameters(); 69 boolean result; 70 71 expectedBrowserName = "netscape"; 72 result = this.select( "browser", expectedBrowserName, parameters ); 73 System.out.println(result); 74 assertTrue( "Test if browser is " + expectedBrowserName, result ); 75 76 expectedBrowserName = "explorer"; 77 result = this.select( "browser", expectedBrowserName, parameters ); 78 System.out.println( result ); 79 assertTrue( "Test if browser is NOT " + expectedBrowserName, !result ); 80 } 81 } 82 | Popular Tags |