1 22 package org.objectweb.petals.engine.csv.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 45 public class MockDeliveryChannel implements DeliveryChannel { 46 47 public MessageExchange accept() throws MessagingException { 48 return null; 49 } 50 51 public MessageExchange accept(long timeoutMS) throws MessagingException, 52 IllegalArgumentException { 53 return null; 54 } 55 56 public void close() throws MessagingException { 57 } 58 59 public MessageExchangeFactory createExchangeFactory() { 60 MessageExchangeFactory messageExchangeFactory = createMock(MessageExchangeFactory.class); 61 try { 62 expect(messageExchangeFactory.createInOnlyExchange()).andReturn( 63 new MockInOnly()).anyTimes(); 64 expect(messageExchangeFactory.createRobustInOnlyExchange()) 65 .andReturn(new MockRobustInOnly()).anyTimes(); 66 expect(messageExchangeFactory.createInOutExchange()).andReturn( 67 new MockInOut()).anyTimes(); 68 } catch (MessagingException e) { 69 } 70 replay(messageExchangeFactory); 71 return messageExchangeFactory; 72 } 73 74 public MessageExchangeFactory createExchangeFactory(QName interfaceName) { 75 return null; 76 } 77 78 public MessageExchangeFactory createExchangeFactory(ServiceEndpoint endpoint) { 79 return null; 80 } 81 82 public MessageExchangeFactory createExchangeFactoryForService( 83 QName serviceName) { 84 return null; 85 } 86 87 private boolean send; 88 89 public boolean isSend() { 90 return send; 91 } 92 93 public void setSend(boolean send) { 94 this.send = send; 95 } 96 97 public void send(MessageExchange exchange) throws MessagingException { 98 send = true; 99 } 100 101 private boolean sendSync; 102 103 public boolean sendSync(MessageExchange exchange) throws MessagingException { 104 if (exchange instanceof MockInOut){ 105 MockNormalizedMessage mockNormalizedMessage = new MockNormalizedMessage(); 106 mockNormalizedMessage.setContent(SourceHelper.createContentSource("test")); 107 ((MockInOut) exchange).setOutMessage(mockNormalizedMessage); 108 } 109 sendSync = true; 110 return false; 111 } 112 113 private boolean sendSyncLong; 114 115 public boolean sendSync(MessageExchange exchange, long timeoutMS) 116 throws MessagingException { 117 sendSyncLong = true; 118 return false; 119 } 120 121 public boolean isSendSync() { 122 return sendSync; 123 } 124 125 public void setSendSync(boolean sendSync) { 126 this.sendSync = sendSync; 127 } 128 129 public boolean isSendSyncLong() { 130 return sendSyncLong; 131 } 132 133 public void setSendSyncLong(boolean sendSyncLong) { 134 this.sendSyncLong = sendSyncLong; 135 } 136 137 } 138 | Popular Tags |