View Javadoc

1   /*
2    * $Id: AbstractMessageReceiverTestCase.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  
11  package org.mule.transport;
12  
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.api.service.Service;
15  import org.mule.api.transport.MessageReceiver;
16  import org.mule.tck.AbstractMuleTestCase;
17  import org.mule.tck.testmodels.fruit.Orange;
18  
19  public abstract class AbstractMessageReceiverTestCase extends AbstractMuleTestCase
20  {
21      protected Service service;
22      protected InboundEndpoint endpoint;
23  
24      protected void doSetUp() throws Exception
25      {
26          service = getTestService("orange", Orange.class);
27          endpoint = getEndpoint();
28      }
29  
30      public void testCreate() throws Exception
31      {
32          Service service = getTestService("orange", Orange.class);
33          InboundEndpoint endpoint = getTestInboundEndpoint("Test");
34          MessageReceiver receiver = getMessageReceiver();
35  
36          assertNotNull(receiver.getEndpoint());
37  
38          try
39          {
40              receiver.setEndpoint(null);
41              fail("Provider cannot be set to null");
42          }
43          catch (IllegalArgumentException e)
44          {
45              // expected
46          }
47  
48          receiver.setEndpoint(endpoint);
49          assertNotNull(receiver.getEndpoint());
50  
51          receiver.dispose();
52      }
53  
54      public abstract MessageReceiver getMessageReceiver() throws Exception;
55  
56      /**
57       * Implementations of this method should ensure that the correct connector is set
58       * on the endpoint
59       * 
60       * @throws Exception
61       */
62      public abstract InboundEndpoint getEndpoint() throws Exception;
63  }