001: package org.objectweb.celtix.jbi.transport;
002:
003: import javax.jbi.messaging.DeliveryChannel;
004: import javax.xml.namespace.QName;
005:
006: import junit.framework.TestCase;
007:
008: import org.easymock.classextension.EasyMock;
009: import org.objectweb.celtix.bindings.ClientBinding;
010: import org.objectweb.celtix.bindings.ResponseCallback;
011: import org.objectweb.celtix.jbi.se.CeltixServiceUnitManager;
012: import org.objectweb.celtix.transports.ClientTransport;
013: import org.objectweb.celtix.transports.ServerTransport;
014: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
015: import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
016:
017: public class JBITransportFactoryTest extends TestCase {
018:
019: JBITransportFactory factory = new JBITransportFactory();
020:
021: private final DeliveryChannel channel = EasyMock
022: .createMock(DeliveryChannel.class);
023: private final CeltixServiceUnitManager suMgr = EasyMock
024: .createMock(CeltixServiceUnitManager.class);
025: private final EndpointReferenceType endpointRef = new EndpointReferenceType();
026:
027: public void setUp() {
028: factory.setDeliveryChannel(channel);
029: factory.setServiceUnitManager(suMgr);
030: }
031:
032: public void testGetSetDeliveryChannel() {
033:
034: factory.setDeliveryChannel(channel);
035: assertSame("get must return set value", channel, factory
036: .getDeliveryChannel());
037: }
038:
039: public void testGetSetServiceUnitManager() {
040:
041: factory.setServiceUnitManager(suMgr);
042: assertSame("get must return set value", suMgr, factory
043: .getServiceUnitManager());
044: }
045:
046: public void testCreateServerTransportNotInitialized()
047: throws Exception {
048:
049: try {
050: factory = new JBITransportFactory();
051: factory.createServerTransport(endpointRef);
052: fail("did not get expected exception");
053: } catch (IllegalStateException ex) {
054: // expected exception
055: }
056: }
057:
058: public void testCreateServerTransport() throws Exception {
059:
060: ServerTransport st = factory.createServerTransport(endpointRef);
061: assertNotNull("server transport must not be null", st);
062: assertSame("transport must JBIServerTransport",
063: JBIServerTransport.class, st.getClass());
064: }
065:
066: public void testCreateTransientServerTransport() throws Exception {
067:
068: try {
069: factory.createTransientServerTransport(endpointRef);
070: fail("did not get expected message");
071: } catch (RuntimeException ex) {
072: assertEquals("wrong message in exception",
073: "not yet implemented", ex.getMessage());
074: }
075:
076: }
077:
078: public void testCreateClientTransport() throws Exception {
079:
080: QName serviceName = new QName("", "foobar");
081: EndpointReferenceUtils.setServiceAndPortName(endpointRef,
082: serviceName, "SOAPPort");
083:
084: ClientBinding clientBinding = EasyMock
085: .createMock(ClientBinding.class);
086: ResponseCallback responseCallback = EasyMock
087: .createMock(ResponseCallback.class);
088: clientBinding.createResponseCallback();
089: EasyMock.expectLastCall().andReturn(responseCallback);
090:
091: EasyMock.replay(clientBinding);
092:
093: ClientTransport ct = factory.createClientTransport(endpointRef,
094: clientBinding);
095: assertNotNull("server transport must not be null", ct);
096: assertSame("transport must JBIClientTransport",
097: JBIClientTransport.class, ct.getClass());
098: EasyMock.verify(clientBinding);
099:
100: }
101:
102: public void testSetResponseCallback() {
103:
104: try {
105: factory.setResponseCallback(null);
106: fail("did not get expected message");
107: } catch (RuntimeException ex) {
108: assertEquals("wrong message in exception",
109: "not yet implemented", ex.getMessage());
110: }
111: }
112:
113: }
|