01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.net.protocol.transport;
05:
06: import com.tc.net.core.TCConnection;
07: import com.tc.util.concurrent.NoExceptionLinkedQueue;
08:
09: public class MockTransportHandshakeMessageFactory implements
10: TransportHandshakeMessageFactory {
11:
12: public TransportHandshakeMessage syn;
13: public TransportHandshakeMessage ack;
14: public TransportHandshakeMessage synAck;
15:
16: public final NoExceptionLinkedQueue createSynCalls = new NoExceptionLinkedQueue();
17: public final NoExceptionLinkedQueue createAckCalls = new NoExceptionLinkedQueue();
18: public final NoExceptionLinkedQueue createSynAckCalls = new NoExceptionLinkedQueue();
19:
20: public TransportHandshakeMessage createSyn(
21: ConnectionID connectionId, TCConnection source) {
22: createSynCalls.put(new Object[] { connectionId, source });
23: return this .syn;
24: }
25:
26: public TransportHandshakeMessage createAck(
27: ConnectionID connectionId, TCConnection source) {
28: createAckCalls.put(new CallContext(connectionId, null, source,
29: null, null));
30: return this .ack;
31: }
32:
33: public TransportHandshakeMessage createSynAck(
34: ConnectionID connectionId, TCConnection source,
35: boolean isMaxConnectionsExceeded, int maxConnections) {
36: return createSynAck(connectionId, null, source,
37: isMaxConnectionsExceeded, maxConnections);
38: }
39:
40: public TransportHandshakeMessage createSynAck(
41: ConnectionID connectionId,
42: TransportHandshakeErrorContext errorContext,
43: TCConnection source, boolean isMaxConnectionsExceeded,
44: int maxConnections) {
45: createSynAckCalls.put(new CallContext(connectionId,
46: errorContext, source, new Boolean(
47: isMaxConnectionsExceeded), new Integer(
48: maxConnections)));
49: return this .synAck;
50: }
51:
52: public static final class CallContext {
53: private final ConnectionID connectionId;
54: private final TCConnection source;
55: private final Boolean isMaxConnectionsExceeded;
56: private final Integer maxConnections;
57: private final TransportHandshakeErrorContext errorContext;
58:
59: public CallContext(ConnectionID connectionId,
60: TransportHandshakeErrorContext errorContext,
61: TCConnection source, Boolean isMaxConnectionsExceeded,
62: Integer maxConnections) {
63: this .connectionId = connectionId;
64: this .errorContext = errorContext;
65: this .source = source;
66: this .isMaxConnectionsExceeded = isMaxConnectionsExceeded;
67: this .maxConnections = maxConnections;
68: }
69:
70: public TransportHandshakeErrorContext getErrorContext() {
71: return this .errorContext;
72: }
73:
74: public ConnectionID getConnectionId() {
75: return connectionId;
76: }
77:
78: public Boolean getIsMaxConnectionsExceeded() {
79: return isMaxConnectionsExceeded;
80: }
81:
82: public Integer getMaxConnections() {
83: return maxConnections;
84: }
85:
86: public TCConnection getSource() {
87: return source;
88: }
89: }
90:
91: }
|