1 16 17 18 package org.apache.naming.resources; 19 20 import java.io.File ; 21 22 import java.util.Date ; 23 24 import javax.naming.NamingException ; 25 26 import javax.naming.directory.Attribute ; 27 import javax.naming.directory.Attributes ; 28 import javax.naming.directory.DirContext ; 29 30 import junit.framework.Test; 31 import junit.framework.TestCase; 32 import junit.framework.TestSuite; 33 34 35 41 42 public class FileDirContextTestCase extends BaseDirContextTestCase { 43 44 45 47 48 53 public FileDirContextTestCase(String name) { 54 55 super(name); 56 57 } 58 59 60 62 63 67 public void setUp() { 68 69 context = new FileDirContext(); 70 ((FileDirContext) context).setDocBase(docBase); 71 72 } 73 74 75 79 public static Test suite() { 80 81 return (new TestSuite(FileDirContextTestCase.class)); 82 83 } 84 85 86 90 public void tearDown() { 91 92 context = null; 93 94 } 95 96 97 99 100 103 public void testGetAttributesWebInf() { 104 105 try { 106 107 File docBaseFile = new File (docBase); 109 File webInfFile = new File (docBaseFile, "WEB-INF"); 110 111 Attributes attributes = context.getAttributes("WEB-INF"); 113 114 checkWebInfAttributes(attributes, 116 new Date (webInfFile.lastModified()), 117 webInfFile.length(), 118 "WEB-INF", 119 new Date (webInfFile.lastModified())); 120 121 } catch (NamingException e) { 122 123 fail("NamingException: " + e); 124 125 } 126 127 } 128 129 130 134 public void testGetAttributesWebXml() { 135 136 try { 137 138 File docBaseFile = new File (docBase); 140 File webInfFile = new File (docBaseFile, "WEB-INF"); 141 File webXmlFile = new File (webInfFile, "web.xml"); 142 143 Attributes attributes = context.getAttributes("WEB-INF/web.xml"); 145 146 checkWebXmlAttributes(attributes, 148 new Date (webXmlFile.lastModified()), 149 webXmlFile.length(), 150 "web.xml", 151 new Date (webXmlFile.lastModified())); 152 153 } catch (NamingException e) { 154 155 fail("NamingException: " + e); 156 157 } 158 159 } 160 161 162 } 163 164 165 166 | Popular Tags |