View Javadoc

1   /*
2    * $Id: MuleMessageLengthTestCase.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.tcp.protocols;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.junit4.rule.DynamicPort;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  
21  import org.junit.Rule;
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  
25  import static org.junit.Assert.assertEquals;
26  
27  public class MuleMessageLengthTestCase extends AbstractServiceAndFlowTestCase
28  {
29      protected static String TEST_MESSAGE = "Test TCP Request";
30  
31      @Rule
32      public DynamicPort port1 = new DynamicPort("port1");
33  
34  
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{{ConfigVariant.SERVICE, "tcp-mplength-test-service.xml"},
39              {ConfigVariant.FLOW, "tcp-mplength-test-flow.xml"}});
40      }
41  
42      public MuleMessageLengthTestCase(ConfigVariant variant, String configResources)
43      {
44          super(variant, configResources);
45      }
46  
47      @Test
48      public void testSend() throws Exception
49      {
50          MuleClient client = new MuleClient(muleContext);
51          MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, null);
52          assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
53      }
54  }