1 22 package org.objectweb.petals.binding.xquarebc.mock; 23 24 import javax.jbi.messaging.DeliveryChannel; 25 import javax.jbi.messaging.MessageExchange; 26 import javax.jbi.messaging.MessageExchangeFactory; 27 import javax.jbi.messaging.MessagingException; 28 import javax.jbi.servicedesc.ServiceEndpoint; 29 import javax.xml.namespace.QName ; 30 31 import org.objectweb.petals.component.common.util.SourceHelper; 32 33 import static org.easymock.EasyMock.expect; 34 import static org.easymock.classextension.EasyMock.createMock; 35 import static org.easymock.classextension.EasyMock.replay; 36 37 42 public class MockDeliveryChannel implements DeliveryChannel { 43 44 public MessageExchange accept() throws MessagingException { 45 return null; 46 } 47 48 public MessageExchange accept(long timeoutMS) throws MessagingException, 49 IllegalArgumentException { 50 return null; 51 } 52 53 public void close() throws MessagingException { 54 } 55 56 public MessageExchangeFactory createExchangeFactory() { 57 MessageExchangeFactory messageExchangeFactory = createMock(MessageExchangeFactory.class); 58 try { 59 expect(messageExchangeFactory.createInOnlyExchange()).andReturn( 60 new MockInOnly()).anyTimes(); 61 expect(messageExchangeFactory.createRobustInOnlyExchange()) 62 .andReturn(new MockRobustInOnly()).anyTimes(); 63 expect(messageExchangeFactory.createInOutExchange()).andReturn( 64 new MockInOut()).anyTimes(); 65 } catch (MessagingException e) { 66 } 67 replay(messageExchangeFactory); 68 return messageExchangeFactory; 69 } 70 71 public MessageExchangeFactory createExchangeFactory(QName interfaceName) { 72 return null; 73 } 74 75 public MessageExchangeFactory createExchangeFactory(ServiceEndpoint endpoint) { 76 return null; 77 } 78 79 public MessageExchangeFactory createExchangeFactoryForService( 80 QName serviceName) { 81 return null; 82 } 83 84 private boolean send; 85 86 public boolean isSend() { 87 return send; 88 } 89 90 public void setSend(boolean send) { 91 this.send = send; 92 } 93 94 public void send(MessageExchange exchange) throws MessagingException { 95 send = true; 96 } 97 98 private boolean sendSync; 99 100 public boolean sendSync(MessageExchange exchange) throws MessagingException { 101 if (exchange instanceof MockInOut) { 102 MockNormalizedMessage mockNormalizedMessage = new MockNormalizedMessage(); 103 mockNormalizedMessage.setContent(SourceHelper 104 .createContentSource("test")); 105 ((MockInOut) exchange).setOutMessage(mockNormalizedMessage); 106 } 107 sendSync = true; 108 return false; 109 } 110 111 private boolean sendSyncLong; 112 113 public boolean sendSync(MessageExchange exchange, long timeoutMS) 114 throws MessagingException { 115 sendSyncLong = true; 116 return false; 117 } 118 119 public boolean isSendSync() { 120 return sendSync; 121 } 122 123 public void setSendSync(boolean sendSync) { 124 this.sendSync = sendSync; 125 } 126 127 public boolean isSendSyncLong() { 128 return sendSyncLong; 129 } 130 131 public void setSendSyncLong(boolean sendSyncLong) { 132 this.sendSyncLong = sendSyncLong; 133 } 134 135 } 136 | Popular Tags |