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("<root>");
+ while (sb.length() < targetLength) {
+ sb.append("<dummy>some xml</dummy>");
+ }
+ sb.append("</root>");
+ byte[] testBytes = sb.toString().getBytes();
+
+ jbiOS.write(testBytes);
+ jbiOS.doClose();
+
+ //Verify send method was called.
+ EasyMock.verify(channel);
}
}