1 18 package org.apache.activemq.broker; 19 20 import java.io.IOException ; 21 22 import junit.framework.Test; 23 24 import org.apache.activemq.command.Command; 25 import org.apache.activemq.command.Response; 26 import org.apache.activemq.openwire.OpenWireFormat; 27 import org.apache.activemq.wireformat.WireFormat; 28 29 34 public class MarshallingBrokerTest extends BrokerTest { 35 36 public WireFormat wireFormat = new OpenWireFormat(); 37 38 public void initCombos() { 39 40 OpenWireFormat wf1 = new OpenWireFormat(); 41 wf1.setCacheEnabled(false); 42 OpenWireFormat wf2 = new OpenWireFormat(); 43 wf2.setCacheEnabled(true); 44 45 addCombinationValues( "wireFormat", new Object []{ 46 wf1, 47 wf2, 48 }); 49 } 50 51 protected StubConnection createConnection() throws Exception { 52 return new StubConnection(broker) { 53 public Response request(Command command) throws Exception { 54 Response r = super.request((Command) wireFormat.unmarshal(wireFormat.marshal(command))); 55 if( r != null ) { 56 r = (Response) wireFormat.unmarshal(wireFormat.marshal(r)); 57 } 58 return r; 59 } 60 public void send(Command command) throws Exception { 61 super.send((Command) wireFormat.unmarshal(wireFormat.marshal(command))); 62 } 63 protected void dispatch(Command command) throws InterruptedException , IOException { 64 super.dispatch((Command) wireFormat.unmarshal(wireFormat.marshal(command))); 65 }; 66 }; 67 } 68 public static Test suite() { 69 return suite(MarshallingBrokerTest.class); 70 } 71 72 public static void main(String [] args) { 73 junit.textui.TestRunner.run(suite()); 74 } 75 76 77 } 78 | Popular Tags |