View Javadoc

1   /*
2    * $Id: AbstractMessageReceiverTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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  
11  package org.mule.tck.providers;
12  
13  import org.mule.tck.AbstractMuleTestCase;
14  import org.mule.tck.testmodels.fruit.Orange;
15  import org.mule.umo.UMOComponent;
16  import org.mule.umo.endpoint.UMOEndpoint;
17  import org.mule.umo.endpoint.UMOImmutableEndpoint;
18  import org.mule.umo.provider.UMOMessageReceiver;
19  
20  public abstract class AbstractMessageReceiverTestCase extends AbstractMuleTestCase
21  {
22      protected UMOComponent component;
23      protected UMOEndpoint endpoint;
24  
25      protected void doSetUp() throws Exception
26      {
27          component = getTestComponent(getTestDescriptor("orange", Orange.class.getName()));
28          endpoint = getEndpoint();
29      }
30  
31      public void testCreate() throws Exception
32      {
33          UMOComponent component = getTestComponent(getTestDescriptor("orange", Orange.class.getName()));
34          UMOEndpoint endpoint = getTestEndpoint("Test", UMOImmutableEndpoint.ENDPOINT_TYPE_SENDER);
35          UMOMessageReceiver receiver = getMessageReceiver();
36  
37          assertNotNull(receiver.getEndpoint());
38          assertNotNull(receiver.getConnector());
39  
40          try
41          {
42              receiver.setEndpoint(null);
43              fail("Provider cannot be set to null");
44          }
45          catch (IllegalArgumentException e)
46          {
47              // expected
48          }
49  
50          try
51          {
52              receiver.setComponent(null);
53              fail("component cannot be set to null");
54          }
55          catch (IllegalArgumentException e)
56          {
57              // expected
58          }
59  
60          receiver.setComponent(component);
61          assertNotNull(receiver.getComponent());
62          receiver.setEndpoint(endpoint);
63          assertNotNull(receiver.getEndpoint());
64  
65          receiver.dispose();
66      }
67  
68      public abstract UMOMessageReceiver getMessageReceiver() throws Exception;
69  
70      /**
71       * Implementations of this method should ensure that the correct connector is set
72       * on the endpoint
73       * 
74       * @return
75       * @throws Exception
76       */
77      public abstract UMOEndpoint getEndpoint() throws Exception;
78  }