1 4 package com.tc.net.protocol.transport; 5 6 import com.tc.net.core.TCConnection; 7 import com.tc.util.concurrent.NoExceptionLinkedQueue; 8 9 public class MockTransportHandshakeMessageFactory implements TransportHandshakeMessageFactory { 10 11 public TransportHandshakeMessage syn; 12 public TransportHandshakeMessage ack; 13 public TransportHandshakeMessage synAck; 14 15 public final NoExceptionLinkedQueue createSynCalls = new NoExceptionLinkedQueue(); 16 public final NoExceptionLinkedQueue createAckCalls = new NoExceptionLinkedQueue(); 17 public final NoExceptionLinkedQueue createSynAckCalls = new NoExceptionLinkedQueue(); 18 19 public TransportHandshakeMessage createSyn(ConnectionID connectionId, TCConnection source) { 20 createSynCalls.put(new Object [] { connectionId, source }); 21 return this.syn; 22 } 23 24 public TransportHandshakeMessage createAck(ConnectionID connectionId, TCConnection source) { 25 createAckCalls.put(new CallContext(connectionId, null, source, null, null)); 26 return this.ack; 27 } 28 29 public TransportHandshakeMessage createSynAck(ConnectionID connectionId, TCConnection source, 30 boolean isMaxConnectionsExceeded, int maxConnections) { 31 return createSynAck(connectionId, null, source, isMaxConnectionsExceeded, maxConnections); 32 } 33 34 public TransportHandshakeMessage createSynAck(ConnectionID connectionId, TransportHandshakeErrorContext errorContext, 35 TCConnection source, boolean isMaxConnectionsExceeded, 36 int maxConnections) { 37 createSynAckCalls.put(new CallContext(connectionId, errorContext, source, new Boolean (isMaxConnectionsExceeded), 38 new Integer (maxConnections))); 39 return this.synAck; 40 } 41 42 public static final class CallContext { 43 private final ConnectionID connectionId; 44 private final TCConnection source; 45 private final Boolean isMaxConnectionsExceeded; 46 private final Integer maxConnections; 47 private final TransportHandshakeErrorContext errorContext; 48 49 public CallContext(ConnectionID connectionId, TransportHandshakeErrorContext errorContext, TCConnection source, 50 Boolean isMaxConnectionsExceeded, Integer maxConnections) { 51 this.connectionId = connectionId; 52 this.errorContext = errorContext; 53 this.source = source; 54 this.isMaxConnectionsExceeded = isMaxConnectionsExceeded; 55 this.maxConnections = maxConnections; 56 } 57 58 public TransportHandshakeErrorContext getErrorContext() { 59 return this.errorContext; 60 } 61 62 public ConnectionID getConnectionId() { 63 return connectionId; 64 } 65 66 public Boolean getIsMaxConnectionsExceeded() { 67 return isMaxConnectionsExceeded; 68 } 69 70 public Integer getMaxConnections() { 71 return maxConnections; 72 } 73 74 public TCConnection getSource() { 75 return source; 76 } 77 } 78 79 } 80 | Popular Tags |