1 package org.objectledge.i18n;
2
3 import java.util.Locale;
4
5 import org.jcontainer.dna.Configuration;
6 import org.jcontainer.dna.ConfigurationException;
7 import org.jmock.Mock;
8 import org.objectledge.configuration.ConfigurationFactory;
9 import org.objectledge.filesystem.ClasspathFileSystemProvider;
10 import org.objectledge.filesystem.FileSystem;
11 import org.objectledge.filesystem.FileSystemProvider;
12 import org.objectledge.filesystem.LocalFileSystemProvider;
13 import org.objectledge.utils.LedgeTestCase;
14 import org.objectledge.xml.XMLGrammarCache;
15 import org.objectledge.xml.XMLValidator;
16
17 /***
18 *
19 * @author <a href="maito:mgolebsk@elka.pw.edu.pl">Marcin Golebski</a>
20 * @created 2005-08-15 <br>
21 * $Id: FormatterTestCase.java,v 1.1 2006/03/07 17:35:07 zwierzem Exp $ <br>
22 */
23 public abstract class FormatterTestCase extends LedgeTestCase
24 {
25 protected Mock i18nMock = mock(I18n.class);
26 protected I18n i18n = (I18n)i18nMock.proxy();
27
28 protected Locale plLocale;
29 protected Locale usLocale;
30
31 public FormatterTestCase()
32 {
33 super();
34 plLocale = new Locale("pl","PL");
35 usLocale = new Locale("en","US");
36 }
37
38 protected void setUp() throws Exception
39 {
40 super.setUp();
41 FileSystemProvider lfs = new LocalFileSystemProvider("local", "src/test/resources");
42 FileSystemProvider cfs = new ClasspathFileSystemProvider("classpath",
43 getClass().getClassLoader());
44 FileSystem fs = new FileSystem(new FileSystemProvider[] { lfs, cfs }, 4096, 4096);
45 XMLValidator xv = new XMLValidator(new XMLGrammarCache());
46 ConfigurationFactory cf = new ConfigurationFactory(fs, xv, "config");
47 Class formatterClass = getFormatterClass();
48 Configuration config = cf.getConfig(formatterClass.getName(), formatterClass);
49 i18nMock.expects(never()).method("getDefaultLocale").will(returnValue(plLocale));
50 createFormatter(config, i18n);
51 }
52
53 protected abstract Class getFormatterClass();
54
55 protected abstract void createFormatter(Configuration config, I18n i18n)
56 throws ConfigurationException;
57 }