View Javadoc

1   /*
2    * $Id: SynchStreamingMule1687TestCase.java 20321 2010-11-24 15:21:24Z 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.tcp.issues;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.endpoint.InboundEndpoint;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.DynamicPortTestCase;
18  
19  import java.io.ByteArrayInputStream;
20  import java.io.InputStream;
21  
22  public class SynchStreamingMule1687TestCase extends DynamicPortTestCase
23  {
24      public static final String TEST_MESSAGE = "Test TCP Request";
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "tcp-synch-streaming-test.xml";
30      }
31  
32      public void testSendAndRequest() throws Exception
33      {
34          MuleClient client = new MuleClient(muleContext);
35          ByteArrayInputStream stream = new ByteArrayInputStream(TEST_MESSAGE.getBytes());
36          MuleMessage request = new DefaultMuleMessage(stream, muleContext);
37          MuleMessage message = client.send(((InboundEndpoint) client.getMuleContext().getRegistry().lookupObject("inEcho")).getAddress(), request);
38          assertNotNull(message);
39  
40          Object payload = message.getPayload();
41          assertTrue(payload instanceof InputStream);
42          assertEquals("Some value - set to make test ok", message.getPayloadAsString());
43      }
44  
45      @Override
46      protected int getNumPortsToFind()
47      {
48          return 1;
49      }
50  }