Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 32182 invoked from network); 14 Apr 2008 15:58:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Apr 2008 15:58:17 -0000 Received: (qmail 61934 invoked by uid 500); 14 Apr 2008 15:58:17 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 61880 invoked by uid 500); 14 Apr 2008 15:58:17 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 61871 invoked by uid 99); 14 Apr 2008 15:58:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Apr 2008 08:58:17 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Apr 2008 15:57:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 14E4D1A983E; Mon, 14 Apr 2008 08:57:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r647867 - /incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java Date: Mon, 14 Apr 2008 15:57:51 -0000 To: cxf-commits@incubator.apache.org From: seanoc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080414155756.14E4D1A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: seanoc Date: Mon Apr 14 08:57:48 2008 New Revision: 647867 URL: http://svn.apache.org/viewvc?rev=647867&view=rev Log: Adding test for CXF-1058. Passes on 2.1 Modified: incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java Modified: incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java?rev=647867&r1=647866&r2=647867&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java (original) +++ incubator/cxf/trunk/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIDestinationTest.java Mon Apr 14 08:57:48 2008 @@ -20,8 +20,17 @@ package org.apache.cxf.transport.jbi; import java.util.logging.Logger; - +import javax.jbi.messaging.DeliveryChannel; +import javax.jbi.messaging.MessageExchange; +import javax.jbi.messaging.NormalizedMessage; import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.ExchangeImpl; +import org.apache.cxf.message.Message; +import org.apache.cxf.message.MessageImpl; +import org.easymock.EasyMock; + + import org.junit.Test; public class JBIDestinationTest extends AbstractJBITest { @@ -29,5 +38,43 @@ @Test public void testDestination() throws Exception { LOG.info("JBI destination test"); + } + + @Test + public void testOutputStreamSubstitutionDoesntCauseExceptionInDoClose() throws Exception { + //Create enough of the object structure to get through the code. + NormalizedMessage normalizedMessage = control.createMock(NormalizedMessage.class); + channel = control.createMock(DeliveryChannel.class); + Exchange exchange = new ExchangeImpl(); + exchange.setOneWay(false); + Message message = new MessageImpl(); + message.setExchange(exchange); + + + MessageExchange messageExchange = control.createMock(MessageExchange.class); + EasyMock.expect(messageExchange.createMessage()).andReturn(normalizedMessage); + message.put(MessageExchange.class, messageExchange); + channel.send(messageExchange); + EasyMock.replay(channel); + + JBIDestinationOutputStream jbiOS = new JBIDestinationOutputStream(message, channel); + + //Create array of more than what is in threshold in CachedOutputStream, + //though the threshold in CachedOutputStream should be made protected + //perhaps so it can be referenced here in case it ever changes. + int targetLength = 64 * 1025; + StringBuffer sb = new StringBuffer(); + sb.append(""); + while (sb.length() < targetLength) { + sb.append("some xml"); + } + sb.append(""); + byte[] testBytes = sb.toString().getBytes(); + + jbiOS.write(testBytes); + jbiOS.doClose(); + + //Verify send method was called. + EasyMock.verify(channel); } }