Author: ffang
Date: Sun May 31 09:15:22 2009
New Revision: 780390
URL: http://svn.apache.org/viewvc?rev=780390&view=rev
Log:
[SMX4-290]Improve test coverage :: SMX4 :: cxf-transport-nmr
Added:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
(with props)
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
(with props)
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
(with props)
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
(with props)
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/resources/
Modified:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/pom.xml
Modified: servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/pom.xml?rev=780390&r1=780389&r2=780390&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/pom.xml (original)
+++ servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/pom.xml Sun May 31
09:15:22 2009
@@ -63,6 +63,18 @@
<artifactId>org.apache.servicemix.specs.jaxb-api-2.0</artifactId>
<version>${servicemix.specs.version}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>${easymock.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java?rev=780390&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
(added)
+++
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
Sun May 31 09:15:22 2009
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.cxf.transport.nmr;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+
+import junit.framework.Assert;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.servicemix.nmr.api.NMR;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+
+
+public abstract class AbstractJBITest extends Assert {
+
+ protected Bus bus;
+ protected EndpointReferenceType target;
+ protected MessageObserver observer;
+ protected Message inMessage;
+ protected IMocksControl control;
+ protected NMR nmr;
+ @Before
+ public void setUp() {
+ BusFactory bf = BusFactory.newInstance();
+ bus = bf.createBus();
+ BusFactory.setDefaultBus(bus);
+ control = EasyMock.createNiceControl();
+ }
+
+ @After
+ public void tearDown() {
+ bus.shutdown(true);
+ if (System.getProperty("cxf.config.file") != null) {
+ System.clearProperty("cxf.config.file");
+ }
+
+ }
+
+ protected NMRConduit setupJBIConduit(boolean send, boolean decoupled) {
+ if (decoupled) {
+ // setup the reference type
+ } else {
+ target = control.createMock(EndpointReferenceType.class);
+ }
+ nmr = control.createMock(NMR.class);
+ NMRConduit jbiConduit = new NMRConduit(bus, target, nmr);
+
+ if (send) {
+ // setMessageObserver
+ observer = new MessageObserver() {
+ public void onMessage(Message m) {
+ inMessage = m;
+ }
+ };
+ jbiConduit.setMessageObserver(observer);
+ }
+
+ return jbiConduit;
+ }
+
+ protected void sendoutMessage(Conduit conduit, Message message, Boolean
isOneWay) throws IOException {
+
+ Exchange exchange = new ExchangeImpl();
+ exchange.setOneWay(isOneWay);
+ message.setExchange(exchange);
+ exchange.setInMessage(message);
+ BindingOperationInfo boi =
control.createMock(BindingOperationInfo.class);
+ exchange.put(BindingOperationInfo.class, boi);
+ try {
+ conduit.prepare(message);
+ } catch (IOException ex) {
+ assertFalse("JMSConduit can't perpare to send out message", false);
+ ex.printStackTrace();
+ }
+ OutputStream os = message.getContent(OutputStream.class);
+ assertTrue("The OutputStream should not be null ", os != null);
+ os.write("HelloWorld".getBytes());
+ os.close();
+ }
+
+
+}
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/AbstractJBITest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java?rev=780390&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
(added)
+++
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
Sun May 31 09:15:22 2009
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.cxf.transport.nmr;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+...@webservice(targetNamespace = "http://apache.org/hello_world_soap_http",
name = "Greeter")
+
+public interface Greeter {
+
+ @ResponseWrapper(localName = "testDocLitFaultResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.TestDocLitFaultResponse")
+ @RequestWrapper(localName = "testDocLitFault", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.TestDocLitFault")
+ @WebMethod
+ public void testDocLitFault(
+ @WebParam(name = "faultType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ java.lang.String faultType
+ );
+
+ @ResponseWrapper(localName = "sayHiResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.SayHiResponse")
+ @RequestWrapper(localName = "sayHi", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.SayHi")
+ @WebResult(name = "responseType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ @WebMethod
+ public java.lang.String sayHi();
+
+ @ResponseWrapper(localName = "testNillableResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.TestNillableResponse")
+ @RequestWrapper(localName = "testNillable", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.TestNillable")
+ @WebResult(name = "responseType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ @WebMethod
+ public java.lang.String testNillable(
+ @WebParam(name = "NillElem", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ java.lang.String nillElem,
+ @WebParam(name = "intElem", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ int intElem
+ );
+
+ @ResponseWrapper(localName = "greetMeLaterResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeLaterResponse")
+ @RequestWrapper(localName = "greetMeLater", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeLater")
+ @WebResult(name = "responseType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ @WebMethod
+ public java.lang.String greetMeLater(
+ @WebParam(name = "requestType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ long requestType
+ );
+
+ @ResponseWrapper(localName = "greetMeSometimeResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeSometimeResponse")
+ @RequestWrapper(localName = "greetMeSometime", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeSometime")
+ @WebResult(name = "responseType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ @WebMethod
+ public java.lang.String greetMeSometime(
+ @WebParam(name = "requestType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ java.lang.String requestType
+ );
+
+ @Oneway
+ @RequestWrapper(localName = "greetMeOneWay", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeOneWay")
+ @WebMethod
+ public void greetMeOneWay(
+ @WebParam(name = "requestType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ java.lang.String requestType
+ );
+
+ @ResponseWrapper(localName = "greetMeResponse", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMeResponse")
+ @RequestWrapper(localName = "greetMe", targetNamespace =
"http://apache.org/hello_world_soap_http/types", className =
"org.apache.hello_world_soap_http.types.GreetMe")
+ @WebResult(name = "responseType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ @WebMethod
+ public java.lang.String greetMe(
+ @WebParam(name = "requestType", targetNamespace =
"http://apache.org/hello_world_soap_http/types")
+ java.lang.String requestType
+ );
+}
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/Greeter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java?rev=780390&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
(added)
+++
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
Sun May 31 09:15:22 2009
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.cxf.transport.nmr;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.servicemix.nmr.api.Channel;
+import org.apache.servicemix.nmr.api.EndpointRegistry;
+import org.apache.servicemix.nmr.api.Exchange;
+import org.apache.servicemix.nmr.api.Pattern;
+import org.easymock.classextension.EasyMock;
+import org.junit.Test;
+
+public class NMRConduitTest extends AbstractJBITest {
+ static final Logger LOG = LogUtils.getLogger(NMRConduitTest.class);
+
+
+ @Test
+ public void testPrepare() throws Exception {
+ LOG.info("test prepare");
+ NMRConduit conduit = setupJBIConduit(false, false);
+ Message message = new MessageImpl();
+ try {
+ conduit.prepare(message);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ assertNotNull(message.getContent(OutputStream.class));
+ assertTrue(message.getContent(OutputStream.class) instanceof
NMRConduitOutputStream);
+ }
+
+ @Test
+ public void testSendOut() throws Exception {
+ LOG.info("test send");
+ NMRConduit conduit = setupJBIConduit(true, false);
+ Message message = new MessageImpl();
+ Member method = control.createMock(Member.class);
+ message.put(Method.class.getName(), method);
+
+ EasyMock.expect(method.getDeclaringClass()).andStubReturn(
+
(Class<?>)org.apache.servicemix.cxf.transport.nmr.Greeter.class);
+
+
+
+ org.apache.cxf.message.Exchange exchange = new ExchangeImpl();
+ exchange.setOneWay(false);
+ message.setExchange(exchange);
+ exchange.setInMessage(message);
+ BindingOperationInfo boi =
control.createMock(BindingOperationInfo.class);
+ BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);
+ EasyMock.expect(boi.getOutput()).andReturn(bmi);
+ exchange.put(BindingOperationInfo.class, boi);
+ Channel channel = control.createMock(Channel.class);
+ EasyMock.expect(nmr.createChannel()).andReturn(channel);
+ Exchange xchg = control.createMock(Exchange.class);
+ EasyMock.expect(channel.createExchange(Pattern.InOut)).andReturn(xchg);
+ org.apache.servicemix.nmr.api.Message inMsg =
control.createMock(org.apache.servicemix.nmr.api.Message.class);
+ EasyMock.expect(xchg.getIn()).andReturn(inMsg);
+ EndpointRegistry endpoints =
control.createMock(EndpointRegistry.class);
+ EasyMock.expect(channel.getNMR()).andReturn(nmr);
+ EasyMock.expect(nmr.getEndpointRegistry()).andReturn(endpoints);
+ org.apache.servicemix.nmr.api.Message outMsg =
control.createMock(org.apache.servicemix.nmr.api.Message.class);
+ EasyMock.expect(xchg.getOut()).andReturn(outMsg);
+
+ Source source = new StreamSource(new ByteArrayInputStream(
+ "<message>TestHelloWorld</message>".getBytes()));
+ EasyMock.expect(outMsg.getBody(Source.class)).andReturn(source);
+
+ control.replay();
+ try {
+ conduit.prepare(message);
+ } catch (IOException ex) {
+ assertFalse("JMSConduit can't perpare to send out message", false);
+ ex.printStackTrace();
+ }
+ OutputStream os = message.getContent(OutputStream.class);
+ assertTrue("The OutputStream should not be null ", os != null);
+ os.write("HelloWorld".getBytes());
+ os.close();
+ InputStream is = inMessage.getContent(InputStream.class);
+ assertNotNull(is);
+ XMLStreamReader reader = StaxUtils.createXMLStreamReader(is, null);
+ assertNotNull(reader);
+ reader.nextTag();
+
+ String reponse = reader.getElementText();
+ assertEquals("The reponse date should be equals", reponse,
"TestHelloWorld");
+ }
+}
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRConduitTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java?rev=780390&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
(added)
+++
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
Sun May 31 09:15:22 2009
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.cxf.transport.nmr;
+
+import java.util.logging.Logger;
+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.apache.servicemix.nmr.api.Channel;
+import org.easymock.EasyMock;
+
+
+import org.junit.Test;
+
+public class NMRDestinationTest extends AbstractJBITest {
+ static final Logger LOG = LogUtils.getLogger(NMRDestinationTest.class);
+ @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.
+ org.apache.servicemix.nmr.api.Message normalizedMessage =
control.createMock(org.apache.servicemix.nmr.api.Message.class);
+ Channel channel = control.createMock(Channel.class);
+ Exchange exchange = new ExchangeImpl();
+ exchange.setOneWay(false);
+ Message message = new MessageImpl();
+ message.setExchange(exchange);
+
+
+ org.apache.servicemix.nmr.api.Exchange messageExchange =
control.createMock(org.apache.servicemix.nmr.api.Exchange.class);
+ EasyMock.expect(messageExchange.getOut()).andReturn(normalizedMessage);
+ message.put(org.apache.servicemix.nmr.api.Exchange.class,
messageExchange);
+ channel.send(messageExchange);
+ EasyMock.replay(channel);
+
+ NMRDestinationOutputStream jbiOS = new
NMRDestinationOutputStream(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);
+ }
+}
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
servicemix/smx4/features/trunk/cxf/cxf-transport-nmr/src/test/java/org/apache/servicemix/cxf/transport/nmr/NMRDestinationTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date