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 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 doPreFunctionalSetUp();
35
36 if (!getTestInfo().isDisposeManagerPerSuite())
37 {
38 setupManager();
39 }
40 doPostFunctionalSetUp();
41 }
42
43 protected void suitePreSetUp() throws Exception
44 {
45 if (getTestInfo().isDisposeManagerPerSuite())
46 {
47 setupManager();
48 }
49 }
50
51 protected void setupManager() throws Exception
52 {
53 MuleManager.getConfiguration().setWorkListener(new TestingWorkListener());
54 ConfigurationBuilder builder = getBuilder();
55 builder.configure(getConfigResources(), null);
56 }
57
58 protected final void doTearDown() throws Exception
59 {
60 doFunctionalTearDown();
61 }
62
63 protected ConfigurationBuilder getBuilder() throws Exception
64 {
65
66 try
67 {
68 Class builderClass = ClassUtils.loadClass(DEFAULT_BUILDER_CLASS, getClass());
69 return (ConfigurationBuilder)builderClass.newInstance();
70 }
71 catch (ClassNotFoundException e)
72 {
73 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 }
87
88 protected void doPostFunctionalSetUp() throws Exception
89 {
90
91 }
92
93 protected void doFunctionalTearDown() throws Exception
94 {
95
96 }
97
98 protected abstract String getConfigResources();
99 }