View Javadoc

1   /*
2    * $Id: UdpResponseTransformerTestCase.java 22450 2011-07-19 08:20:41Z dirk.olmes $
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.udp.functional;
12  
13  import org.mule.tck.junit4.FunctionalTestCase;
14  import org.mule.tck.junit4.rule.DynamicPort;
15  import org.mule.transport.udp.util.UdpClient;
16  
17  import org.junit.Rule;
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  
22  public class UdpResponseTransformerTestCase extends FunctionalTestCase
23  {
24  
25      @Rule
26      public DynamicPort dynamicPort = new DynamicPort("port1");
27  
28      @Override
29      protected String getConfigResources()
30      {
31          return "udp-response-transformer-config.xml";
32      }
33  
34      @Test
35      public void testResponseTransformer() throws Exception
36      {
37          UdpClient client = null;
38          try
39          {
40              client = new UdpClient(dynamicPort.getNumber());
41              byte[] response = client.send(TEST_MESSAGE);
42  
43              String expected = TEST_MESSAGE + " In Out Out2";
44              String result = new String(response).trim();
45              assertEquals(expected, result);
46          }
47          finally
48          {
49              if (client != null)
50              {
51                  client.shutdown();
52              }
53          }
54      }
55  }