01: /*
02: * Created on 14-Apr-2003
03: */
04: package net.sf.jportlet.util.test;
05:
06: import java.util.Locale;
07:
08: import net.sf.jportlet.portlet.Portlet;
09: import net.sf.jportlet.util.ClasspathResourceLoader;
10: import junit.framework.TestCase;
11:
12: /**
13: * @author Herve
14: */
15: public class ClasspathResourceLoaderTest extends TestCase {
16:
17: /**
18: *
19: */
20: public ClasspathResourceLoaderTest() {
21: super ();
22: }
23:
24: /**
25: * @param arg0
26: */
27: public ClasspathResourceLoaderTest(String arg0) {
28: super (arg0);
29: }
30:
31: public void testGetResourcePath() throws Exception {
32: String xpath;
33: ClasspathResourceLoader cp = new ClasspathResourceLoader(
34: ClasspathResourceLoaderTest.class);
35:
36: xpath = cp.getResourcePath("res.txt");
37: assertEquals("net/sf/jportlet/util/test/res.txt", xpath);
38:
39: /* Markup */
40: xpath = cp.getResourcePath("res.html", Portlet.Markup.HTML
41: .toString());
42: assertEquals("net/sf/jportlet/util/test/html/res.html", xpath);
43:
44: xpath = cp.getResourcePath("res.txt", Portlet.Markup.HTML
45: .toString());
46: assertEquals("net/sf/jportlet/util/test/res.txt", xpath);
47:
48: /* Language */
49: xpath = cp.getResourcePath("res.html", Portlet.Markup.HTML
50: .toString(), Locale.ENGLISH);
51: assertEquals("net/sf/jportlet/util/test/html/res_en.html",
52: xpath);
53:
54: xpath = cp.getResourcePath("res.txt", Portlet.Markup.HTML
55: .toString(), Locale.ENGLISH);
56: assertEquals("net/sf/jportlet/util/test/res.txt", xpath);
57:
58: /* Locale */
59: xpath = cp.getResourcePath("res.html", Portlet.Markup.HTML
60: .toString(), Locale.US);
61: assertEquals("net/sf/jportlet/util/test/html/res_en_US.html",
62: xpath);
63:
64: xpath = cp.getResourcePath("res.txt", Portlet.Markup.HTML
65: .toString(), Locale.US);
66: assertEquals("net/sf/jportlet/util/test/res.txt", xpath);
67: }
68: }
|