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