001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.net.protocol.tcm;
005:
006: import com.tc.bytes.TCByteBuffer;
007: import com.tc.exception.ImplementMe;
008: import com.tc.net.TCSocketAddress;
009: import com.tc.net.protocol.NetworkLayer;
010: import com.tc.net.protocol.NetworkStackID;
011: import com.tc.net.protocol.TCNetworkMessage;
012: import com.tc.net.protocol.transport.MessageTransport;
013: import com.tc.util.concurrent.NoExceptionLinkedQueue;
014:
015: import java.util.ArrayList;
016: import java.util.List;
017:
018: public class TestMessageChannel implements MessageChannel {
019:
020: public List createMessageContexts = new ArrayList();
021: public NoExceptionLinkedQueue sendQueue = new NoExceptionLinkedQueue();
022: public TCMessage message;
023: public ChannelID channelID;
024:
025: public void addListener(ChannelEventListener listener) {
026: return;
027: }
028:
029: public boolean isConnected() {
030: return false;
031: }
032:
033: public boolean isOpen() {
034: return false;
035: }
036:
037: public boolean isClosed() {
038: return false;
039: }
040:
041: public TCMessage createMessage(TCMessageType type) {
042: createMessageContexts.add(new CreateMessageContext(type,
043: this .message));
044: return this .message;
045: }
046:
047: public void close() {
048: return;
049: }
050:
051: public ChannelID getChannelID() {
052: return channelID;
053: }
054:
055: public void setSendLayer(NetworkLayer layer) {
056: return;
057: }
058:
059: public void setReceiveLayer(NetworkLayer layer) {
060: return;
061: }
062:
063: public void send(TCNetworkMessage msg) {
064: sendQueue.put(msg);
065: }
066:
067: public void receive(TCByteBuffer[] msgData) {
068: return;
069: }
070:
071: public NetworkStackID open() {
072: return null;
073: }
074:
075: public void notifyTransportConnected(MessageTransport transport) {
076: return;
077: }
078:
079: public void notifyTransportDisconnected(MessageTransport transport) {
080: return;
081: }
082:
083: public void notifyTransportConnectAttempt(MessageTransport transport) {
084: return;
085: }
086:
087: public void notifyTransportClosed(MessageTransport transport) {
088: return;
089: }
090:
091: public Object getAttachment(String key) {
092: throw new ImplementMe();
093: }
094:
095: public void addAttachment(String key, Object value, boolean replace) {
096: throw new ImplementMe();
097: }
098:
099: public Object removeAttachment(String key) {
100: throw new ImplementMe();
101: }
102:
103: public String getRemoteSocketInfo() {
104: throw new ImplementMe();
105: }
106:
107: public TCSocketAddress getLocalAddress() {
108: throw new ImplementMe();
109: }
110:
111: public TCSocketAddress getRemoteAddress() {
112: throw new ImplementMe();
113: }
114:
115: public static class CreateMessageContext {
116: public final TCMessageType type;
117: public final TCMessage returnedMessage;
118:
119: private CreateMessageContext(TCMessageType type,
120: TCMessage returnedMessage) {
121: this.type = type;
122: this.returnedMessage = returnedMessage;
123: }
124: }
125: }
|