1 package org.apache.fulcrum.testcontainer;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import java.io.File;
18
19 import org.apache.avalon.framework.component.ComponentException;
20 /**
21 * Basic testing of the Container
22 *
23 * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
24 * @version $Id: EcmContainerTest.java 223137 2004-10-30 13:18:00Z epugh $
25 */
26 public class EcmContainerTest extends BaseUnitTest
27 {
28 /**
29 * Constructor for test.
30 *
31 * @param testName name of the test being executed
32 */
33 public EcmContainerTest(String testName)
34 {
35 super(testName);
36 }
37
38 public void setUp() throws Exception{
39 containerType=CONTAINER_ECM;
40 super.setUp();
41 }
42
43 public void testInitialization()
44 {
45 assertTrue(true);
46 }
47 public void testComponentUsage()
48 {
49 SimpleComponent sc = null;
50 try
51 {
52 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
53 }
54 catch (ComponentException e)
55 {
56 e.printStackTrace();
57 fail(e.getMessage());
58 }
59 assertNotNull(sc);
60 sc.test();
61 assertEquals(sc.getAppRoot(),sc.getAppRoot2());
62 this.release(sc);
63 }
64 public void testAlternativeRoles()
65 {
66 SimpleComponent sc = null;
67 File f = new File("src/test/TestAlternativeRoleConfig.xml");
68 assertTrue(f.exists());
69 this.setRoleFileName("src/test/TestAlternativeRoleConfig.xml");
70 try
71 {
72 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
73 }
74 catch (ComponentException e)
75 {
76 e.printStackTrace();
77 fail(e.getMessage());
78 }
79 assertTrue(sc instanceof AlternativeComponentImpl);
80 assertNotNull(sc);
81 sc.test();
82 this.release(sc);
83 }
84
85 public void testLoadingContainerWithNoRolesfile()
86 {
87 SimpleComponent sc = null;
88
89 this.setRoleFileName(null);
90 this.setConfigurationFileName(
91 "src/test/TestComponentConfigIntegratedRoles.xml");
92 try
93 {
94 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
95 }
96 catch (ComponentException e)
97 {
98 e.printStackTrace();
99 fail(e.getMessage());
100 }
101 assertTrue(sc instanceof AlternativeComponentImpl);
102 assertNotNull(sc);
103 sc.test();
104 this.release(sc);
105 }
106
107 public void testLoadingNonExistentFile()
108 {
109 SimpleComponent sc = null;
110
111 this.setRoleFileName(null);
112 this.setConfigurationFileName("BogusFile.xml");
113 try
114 {
115 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
116 }
117 catch(RuntimeException re){
118
119 }
120 catch (ComponentException e)
121 {
122
123 fail(e.getMessage());
124 }
125 }
126 }