1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.tck; |
12 | |
|
13 | |
import org.mule.MuleManager; |
14 | |
import org.mule.config.ConfigurationBuilder; |
15 | |
import org.mule.util.ClassUtils; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | 178 | public abstract class FunctionalTestCase extends AbstractMuleTestCase |
28 | |
{ |
29 | |
|
30 | |
public static final String DEFAULT_BUILDER_CLASS = "org.mule.config.builders.MuleXmlConfigurationBuilder"; |
31 | |
|
32 | |
protected final void doSetUp() throws Exception |
33 | |
{ |
34 | 178 | doPreFunctionalSetUp(); |
35 | |
|
36 | 178 | if (!getTestInfo().isDisposeManagerPerSuite()) |
37 | |
{ |
38 | 12 | setupManager(); |
39 | |
} |
40 | 178 | doPostFunctionalSetUp(); |
41 | 178 | } |
42 | |
|
43 | |
protected void suitePreSetUp() throws Exception |
44 | |
{ |
45 | 14 | if (getTestInfo().isDisposeManagerPerSuite()) |
46 | |
{ |
47 | 8 | setupManager(); |
48 | |
} |
49 | 14 | } |
50 | |
|
51 | |
protected void setupManager() throws Exception |
52 | |
{ |
53 | 20 | MuleManager.getConfiguration().setWorkListener(new TestingWorkListener()); |
54 | 20 | ConfigurationBuilder builder = getBuilder(); |
55 | 20 | builder.configure(getConfigResources(), null); |
56 | 20 | } |
57 | |
|
58 | |
protected final void doTearDown() throws Exception |
59 | |
{ |
60 | 178 | doFunctionalTearDown(); |
61 | 178 | } |
62 | |
|
63 | |
protected ConfigurationBuilder getBuilder() throws Exception |
64 | |
{ |
65 | |
|
66 | |
try |
67 | |
{ |
68 | 14 | Class builderClass = ClassUtils.loadClass(DEFAULT_BUILDER_CLASS, getClass()); |
69 | 14 | return (ConfigurationBuilder)builderClass.newInstance(); |
70 | |
} |
71 | 0 | catch (ClassNotFoundException e) |
72 | |
{ |
73 | 0 | throw new ClassNotFoundException( |
74 | |
"The builder " |
75 | |
+ DEFAULT_BUILDER_CLASS |
76 | |
+ " is not on your classpath and " |
77 | |
+ "the getBuilder() method of this class has not been overloaded to return a different builder. Please " |
78 | |
+ "check your functional test.", e); |
79 | |
} |
80 | |
|
81 | |
} |
82 | |
|
83 | |
protected void doPreFunctionalSetUp() throws Exception |
84 | |
{ |
85 | |
|
86 | 178 | } |
87 | |
|
88 | |
protected void doPostFunctionalSetUp() throws Exception |
89 | |
{ |
90 | |
|
91 | 178 | } |
92 | |
|
93 | |
protected void doFunctionalTearDown() throws Exception |
94 | |
{ |
95 | |
|
96 | 178 | } |
97 | |
|
98 | |
protected abstract String getConfigResources(); |
99 | |
} |