View Javadoc

1   /**
2    * 
3    */
4   package org.melati.test;
5   
6   import java.util.Properties;
7   
8   import org.melati.MelatiConfig;
9   import org.melati.servlet.FormDataAdaptorFactory;
10  import org.melati.template.SimpleDateAdaptor;
11  import org.melati.template.YMDDateAdaptor;
12  import org.melati.template.YMDHMSTimestampAdaptor;
13  import org.melati.util.ConfigException;
14  
15  import junit.framework.TestCase;
16  
17  /**
18   * @author timp
19   * @since 14-Dec-2006
20   */
21  public class MelatiConfigTest extends TestCase {
22  
23    /**
24     * Constructor for MelatiConfigTest.
25     * 
26     * @param name
27     */
28    public MelatiConfigTest(String name) {
29      super(name);
30    }
31  
32    /**
33     * @see TestCase#setUp()
34     */
35    protected void setUp()
36        throws Exception {
37      super.setUp();
38    }
39  
40    /**
41     * @see TestCase#tearDown()
42     */
43    protected void tearDown()
44        throws Exception {
45      super.tearDown();
46    }
47  
48    /**
49     * @see org.melati.MelatiConfig#MelatiConfig()
50     */
51    public void testMelatiConfig() {
52  
53    }
54  
55    /**
56     * @throws Exception
57     * @see org.melati.MelatiConfig#MelatiConfig(String)
58     */
59    public void testMelatiConfigString()
60        throws Exception {
61      MelatiConfig mc = new MelatiConfig("org.melati.MelatiConfig");
62      assertEquals("/melatitest/melati-static/admin/static", mc.getStaticURL());
63  
64      try {
65        mc = new MelatiConfig("nonexistantProperties");
66        fail("Should have blown up");
67      } catch (ConfigException e) {
68        assertTrue(e.getMessage().indexOf("Is it in your CLASSPATH")>= 0); 
69      }
70  
71      // Bad locale setting
72      try {
73        mc = new MelatiConfig("bad.MelatiConfig");
74        fail("Should have blown up");
75      } catch (ConfigException e) {
76        System.err.println(e);
77        assertTrue(e.getMessage().indexOf("is not a valid language tag")>= 0); 
78      }
79  
80    }
81  
82    /**
83     * @see org.melati.MelatiConfig#MelatiConfig(Properties)
84     */
85    public void testMelatiConfigProperties() throws Exception {
86      Properties p = new Properties();
87      p.setProperty("org.melati.MelatiConfig.staticURL", "test");
88      MelatiConfig mc = new MelatiConfig(p);
89      assertEquals("test", mc.getStaticURL());
90    }
91    /**
92     * @see org.melati.MelatiConfig#getServletTemplateEngine()
93     */
94    public void testGetServletTemplateEngine() {
95  
96    }
97  
98    /**
99     * @see org.melati.MelatiConfig#getTemplateEngine()
100    */
101   public void testGetTemplateEngine() {
102 
103   }
104 
105   /**
106    * @see org.melati.MelatiConfig#setTemplateEngine(TemplateEngine)
107    */
108   public void testSetTemplateEngine() {
109 
110   }
111 
112   /**
113    * @see org.melati.MelatiConfig#getAccessHandler()
114    */
115   public void testGetAccessHandler() {
116 
117   }
118 
119   /**
120    * @see org.melati.MelatiConfig#setAccessHandler(AccessHandler)
121    */
122   public void testSetAccessHandler() {
123 
124   }
125 
126   /**
127    * @see org.melati.MelatiConfig#getTempletLoader()
128    */
129   public void testGetTempletLoader() {
130 
131   }
132 
133   /**
134    * @see org.melati.MelatiConfig#setTempletLoader(TempletLoader)
135    */
136   public void testSetTempletLoader() {
137 
138   }
139 
140   /**
141    * @see org.melati.MelatiConfig#getFormDataAdaptorFactory()
142    */
143   public void testGetFormDataAdaptorFactory() {
144 
145   }
146 
147   /**
148    * @see org.melati.MelatiConfig#setFormDataAdaptorFactory(FormDataAdaptorFactory)
149    */
150   public void testSetFormDataAdaptorFactory() {
151 
152   }
153 
154   /**
155    * @see org.melati.MelatiConfig#getJavascriptLibraryURL()
156    */
157   public void testGetJavascriptLibraryURL() {
158 
159   }
160 
161   /**
162    * @see org.melati.MelatiConfig#setJavascriptLibraryURL(String)
163    */
164   public void testSetJavascriptLibraryURL() {
165 
166   }
167 
168   /**
169    * @see org.melati.MelatiConfig#getStaticURL()
170    */
171   public void testGetStaticURL() {
172 
173   }
174 
175   /**
176    * @see org.melati.MelatiConfig#setStaticURL(String)
177    */
178   public void testSetStaticURL() {
179 
180   }
181 
182   /**
183    * Note not used outside tests.
184    * 
185    * @throws Exception
186    * @see org.melati.MelatiConfig#getTemplatePath()
187    */
188   public void testGetTemplatePath()
189       throws Exception {
190     MelatiConfig mc = new MelatiConfig();
191     assertEquals(".", mc.getTemplatePath());
192   }
193 
194   /**
195    * @see org.melati.MelatiConfig#setTemplatePath(String)
196    */
197   public void testSetTemplatePath() {
198 
199   }
200 
201   /**
202    * @throws Exception 
203    * @see org.melati.MelatiConfig#getLogoutPageServletClassName()
204    */
205   public void testGetLogoutPageServletClassName() throws Exception {
206     assertEquals("org.melati.login.Logout", MelatiConfig.getLogoutPageServletClassName());
207  }
208 
209   /**
210    * @see org.melati.MelatiConfig#setLogoutPageServletClassName(String)
211    */
212   public void testSetLogoutPageServletClassName() {
213 
214   }
215 
216   /**
217    * @throws Exception 
218    * @see org.melati.MelatiConfig#getLoginPageServletClassName()
219    */
220   public void testGetLoginPageServletClassName() throws Exception {
221     assertEquals("org.melati.login.Login", MelatiConfig.getLoginPageServletClassName());
222   }
223 
224   /**
225    * @see org.melati.MelatiConfig#setLoginPageServletClassName(String)
226    */
227   public void testSetLoginPageServletClassName() {
228 
229   }
230 
231   /**
232    * @see org.melati.MelatiConfig#getPoemLocale()
233    */
234   public void testGetPoemLocale() throws Exception {
235    // MelatiConfig mc = new MelatiConfig();
236    // assertEquals(mc.getPoemLocale(), mc.getMelatiLocale());
237 
238   }
239 
240   /**
241    * @see org.melati.MelatiConfig#setPoemiLocale(PoemLocale)
242    */
243   public void testSetPoemLocale() {
244 
245   }
246 
247   /**
248    * @see org.melati.MelatiConfig#getPreferredCharsets()
249    */
250   public void testGetPreferredCharsets() {
251 
252   }
253 
254   /**
255    * @see org.melati.MelatiConfig#setPreferredCharsets(Vector)
256    */
257   public void testSetPreferredCharsets() {
258 
259   }
260 
261   /**
262    * @throws Exception 
263    * @see org.melati.MelatiConfig#getFdaFactory()
264    */
265   public void testGetFdaFactory() throws Exception {
266     MelatiConfig mc = new MelatiConfig();
267     FormDataAdaptorFactory fdaf = mc.getFdaFactory();
268     assertNotNull(fdaf);
269   }
270 
271   /**
272    * @throws Exception 
273    * @see org.melati.MelatiConfig#setFdaFactory(FormDataAdaptorFactory)
274    */
275   public void testSetFdaFactory() throws Exception {
276   }
277 
278   /**
279    * @throws Exception 
280    * @see org.melati.MelatiConfig#getYMDDateAdaptor()
281    */
282   public void testGetYMDDateAdaptor() throws Exception {
283     YMDDateAdaptor it = MelatiConfig.getYMDDateAdaptor();
284     assertNotNull(it);
285 
286   }
287 
288   /**
289    * @throws Exception 
290    * @see org.melati.MelatiConfig#getYMDHMSTimestampAdaptor()
291    */
292   public void testGetYMDHMSTimestampAdaptor() throws Exception {
293     YMDHMSTimestampAdaptor it = MelatiConfig.getYMDHMSTimestampAdaptor();
294     assertNotNull(it);
295   }
296 
297   /**
298    * @throws Exception 
299    * @see org.melati.MelatiConfig#getSimpleDateAdaptor()
300    */
301   public void testGetSimpleDateAdaptor() throws Exception {
302     SimpleDateAdaptor it = MelatiConfig.getSimpleDateAdaptor();
303     assertNotNull(it);
304   }
305 
306 }