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 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21
22
23
24 public abstract class AbstractBadConfigTestCase extends TestCase
25 {
26 protected final transient Log logger = LogFactory.getLog(getClass());
27
28 public void assertErrorContains(String phrase) throws Exception
29 {
30 try {
31 parseConfig();
32 fail("expected error");
33 } catch (Exception e) {
34 logger.debug("Caught " + e);
35 assertTrue("Missing phrase '" + phrase + "' in '" + e.toString() + "'",
36 e.toString().indexOf(phrase) > -1);
37 }
38 }
39
40 protected void parseConfig() throws Exception
41 {
42 new DefaultMuleContextFactory().createMuleContext(getBuilder());
43 }
44
45 protected ConfigurationBuilder getBuilder() throws Exception
46 {
47 return new SpringXmlConfigurationBuilder(getConfigResources());
48 }
49
50 protected abstract String getConfigResources();
51
52 }