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: YaafiContainerTest.java 223282 2005-03-01 12:17:31Z sgoeschl $
25 */
26 public class YaafiContainerTest extends BaseUnitTest
27 {
28 /**
29 * Constructor for test.
30 *
31 * @param testName name of the test being executed
32 */
33 public YaafiContainerTest(String testName)
34 {
35 super(testName);
36 }
37
38 public void testInitialization()
39 {
40 assertTrue(true);
41 }
42 public void testComponentUsage()
43 {
44 SimpleComponent sc = null;
45 try
46 {
47 sc = (SimpleComponent) this.lookup(SimpleComponent.class.getName());
48
49 }
50 catch (ComponentException e)
51 {
52 e.printStackTrace();
53 fail(e.getMessage());
54 }
55 assertNotNull(sc);
56 sc.test();
57 assertEquals(sc.getAppRoot(),sc.getAppRoot2());
58 this.release(sc);
59 }
60 public void testAlternativeRoles()
61 {
62 SimpleComponent sc = null;
63 File f = new File("src/test/TestAlternativeRoleConfig.xml");
64 assertTrue(f.exists());
65 this.setRoleFileName("src/test/TestAlternativeRoleConfig.xml");
66 try
67 {
68 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
69 }
70 catch (ComponentException e)
71 {
72 e.printStackTrace();
73 fail(e.getMessage());
74 }
75 assertTrue(sc instanceof AlternativeComponentImpl);
76 assertNotNull(sc);
77 sc.test();
78 this.release(sc);
79 }
80
81 public void testLoadingContainerWithNoRolesfileFails()
82 {
83 SimpleComponent sc = null;
84
85 this.setRoleFileName(null);
86 this.setConfigurationFileName(
87 "src/test/TestComponentConfigIntegratedRoles.xml");
88 try
89 {
90 sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
91 fail("We should fail");
92 }
93 catch (Exception e)
94 {
95
96 }
97
98 }
99
100 }