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