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.bytes.TCByteBuffer;
07:
08: import junit.framework.TestCase;
09:
10: public class TransportHandshakeMessageTest extends TestCase {
11:
12: private TransportHandshakeMessage message;
13: private TransportHandshakeMessageFactoryImpl factory;
14:
15: public void setUp() throws Exception {
16:
17: factory = new TransportHandshakeMessageFactoryImpl();
18:
19: }
20:
21: public void testSendAndReceive() throws Exception {
22: boolean isMaxConnectionsExceeded = true;
23: int maxConnections = 13;
24: DefaultConnectionIdFactory connectionIDProvider = new DefaultConnectionIdFactory();
25: ConnectionID connectionId = connectionIDProvider
26: .nextConnectionId();
27: message = factory.createSynAck(connectionId, null,
28: isMaxConnectionsExceeded, maxConnections);
29: TCByteBuffer payload[] = message.getPayload();
30:
31: WireProtocolHeader header = new WireProtocolHeader();
32: header
33: .setProtocol(WireProtocolHeader.PROTOCOL_TRANSPORT_HANDSHAKE);
34: message = new TransportHandshakeMessageImpl(null, header,
35: payload);
36: assertEquals(isMaxConnectionsExceeded, message
37: .isMaxConnectionsExceeded());
38: assertEquals(maxConnections, message.getMaxConnections());
39: }
40: }
|