1   /*
2    * $Id: TcpRemoteSyncTestCase.java 10789 2008-02-12 20:04:43Z 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  package org.mule.transport.tcp;
11  
12  import org.mule.DefaultMuleMessage;
13  import org.mule.api.MuleMessage;
14  import org.mule.api.config.MuleProperties;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class TcpRemoteSyncTestCase extends FunctionalTestCase
22  {
23     
24     public static final String message = "mule";
25     
26     protected String getConfigResources() 
27     {
28         return "tcp-remotesync.xml";
29     }
30     
31     public void testTcpTcpRemoteSync() throws Exception
32     {
33         MuleClient client = new MuleClient();
34         Map props = new HashMap();
35         
36         //must notify the client to wait for a response from the server
37         props.put(MuleProperties.MULE_REMOTE_SYNC_PROPERTY, Boolean.TRUE);
38         MuleMessage reply = client.send("tcp://localhost:6161", new DefaultMuleMessage(message), props);
39  
40         assertNotNull(reply);
41         assertNotNull(reply.getPayload());
42         assertEquals("Received: " + message, reply.getPayloadAsString());
43         
44     }
45      
46      public void testTcpVmRemoteSync() throws Exception
47      {
48          MuleClient client = new MuleClient();
49          Map props = new HashMap();
50          
51          //must notify the client to wait for a response from the server
52          props.put(MuleProperties.MULE_REMOTE_SYNC_PROPERTY, Boolean.TRUE);
53          
54          MuleMessage reply = client.send("tcp://localhost:6163", new DefaultMuleMessage(message), props);
55  
56          assertNotNull(reply);
57          assertNotNull(reply.getPayload());
58          assertEquals("Received: " + message, reply.getPayloadAsString());
59          
60      }
61  
62  }