KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > protocol > MockNetworkStackProvider


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.protocol;
5
6 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
7
8 import com.tc.exception.ImplementMe;
9 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) throws StackNotFoundException {
21     try {
22       connectTransportCalls.put(connection);
23       if (throwStackNotFoundException) {
24           throw new StackNotFoundException(null);
25       }
26     } catch (InterruptedException JavaDoc e) {
27       e.printStackTrace();
28     }
29   }
30
31   public MessageTransport waitForConnectTransportCall(long timeout) throws InterruptedException JavaDoc {
32     return (MessageTransport) connectTransportCalls.poll(timeout);
33   }
34
35   public NetworkStackHarness removeNetworkStack(ConnectionID connectionId) {
36     throw new ImplementMe();
37   }
38
39   public MessageTransport attachNewConnection(ConnectionID connectionId, TCConnection connection) {
40     throw new ImplementMe();
41   }
42
43 }
Popular Tags