1 16 package org.apache.catalina.storeconfig; 17 18 import java.io.PrintWriter ; 19 import java.io.StringWriter ; 20 21 import junit.framework.TestCase; 22 23 import org.apache.catalina.Loader; 24 import org.apache.catalina.loader.WebappLoader; 25 import org.apache.catalina.storeconfig.LoaderSF; 26 import org.apache.catalina.storeconfig.StoreDescription; 27 import org.apache.catalina.storeconfig.StoreRegistry; 28 29 33 public class LoaderSFTest extends TestCase { 34 StoreRegistry registry; 35 36 StringWriter writer = new StringWriter (); 37 38 PrintWriter pWriter = new PrintWriter (writer); 39 40 Loader loader; 41 42 LoaderSF factory; 43 44 StoreDescription desc; 45 46 51 protected void setUp() throws Exception { 52 53 super.setUp(); 54 registry = new StoreRegistry(); 55 desc = DescriptorHelper.registerDescriptor(null, registry, 56 WebappLoader.class.getName(), "Loader", WebappLoader.class 57 .getName(), "org.apache.catalina.storeconfig.LoaderSF", 58 false, false); 59 factory = (LoaderSF) desc.getStoreFactory(); 60 loader = new WebappLoader(); 61 62 } 63 64 public void testManagerNonStandardStore() throws Exception { 65 assertTrue(factory.isDefaultLoader(loader)); 66 loader.setDelegate(true); 67 assertFalse(factory.isDefaultLoader(loader)); 68 String aspectedResult = "<Loader className=\"org.apache.catalina.loader.WebappLoader\"" 69 + LF.LINE_SEPARATOR 70 + " delegate=\"true\"/>" 71 + LF.LINE_SEPARATOR; 72 check(aspectedResult); 73 } 74 75 public void testStoreEmpty() throws Exception { 76 assertTrue(factory.isDefaultLoader(loader)); 77 String aspectedResult = ""; 78 check(aspectedResult); 79 } 80 81 protected void check(String aspectedResult) throws Exception { 82 factory.store(pWriter, -2, loader); 83 assertEquals(aspectedResult, writer.toString()); 84 } 85 86 } | Popular Tags |