1 package org.objectweb.celtix.jbi.transport; 2 3 import javax.jbi.messaging.DeliveryChannel; 4 import javax.xml.namespace.QName ; 5 6 import junit.framework.TestCase; 7 8 import org.easymock.classextension.EasyMock; 9 import org.objectweb.celtix.bindings.ClientBinding; 10 import org.objectweb.celtix.bindings.ResponseCallback; 11 import org.objectweb.celtix.jbi.se.CeltixServiceUnitManager; 12 import org.objectweb.celtix.transports.ClientTransport; 13 import org.objectweb.celtix.transports.ServerTransport; 14 import org.objectweb.celtix.ws.addressing.EndpointReferenceType; 15 import org.objectweb.celtix.wsdl.EndpointReferenceUtils; 16 17 public class JBITransportFactoryTest extends TestCase { 18 19 JBITransportFactory factory = new JBITransportFactory(); 20 21 private final DeliveryChannel channel = EasyMock.createMock(DeliveryChannel.class); 22 private final CeltixServiceUnitManager suMgr = EasyMock.createMock(CeltixServiceUnitManager.class); 23 private final EndpointReferenceType endpointRef = new EndpointReferenceType(); 24 25 26 public void setUp() { 27 factory.setDeliveryChannel(channel); 28 factory.setServiceUnitManager(suMgr); 29 } 30 31 32 public void testGetSetDeliveryChannel() { 33 34 factory.setDeliveryChannel(channel); 35 assertSame("get must return set value", channel, factory.getDeliveryChannel()); 36 } 37 38 public void testGetSetServiceUnitManager() { 39 40 factory.setServiceUnitManager(suMgr); 41 assertSame("get must return set value", suMgr, factory.getServiceUnitManager()); 42 } 43 44 45 public void testCreateServerTransportNotInitialized() throws Exception { 46 47 try { 48 factory = new JBITransportFactory(); 49 factory.createServerTransport(endpointRef); 50 fail("did not get expected exception"); 51 } catch (IllegalStateException ex) { 52 } 54 } 55 56 57 public void testCreateServerTransport() throws Exception { 58 59 ServerTransport st = factory.createServerTransport(endpointRef); 60 assertNotNull("server transport must not be null", st); 61 assertSame("transport must JBIServerTransport", JBIServerTransport.class, st.getClass()); 62 } 63 64 65 public void testCreateTransientServerTransport() throws Exception { 66 67 try { 68 factory.createTransientServerTransport(endpointRef); 69 fail("did not get expected message"); 70 } catch (RuntimeException ex) { 71 assertEquals("wrong message in exception", "not yet implemented", ex.getMessage()); 72 } 73 74 } 75 76 77 public void testCreateClientTransport() throws Exception { 78 79 QName serviceName = new QName ("", "foobar"); 80 EndpointReferenceUtils.setServiceAndPortName(endpointRef, serviceName, "SOAPPort"); 81 82 ClientBinding clientBinding = EasyMock.createMock(ClientBinding.class); 83 ResponseCallback responseCallback = EasyMock.createMock(ResponseCallback.class); 84 clientBinding.createResponseCallback(); 85 EasyMock.expectLastCall().andReturn(responseCallback); 86 87 EasyMock.replay(clientBinding); 88 89 ClientTransport ct = factory.createClientTransport(endpointRef, clientBinding); 90 assertNotNull("server transport must not be null", ct); 91 assertSame("transport must JBIClientTransport", JBIClientTransport.class, ct.getClass()); 92 EasyMock.verify(clientBinding); 93 94 } 95 96 97 public void testSetResponseCallback() { 98 99 try { 100 factory.setResponseCallback(null); 101 fail("did not get expected message"); 102 } catch (RuntimeException ex) { 103 assertEquals("wrong message in exception", "not yet implemented", ex.getMessage()); 104 } 105 } 106 107 } 108 | Popular Tags |