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.core.StandardServer; 24 25 29 public class StoreRegistryTest extends TestCase { 30 31 StoreRegistry registry; 32 33 StringWriter writer = new StringWriter (); 34 35 PrintWriter pWriter = new PrintWriter (writer); 36 37 StandardServer standardServer = new StandardServer(); 38 39 IStoreFactory factory; 40 41 StoreDescription desc; 42 43 48 protected void setUp() throws Exception { 49 50 super.setUp(); 51 registry = new StoreRegistry(); 52 desc = new StoreDescription(); 53 desc.setTag("Server"); 54 desc.setTagClass("org.apache.catalina.core.StandardServer"); 55 desc.setStandard(true); 56 desc 57 .setStoreFactoryClass("org.apache.catalina.storeconfig.StoreFactoryBase"); 58 registry.registerDescription(desc); 59 factory = new StoreFactoryBase(); 60 factory.setRegistry(registry); 61 } 62 63 public void testSaveServer() throws Exception { 64 assertNotNull(registry.findDescription(StandardServer.class)); 65 factory.store(pWriter, -2, standardServer); 66 assertEquals("XML Diff", "<Server/>" + LF.LINE_SEPARATOR, writer 67 .toString()); 68 } 69 70 public void testAttributes() throws Exception { 71 standardServer.setPort(7305); 72 factory.store(pWriter, -2, standardServer); 73 assertEquals("XML Diff", "<Server" + LF.LINE_SEPARATOR 74 + " port=\"7305\"/>" + LF.LINE_SEPARATOR, writer.toString()); 75 76 } 77 78 } | Popular Tags |