View Javadoc

1   /*
2    * $Id: IndirectReceiveMule1842TestCase.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.transport.file.issues;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.api.service.Service;
16  import org.mule.api.source.CompositeMessageSource;
17  import org.mule.module.client.MuleClient;
18  import org.mule.transport.file.AbstractFileFunctionalTestCase;
19  
20  import java.io.File;
21  
22  /**
23   * This used to be part of FileFunctionalTest; moved here to allow isolation of individual case.
24   */
25  public class IndirectReceiveMule1842TestCase extends AbstractFileFunctionalTestCase
26  {
27  
28      public void testIndirectRequest() throws Exception
29      {
30          File target = initForRequest();
31  
32          // add a receiver endpoint that will poll the readFromDirectory
33          Service relay = muleContext.getRegistry().lookupService("relay");
34          assertNotNull(relay);
35          String url = fileToUrl(target) + "?connector=receiveConnector";
36          logger.debug(url);
37          
38          InboundEndpoint endpoint = 
39              muleContext.getEndpointFactory().getInboundEndpoint(url);
40          ((CompositeMessageSource) relay.getMessageSource()).addSource(endpoint);
41          relay.stop();
42          relay.start();
43  
44          // then read from the queue that the polling receiver will write to
45          MuleClient client = new MuleClient(muleContext);
46          MuleMessage message = client.request("receive", 3000);
47          checkReceivedMessage(message);
48      }
49  
50  }