KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > util > ResourceHandlerChainTest


1 package org.sapia.soto.util;
2
3 import junit.framework.TestCase;
4
5 /**
6  * @author Yanick Duchesne
7  *
8  * <dl>
9  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
10  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
11  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
12  * </dl>
13  */

14 public class ResourceHandlerChainTest extends TestCase{
15     
16     public ResourceHandlerChainTest(String JavaDoc name){
17         super(name);
18     }
19     
20     public void testAppend(){
21         ResourceHandlerChain chain = new ResourceHandlerChain();
22         String JavaDoc r = "some/resource";
23         chain.append(new FileResourceHandler());
24         chain.append(new ClasspathResourceHandler());
25         ResourceHandler h = chain.select(r);
26         super.assertTrue("ResourceHandler not found", h != null);
27         super.assertTrue("ResourceHandler should be instance of " + FileResourceHandler.class.getName(), h instanceof FileResourceHandler);
28     }
29     
30     public void testPrepend(){
31         ResourceHandlerChain chain = new ResourceHandlerChain();
32         String JavaDoc r = "some/resource";
33         chain.append(new FileResourceHandler());
34         chain.prepend(new ClasspathResourceHandler());
35         ResourceHandler h = chain.select(r);
36         super.assertTrue("ResourceHandler not found", h != null);
37         super.assertTrue("ResourceHandler should be instance of " + FileResourceHandler.class.getName(), h instanceof ClasspathResourceHandler);
38     }
39     
40     public void testSelect(){
41         ResourceHandlerChain chain = new ResourceHandlerChain();
42         String JavaDoc r = "resource:/some/resource";
43         chain.append(new FileResourceHandler());
44         chain.prepend(new ClasspathResourceHandler());
45         ResourceHandler h = chain.select(r);
46         super.assertTrue("ResourceHandler not found", h != null);
47         
48         r = "file:/some/resource";
49         chain.append(new FileResourceHandler());
50         chain.prepend(new ClasspathResourceHandler());
51         h = chain.select(r);
52         super.assertTrue("ResourceHandler not found", h != null);
53     }
54
55 }
56
57
Popular Tags