View Javadoc

1   /*
2    * $Id: CustomConfigTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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  package org.mule.test.integration.config;
11  
12  import org.mule.api.endpoint.ImmutableEndpoint;
13  import org.mule.api.exception.MessagingExceptionHandler;
14  import org.mule.api.transformer.Transformer;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.tck.testmodels.mule.TestCompressionTransformer;
17  import org.mule.tck.testmodels.mule.TestConnector;
18  import org.mule.tck.testmodels.mule.TestExceptionStrategy;
19  
20  public class CustomConfigTestCase extends FunctionalTestCase
21  {
22  
23      protected String getConfigResources()
24      {
25          return "org/mule/test/integration/config/custom-config.xml";
26      }
27  
28      public void testCustomEndpointConfig() throws Exception
29      {
30          ImmutableEndpoint ep = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
31              "fooEndpoint");
32          assertNotNull("fooEndpoint should not be null", ep);
33          TestFilter tf = (TestFilter)ep.getFilter();
34          assertNotNull("the filter on the endpoint should not be null", tf);
35          assertEquals(tf.getFoo(), "goo");
36          assertEquals(tf.getBar(), 12);
37      }
38  
39      public void testCustomConnectorConfig() throws Exception
40      {
41          TestConnector cnn = (TestConnector)muleContext.getRegistry().lookupConnector("customConnector");
42          assertNotNull("customConnector should not be null", cnn);
43          assertEquals(cnn.getSomeProperty(), "foo");
44  
45          //Test exception strategy
46          MessagingExceptionHandler es = muleContext.getRegistry().lookupModel("main").getExceptionListener();
47          assertNotNull(es);
48          assertTrue(es instanceof TestExceptionStrategy);
49          assertEquals("bar", ((TestExceptionStrategy) es).getTestProperty());
50      }
51  
52      public void testCustomTransformerConfig() throws Exception
53      {
54          Transformer trans = muleContext.getRegistry().lookupTransformer("testTransformer");
55          assertNotNull("testTransformer should not be null", trans);
56          assertTrue("Transformer should be an instance of TestCompressionTransformer", trans instanceof TestCompressionTransformer);
57          assertEquals(((TestCompressionTransformer)trans).getBeanProperty1(), "soo");
58          assertEquals(((TestCompressionTransformer)trans).getBeanProperty2(), 12345);
59      }
60  
61  }