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