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;
05:
06: import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
07:
08: import com.tc.exception.ImplementMe;
09: import com.tc.net.core.TCConnection;
10: import com.tc.net.protocol.transport.ConnectionID;
11: import com.tc.net.protocol.transport.MessageTransport;
12: import com.tc.net.protocol.transport.NetworkStackProvider;
13:
14: public class MockNetworkStackProvider implements NetworkStackProvider {
15:
16: private final LinkedQueue connectTransportCalls = new LinkedQueue();
17:
18: public boolean throwStackNotFoundException = false;
19:
20: public void attachNewConnection(TCConnection connection)
21: throws StackNotFoundException {
22: try {
23: connectTransportCalls.put(connection);
24: if (throwStackNotFoundException) {
25: throw new StackNotFoundException(null);
26: }
27: } catch (InterruptedException e) {
28: e.printStackTrace();
29: }
30: }
31:
32: public MessageTransport waitForConnectTransportCall(long timeout)
33: throws InterruptedException {
34: return (MessageTransport) connectTransportCalls.poll(timeout);
35: }
36:
37: public NetworkStackHarness removeNetworkStack(
38: ConnectionID connectionId) {
39: throw new ImplementMe();
40: }
41:
42: public MessageTransport attachNewConnection(
43: ConnectionID connectionId, TCConnection connection) {
44: throw new ImplementMe();
45: }
46:
47: }
|