View Javadoc

1   /*
2    * $Id: CustomConfigTestCase.java 20385 2010-11-29 20:25:26Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.integration.config;
12  
13  import org.mule.api.endpoint.ImmutableEndpoint;
14  import org.mule.api.exception.MessagingExceptionHandler;
15  import org.mule.api.transformer.Transformer;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.tck.testmodels.mule.TestCompressionTransformer;
18  import org.mule.tck.testmodels.mule.TestConnector;
19  import org.mule.tck.testmodels.mule.TestExceptionStrategy;
20  
21  public class CustomConfigTestCase extends FunctionalTestCase
22  {
23  
24      protected String getConfigResources()
25      {
26          return "org/mule/test/integration/config/custom-config.xml";
27      }
28  
29      public void testCustomEndpointConfig() throws Exception
30      {
31          ImmutableEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
32              "fooEndpoint");
33          assertNotNull("fooEndpoint should not be null", ep);
34          TestFilter tf = (TestFilter)ep.getFilter();
35          assertNotNull("the filter on the endpoint should not be null", tf);
36          assertEquals(tf.getFoo(), "goo");
37          assertEquals(tf.getBar(), 12);
38      }
39  
40      public void testCustomConnectorConfig() throws Exception
41      {
42          TestConnector cnn = (TestConnector)muleContext.getRegistry().lookupConnector("customConnector");
43          assertNotNull("customConnector should not be null", cnn);
44          assertEquals(cnn.getSomeProperty(), "foo");
45  
46          //Test exception strategy
47          MessagingExceptionHandler es = muleContext.getRegistry().lookupModel("main").getExceptionListener();
48          assertNotNull(es);
49          assertTrue(es instanceof TestExceptionStrategy);
50          assertEquals("bar", ((TestExceptionStrategy) es).getTestProperty());
51      }
52  
53      public void testCustomTransformerConfig() throws Exception
54      {
55          Transformer trans = muleContext.getRegistry().lookupTransformer("testTransformer");
56          assertNotNull("testTransformer should not be null", trans);
57          assertTrue("Transformer should be an instance of TestCompressionTransformer", trans instanceof TestCompressionTransformer);
58          assertEquals(((TestCompressionTransformer)trans).getBeanProperty1(), "soo");
59          assertEquals(((TestCompressionTransformer)trans).getBeanProperty2(), 12345);
60      }
61  
62  }