1 64 65 package com.jcorporate.expresso.core.misc.tests; 66 67 import com.jcorporate.expresso.core.misc.ConfigManager; 68 import com.jcorporate.expresso.core.misc.XmlDocTypeFilter; 69 import com.jcorporate.expresso.services.test.ExpressoTestCase; 70 import junit.framework.TestSuite; 71 import org.xml.sax.InputSource ; 72 73 import java.io.FileInputStream ; 74 75 76 82 public class TestXmlDocTypeFilter 83 extends ExpressoTestCase { 84 public TestXmlDocTypeFilter(String testName) 85 throws Exception { 86 super(testName); 87 } 88 89 90 String configDir = null; 91 XmlDocTypeFilter testClass = null; 92 93 public static void main(String [] args) 94 throws Exception { 95 96 junit.textui.TestRunner.run(suite()); 98 } 99 100 public static junit.framework.Test suite() 101 throws Exception { 102 return new TestSuite(TestXmlDocTypeFilter.class); 103 } 104 105 public void setUp() { 106 configDir = ConfigManager.getConfigDir(); 107 assertTrue("configDir != null", 108 (configDir != null && configDir.length() > 0)); 109 110 testClass = new XmlDocTypeFilter(); 111 } 112 113 public void testParseExpressoConfig() 114 throws Exception { 115 String fileName = configDir + "/expresso-config.xml"; 116 FileInputStream fis = new FileInputStream (fileName); 117 InputSource inputSource = new InputSource (fis); 118 assertTrue("Proper Expresso Config Doctype", 119 testClass.isProperDocType("expresso-config", inputSource) == true); 120 fis.close(); 121 fis = new FileInputStream (fileName); 122 inputSource = new InputSource (fis); 123 assertTrue("Testing Wrong Expresso Config Doctype", 124 testClass.isProperDocType("expresso-config-WRONG", 125 inputSource) == false); 126 } 127 128 public void testParseStrutsConfig() 129 throws Exception { 130 String fileName = configDir + "/struts-config.xml"; 131 FileInputStream fis = new FileInputStream (fileName); 132 InputSource inputSource = new InputSource (fis); 133 assertTrue("Proper Struts Config Doctype", 134 testClass.isProperDocType("struts-config", inputSource) == true); 135 fis.close(); 136 fis = new FileInputStream (fileName); 137 inputSource = new InputSource (fis); 138 assertTrue("Testing Wrong Struts Config Doctype", 139 testClass.isProperDocType("struts-config-WRONG", 140 inputSource) == false); 141 } 142 143 public void testParseLoggingConfig() 144 throws Exception { 145 String fileName = configDir + "/expressoLogging.xml"; 146 FileInputStream fis = new FileInputStream (fileName); 147 InputSource inputSource = new InputSource (fis); 148 assertTrue("Proper Log4j Configuration Doctype", 149 testClass.isProperDocType("log4j:configuration", 150 inputSource) == true); 151 fis.close(); 152 fis = new FileInputStream (fileName); 153 inputSource = new InputSource (fis); 154 assertTrue("Testing Wrong Log4j Config Doctype", 155 testClass.isProperDocType("log4j:configuration-WRONG", 156 inputSource) == false); 157 } 158 } | Popular Tags |