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("/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        assertTrue(e.getCause().getMessage().indexOf("is not a valid language tag")>= 0); 
77      }
78  
79    }
80  
81    /**
82     * @see org.melati.MelatiConfig#MelatiConfig(Properties)
83     */
84    public void testMelatiConfigProperties() throws Exception {
85      Properties p = new Properties();
86      p.setProperty("org.melati.MelatiConfig.staticURL", "test");
87      MelatiConfig mc = new MelatiConfig(p);
88      assertEquals("test", mc.getStaticURL());
89    }
90    /**
91     * @see org.melati.MelatiConfig#getServletTemplateEngine()
92     */
93    public void testGetServletTemplateEngine() {
94  
95    }
96  
97    /**
98     * @see org.melati.MelatiConfig#getTemplateEngine()
99     */
100   public void testGetTemplateEngine() {
101 
102   }
103 
104   /**
105    * @see org.melati.MelatiConfig#setTemplateEngine(TemplateEngine)
106    */
107   public void testSetTemplateEngine() {
108 
109   }
110 
111   /**
112    * @see org.melati.MelatiConfig#getAccessHandler()
113    */
114   public void testGetAccessHandler() {
115 
116   }
117 
118   /**
119    * @see org.melati.MelatiConfig#setAccessHandler(AccessHandler)
120    */
121   public void testSetAccessHandler() {
122 
123   }
124 
125   /**
126    * @see org.melati.MelatiConfig#getTempletLoader()
127    */
128   public void testGetTempletLoader() {
129 
130   }
131 
132   /**
133    * @see org.melati.MelatiConfig#setTempletLoader(TempletLoader)
134    */
135   public void testSetTempletLoader() {
136 
137   }
138 
139   /**
140    * @see org.melati.MelatiConfig#getFormDataAdaptorFactory()
141    */
142   public void testGetFormDataAdaptorFactory() {
143 
144   }
145 
146   /**
147    * @see org.melati.MelatiConfig#setFormDataAdaptorFactory(FormDataAdaptorFactory)
148    */
149   public void testSetFormDataAdaptorFactory() {
150 
151   }
152 
153   /**
154    * @see org.melati.MelatiConfig#getJavascriptLibraryURL()
155    */
156   public void testGetJavascriptLibraryURL() {
157 
158   }
159 
160   /**
161    * @see org.melati.MelatiConfig#setJavascriptLibraryURL(String)
162    */
163   public void testSetJavascriptLibraryURL() {
164 
165   }
166 
167   /**
168    * @see org.melati.MelatiConfig#getStaticURL()
169    */
170   public void testGetStaticURL() {
171 
172   }
173 
174   /**
175    * @see org.melati.MelatiConfig#setStaticURL(String)
176    */
177   public void testSetStaticURL() {
178 
179   }
180 
181   /**
182    * Note not used outside tests.
183    * 
184    * @throws Exception
185    * @see org.melati.MelatiConfig#getTemplatePath()
186    */
187   public void testGetTemplatePath()
188       throws Exception {
189     MelatiConfig mc = new MelatiConfig();
190     assertEquals(".", mc.getTemplatePath());
191   }
192 
193   /**
194    * @see org.melati.MelatiConfig#setTemplatePath(String)
195    */
196   public void testSetTemplatePath() {
197 
198   }
199 
200   /**
201    * @throws Exception 
202    * @see org.melati.MelatiConfig#getLogoutPageServletClassName()
203    */
204   public void testGetLogoutPageServletClassName() throws Exception {
205     assertEquals("org.melati.login.Logout", MelatiConfig.getLogoutPageServletClassName());
206  }
207 
208   /**
209    * @see org.melati.MelatiConfig#setLogoutPageServletClassName(String)
210    */
211   public void testSetLogoutPageServletClassName() {
212 
213   }
214 
215   /**
216    * @throws Exception 
217    * @see org.melati.MelatiConfig#getLoginPageServletClassName()
218    */
219   public void testGetLoginPageServletClassName() throws Exception {
220     assertEquals("org.melati.login.Login", MelatiConfig.getLoginPageServletClassName());
221   }
222 
223   /**
224    * @see org.melati.MelatiConfig#setLoginPageServletClassName(String)
225    */
226   public void testSetLoginPageServletClassName() {
227 
228   }
229 
230   /**
231    * @see org.melati.MelatiConfig#getPoemLocale()
232    */
233   public void testGetPoemLocale() throws Exception {
234    // MelatiConfig mc = new MelatiConfig();
235    // assertEquals(mc.getPoemLocale(), mc.getMelatiLocale());
236 
237   }
238 
239   /**
240    * @see org.melati.MelatiConfig#setPoemiLocale(PoemLocale)
241    */
242   public void testSetPoemLocale() {
243 
244   }
245 
246   /**
247    * @see org.melati.MelatiConfig#getPreferredCharsets()
248    */
249   public void testGetPreferredCharsets() {
250 
251   }
252 
253   /**
254    * @see org.melati.MelatiConfig#setPreferredCharsets(Vector)
255    */
256   public void testSetPreferredCharsets() {
257 
258   }
259 
260   /**
261    * @throws Exception 
262    * @see org.melati.MelatiConfig#getFdaFactory()
263    */
264   public void testGetFdaFactory() throws Exception {
265     MelatiConfig mc = new MelatiConfig();
266     FormDataAdaptorFactory fdaf = mc.getFdaFactory();
267     assertNotNull(fdaf);
268   }
269 
270   /**
271    * @throws Exception 
272    * @see org.melati.MelatiConfig#setFdaFactory(FormDataAdaptorFactory)
273    */
274   public void testSetFdaFactory() throws Exception {
275   }
276 
277   /**
278    * @throws Exception 
279    * @see org.melati.MelatiConfig#getYMDDateAdaptor()
280    */
281   public void testGetYMDDateAdaptor() throws Exception {
282     YMDDateAdaptor it = MelatiConfig.getYMDDateAdaptor();
283     assertNotNull(it);
284 
285   }
286 
287   /**
288    * @throws Exception 
289    * @see org.melati.MelatiConfig#getYMDHMSTimestampAdaptor()
290    */
291   public void testGetYMDHMSTimestampAdaptor() throws Exception {
292     YMDHMSTimestampAdaptor it = MelatiConfig.getYMDHMSTimestampAdaptor();
293     assertNotNull(it);
294   }
295 
296   /**
297    * @throws Exception 
298    * @see org.melati.MelatiConfig#getSimpleDateAdaptor()
299    */
300   public void testGetSimpleDateAdaptor() throws Exception {
301     SimpleDateAdaptor it = MelatiConfig.getSimpleDateAdaptor();
302     assertNotNull(it);
303   }
304 
305 }