1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring.parsers;
12
13 import org.mule.api.config.ConfigurationBuilder;
14 import org.mule.config.spring.SpringXmlConfigurationBuilder;
15 import org.mule.context.DefaultMuleContextFactory;
16
17 import junit.framework.TestCase;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21
22
23
24
25 public abstract class AbstractBadConfigTestCase extends TestCase
26 {
27 protected final transient Log logger = LogFactory.getLog(getClass());
28
29 public void assertErrorContains(String phrase) throws Exception
30 {
31 try
32 {
33 parseConfig();
34 fail("expected error");
35 }
36 catch (Exception e)
37 {
38 logger.debug("Caught " + e);
39 assertTrue("Missing phrase '" + phrase + "' in '" + e.toString() + "'",
40 e.toString().indexOf(phrase) > -1);
41 }
42 }
43
44 protected void parseConfig() throws Exception
45 {
46 new DefaultMuleContextFactory().createMuleContext(getBuilder());
47 }
48
49 protected ConfigurationBuilder getBuilder() throws Exception
50 {
51 return new SpringXmlConfigurationBuilder(getConfigResources());
52 }
53
54 protected abstract String getConfigResources();
55 }