1 package org.apache.turbine;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import junit.framework.Test;
20 import junit.framework.TestSuite;
21
22 import org.apache.torque.Torque;
23 import org.apache.turbine.services.TurbineServices;
24 import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
25 import org.apache.turbine.test.BaseTestCase;
26 import org.apache.turbine.util.TurbineConfig;
27
28 /***
29 * Can we load and run Torque standalone, from Component and from
30 * AvalonComponent Service?
31 *
32 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
33 * @version $Id: TorqueLoadTest.java 264148 2005-08-29 14:21:04Z henning $
34 */
35 public class TorqueLoadTest
36 extends BaseTestCase
37 {
38 public TorqueLoadTest(String name)
39 throws Exception
40 {
41 super(name);
42 }
43
44 public static Test suite()
45 {
46 return new TestSuite(TorqueLoadTest.class);
47 }
48
49 /***
50 * An uninitialized Torque must not be initialized.
51 */
52 public void testTorqueNonInit()
53 throws Exception
54 {
55 assertFalse("Torque should not be initialized!", Torque.isInit());
56 }
57
58 /***
59 * Load Torque from a given config file.
60 */
61 public void testTorqueManualInit()
62 throws Exception
63 {
64 assertFalse("Torque should not be initialized!", Torque.isInit());
65 Torque.init("conf/test/TorqueTest.properties");
66 assertTrue("Torque must be initialized!", Torque.isInit());
67 Torque.shutdown();
68
69
70
71 }
72
73 /***
74 * Load Torque with the ComponentService
75 */
76 public void testTorqueComponentServiceInit()
77 throws Exception
78 {
79 assertFalse("Torque should not be initialized!", Torque.isInit());
80
81 TurbineConfig tc = new TurbineConfig(".", "/conf/test/TurbineComponentService.properties");
82 try
83 {
84 tc.initialize();
85 assertTrue("Torque must be initialized!", Torque.isInit());
86 }
87 catch (Exception e)
88 {
89 throw e;
90 }
91 finally
92 {
93 tc.dispose();
94 }
95
96
97
98 }
99
100 private AvalonComponentService getService()
101 {
102 return (AvalonComponentService) TurbineServices.getInstance()
103 .getService(AvalonComponentService.SERVICE_NAME);
104 }
105
106
107
108
109 /***
110 // * Load Torque with the AvalonComponentService
111 // */
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 }
141