View Javadoc

1   /*
2    * $Id: SafeProtocolMule2227TestCase.java 22485 2011-07-21 08:26:15Z justin.calleja $
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.api.MuleException;
14  import org.mule.module.client.MuleClient;
15  import org.mule.transport.tcp.protocols.SafeProtocolTestCase;
16  
17  import org.junit.Test;
18  
19  public class SafeProtocolMule2227TestCase extends SafeProtocolTestCase
20  {
21  
22      // this actually "works" much of the time, in that a response is received that looks reasonable.
23      // that's just because the test is so simple that the length encoded string is read by the
24      // server as a literal chunk of text (including the cookies and lengths!).  on the return these
25      // are still present so the data that were sent are read (missing the appended text).
26  
27      // the rest of the time, it gives an out of memory error.  that's because it responds to the
28      // cookie alone, which means that "Received" is taken as a message, and "Re" gives a length of
29      // 542270819 leading to a memory overflow
30  
31      // the only way round this i can see is to allow a parameter on the protocol to specify a
32      // maximum size.  see MULE-2449.
33  
34      // update - we now do have a maximum size
35  
36      public SafeProtocolMule2227TestCase(ConfigVariant variant, String configResources)
37      {
38          super(variant, configResources);
39      }
40  
41      @Test
42      public void testSafeToUnsafe() throws MuleException
43      {
44          MuleClient client = new MuleClient(muleContext);
45          // this may fail, but should not crash
46          try
47          {
48              client.send("tcp://localhost:" + dynamicPort1.getNumber() + "?connector=safe", TEST_MESSAGE, null);
49          }
50          catch(Exception e)
51          {
52              // an error is ok - we were losing the JVM before
53          }
54      }
55  
56  }