1 /* 2 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 3 * The software in this package is published under the terms of the CPAL v1.0 4 * license, a copy of which has been included with this distribution in the 5 * LICENSE.txt file. 6 */ 7 package org.mule.transport.tcp.issues; 8 9 import org.mule.api.MuleException; 10 import org.mule.module.client.MuleClient; 11 import org.mule.transport.tcp.protocols.SafeProtocolTestCase; 12 13 import org.junit.Test; 14 15 public class SafeProtocolMule2227TestCase extends SafeProtocolTestCase 16 { 17 18 // this actually "works" much of the time, in that a response is received that looks reasonable. 19 // that's just because the test is so simple that the length encoded string is read by the 20 // server as a literal chunk of text (including the cookies and lengths!). on the return these 21 // are still present so the data that were sent are read (missing the appended text). 22 23 // the rest of the time, it gives an out of memory error. that's because it responds to the 24 // cookie alone, which means that "Received" is taken as a message, and "Re" gives a length of 25 // 542270819 leading to a memory overflow 26 27 // the only way round this i can see is to allow a parameter on the protocol to specify a 28 // maximum size. see MULE-2449. 29 30 // update - we now do have a maximum size 31 32 @Test 33 public void testSafeToUnsafe() throws MuleException 34 { 35 MuleClient client = new MuleClient(muleContext); 36 // this may fail, but should not crash 37 try 38 { 39 client.send("tcp://localhost:" + dynamicPort1.getNumber() + "?connector=safe", TEST_MESSAGE, null); 40 } 41 catch(Exception e) 42 { 43 // an error is ok - we were losing the JVM before 44 } 45 } 46 47 }