Session { synchronized int setSendingData(ByteBuffer data) { final int remaining = data.remaining(); sendingStream.write(data.array(), data.position(), data.remaining()); return remaining; } Session(int sourceIp, int sourcePort, int destinationIp, int destinationPort); boolean isClientWindowFull(); synchronized void addReceivedData(byte[] data); synchronized byte[] getReceivedData(int maxSize); boolean hasReceivedData(); synchronized byte[] getSendingData(); boolean hasDataToSend(); int getDestIp(); int getDestPort(); long getSendNext(); void setSendNext(long sendNext); int getMaxSegmentSize(); boolean isConnected(); void setConnected(boolean isConnected); int getSourceIp(); int getSourcePort(); long getRecSequence(); AbstractSelectableChannel getChannel(); void setChannel(AbstractSelectableChannel channel); boolean hasReceivedLastSegment(); void setHasReceivedLastSegment(boolean hasReceivedLastSegment); synchronized IPv4Header getLastIpHeader(); synchronized TCPHeader getLastTcpHeader(); synchronized UDPHeader getLastUdpHeader(); boolean isDataForSendingReady(); void setUnackData(byte[] unackData); void setResendPacketCounter(int resendPacketCounter); int getTimestampSender(); int getTimestampReplyto(); boolean isBusyRead(); void setBusyread(boolean isbusyread); boolean isBusywrite(); void setBusywrite(boolean isbusywrite); boolean isAbortingConnection(); void setAbortingConnection(boolean abortingConnection); SelectionKey getSelectionKey(); public long connectionStartTime; }
@Test public void setSendingData() { final Session session = new Session(1, 2, 3, 4); final byte[] test = "Hello, World.".getBytes(); final ByteBuffer buffer = ByteBuffer.wrap(test); for (int i = 0; i < 5; i++) buffer.get(); session.setSendingData(buffer); final byte[] actual = session.getSendingData(); final byte[] result = ", World.".getBytes(); assertArrayEquals(result, actual); }