1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.component.factory.desc;
17
18 import junit.framework.TestCase;
19
20 import org.seasar.framework.exception.ResourceNotFoundRuntimeException;
21 import org.seasar.framework.exception.SAXRuntimeException;
22 import org.seasar.framework.util.ResourceUtil;
23
24
25
26
27
28
29 public class ComponentRegistryTest extends TestCase {
30
31
32
33 public void testRegistComponents() {
34 ComponentRegistry registry = new ComponentRegistry();
35
36 }
37
38
39
40
41 public void testLoad1() {
42 String path = createPath("1");
43 ComponentRegistry registry = new ComponentRegistry();
44 UrumaComponentDesc desc = registry.load(path);
45 assertNotNull("1", desc);
46 assertEquals("2", "tagName:testTag "
47 + "tagHandler:org.seasar.uruma.dummy.TagHandler(arg1, arg2) "
48 + "renderer:org.seasar.uruma.dummy.Renderer(arg1, arg2, arg3)",
49 desc.toString());
50 }
51
52
53
54
55 public void testLoad2() {
56 String path = createPath("2");
57 ComponentRegistry registry = new ComponentRegistry();
58 try {
59 registry.load(path);
60 fail();
61 } catch (SAXRuntimeException ex) {
62 assertTrue(true);
63 }
64 }
65
66
67
68
69 public void testLoad3() {
70 String path = createPath("NG");
71 ComponentRegistry registry = new ComponentRegistry();
72 try {
73 registry.load(path);
74 fail();
75 } catch (ResourceNotFoundRuntimeException ex) {
76 assertTrue(true);
77 }
78 }
79
80 private String createPath(final String suffix) {
81 return ResourceUtil.convertPath(getClass().getSimpleName() + suffix
82 + ".ucd", getClass());
83 }
84 }