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