Source Code Cross Referenced for MockTCConnection.java in  » Net » Terracotta » com » tc » net » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Terracotta » com.tc.net.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.core;
005:
006:        import com.tc.exception.ImplementMe;
007:        import com.tc.net.TCSocketAddress;
008:        import com.tc.net.core.event.TCConnectionEventListener;
009:        import com.tc.net.protocol.NetworkMessageSink;
010:        import com.tc.net.protocol.NullProtocolAdaptor;
011:        import com.tc.net.protocol.TCNetworkMessage;
012:        import com.tc.net.protocol.TCProtocolAdaptor;
013:        import com.tc.util.TCTimeoutException;
014:        import com.tc.util.concurrent.NoExceptionLinkedQueue;
015:
016:        import java.net.Socket;
017:        import java.util.ArrayList;
018:        import java.util.List;
019:
020:        /**
021:         * @deprecated use TestTCConnection instead.  This implementation has a bunch of side effects.
022:         */
023:        public class MockTCConnection implements  TCConnection {
024:
025:            private boolean isConnected;
026:            private boolean isClosed;
027:
028:            private int closeCallCount = 0;
029:            private List sentMessages = new ArrayList();
030:            private NetworkMessageSink messageSink;
031:            private final TCProtocolAdaptor protocolAdaptor = new NullProtocolAdaptor();
032:
033:            public TCSocketAddress localAddress = new TCSocketAddress(
034:                    TCSocketAddress.LOOPBACK_ADDR, 0);
035:            public TCSocketAddress remoteAddress = new TCSocketAddress(
036:                    TCSocketAddress.LOOPBACK_ADDR, 0);
037:
038:            public boolean fail = false;
039:            public final NoExceptionLinkedQueue connectCalls = new NoExceptionLinkedQueue();
040:
041:            public long getConnectTime() {
042:                throw new ImplementMe();
043:            }
044:
045:            public long getIdleTime() {
046:                throw new ImplementMe();
047:            }
048:
049:            public void addListener(TCConnectionEventListener listener) {
050:                //
051:            }
052:
053:            public void removeListener(TCConnectionEventListener listener) {
054:                //
055:            }
056:
057:            public boolean close(long timeout) {
058:                isConnected = false;
059:                isClosed = true;
060:                closeCallCount++;
061:                return true;
062:            }
063:
064:            public int getCloseCallCount() {
065:                return this .closeCallCount;
066:            }
067:
068:            public void connect(TCSocketAddress addr, int timeout)
069:                    throws TCTimeoutException {
070:                connectCalls.put(new Object[] { addr, new Integer(timeout) });
071:                if (fail) {
072:                    throw new TCTimeoutException("Timed out !!!");
073:                }
074:                this .isConnected = true;
075:            }
076:
077:            public boolean asynchConnect(TCSocketAddress addr) {
078:                return this .isConnected = true;
079:            }
080:
081:            public void isConnected(boolean b) {
082:                this .isConnected = b;
083:            }
084:
085:            public boolean isConnected() {
086:                return isConnected;
087:            }
088:
089:            public boolean isClosed() {
090:                return isClosed;
091:            }
092:
093:            public void setMessageSink(NetworkMessageSink sink) {
094:                this .messageSink = sink;
095:            }
096:
097:            public void putMessage(TCNetworkMessage message) {
098:                this .sentMessages.add(message);
099:                if (this .messageSink != null)
100:                    this .messageSink.putMessage(message);
101:            }
102:
103:            public List getSentMessages() {
104:                return this .sentMessages;
105:            }
106:
107:            public TCSocketAddress getLocalAddress() {
108:                return this .localAddress;
109:            }
110:
111:            public TCSocketAddress getRemoteAddress() {
112:                return this .remoteAddress;
113:            }
114:
115:            public TCProtocolAdaptor getProtocolAdaptor() {
116:                return this .protocolAdaptor;
117:            }
118:
119:            public void asynchClose() {
120:                close(-1);
121:            }
122:
123:            public Socket detach() {
124:                throw new ImplementMe();
125:            }
126:
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.