KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > protocol > transport > TransportHandshakeMessageTest


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