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.Manager; 24 import org.apache.catalina.session.StandardManager; 25 26 30 public class ManagerSFTest extends TestCase { 31 StoreRegistry registry; 32 33 StringWriter writer = new StringWriter (); 34 35 PrintWriter pWriter = new PrintWriter (writer); 36 37 StandardManager manager; 38 39 ManagerSF factory; 40 41 StoreDescription desc; 42 43 48 protected void setUp() throws Exception { 49 50 super.setUp(); 51 registry = new StoreRegistry(); 52 desc = DescriptorHelper.registerDescriptor(null, registry, 53 Manager.class.getName(), "Manager", 54 Manager.class.getName(), 55 "org.apache.catalina.storeconfig.ManagerSF", false, false); 56 desc.addTransientAttribute("entropy"); 57 desc.addTransientAttribute("distributable"); 58 factory = (ManagerSF) desc.getStoreFactory(); 59 manager = new StandardManager(); 60 61 } 62 63 public void testFindStandardManager() { 64 StoreDescription managerdesc = registry.findDescription(manager.getClass()); 65 assertEquals(desc,managerdesc); 66 } 67 68 public void testManagerNonStandardStore() throws Exception { 69 assertTrue(factory.isDefaultManager(manager)); 70 manager.setMaxActiveSessions(100); 71 assertFalse(factory.isDefaultManager(manager)); 72 String aspectedResult = "<Manager className=\"org.apache.catalina.session.StandardManager\"" 73 + LF.LINE_SEPARATOR 74 + " maxActiveSessions=\"100\"/>" 75 + LF.LINE_SEPARATOR; 76 check(aspectedResult); 77 } 78 79 public void testStoreEmpty() throws Exception { 80 assertTrue(factory.isDefaultManager(manager)); 81 String aspectedResult = ""; 82 check(aspectedResult); 83 } 84 85 protected void check(String aspectedResult) throws Exception { 86 factory.store(pWriter, -2, manager); 87 assertEquals(aspectedResult, writer.toString()); 88 } 89 90 } | Popular Tags |