1 package org.sapia.soto.util; 2 3 import junit.framework.TestCase; 4 5 14 public class ResourceHandlerChainTest extends TestCase{ 15 16 public ResourceHandlerChainTest(String name){ 17 super(name); 18 } 19 20 public void testAppend(){ 21 ResourceHandlerChain chain = new ResourceHandlerChain(); 22 String 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 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 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 |