org.jivesoftware.smackx.bytestreams.ibb
Class InBandBytestreamSessionTest

java.lang.Object
  extended by org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSessionTest

public class InBandBytestreamSessionTest
extends java.lang.Object

Test for InBandBytestreamSession.

Tests the basic behavior of an In-Band Bytestream session along with sending data encapsulated in IQ stanzas.

Author:
Henning Staib

Constructor Summary
InBandBytestreamSessionTest()
           
 
Method Summary
 void setup()
          Initialize fields used in the tests.
 void shouldCloseBothStreamsIfSessionIsClosed()
          If the session is closed the input stream and output stream should be closed as well.
 void shouldConfirmReceivedDataPacket()
          Valid data packets should be confirmed.
 void shouldNotCloseBothStreamsIfInputStreamIsClosed()
          If the output stream is closed the input stream should not be closed as well.
 void shouldNotCloseBothStreamsIfOutputStreamIsClosed()
          If the input stream is closed the output stream should not be closed as well.
 void shouldNotDeadlockIfInputStreamIsClosed()
          If the input stream is closed concurrently there should be no deadlock.
 void shouldReadAllReceivedData1()
          Test the input stream read(byte[], int, int) method.
 void shouldReadAllReceivedData2()
          Test the input stream read() method.
 void shouldReplyWithErrorIfAlreadyUsedSequenceIsReceived()
          If the data packet has a sequence that is already used an 'unexpected-request' error should be returned.
 void shouldReplyWithErrorIfDataIsInvalid()
          If the data packet contains invalid Base64 encoding an 'bad-request' error should be returned.
 void shouldSendCloseRequestIfInvalidSequenceReceived()
          If a data packet is received out of order the session should be closed.
 void shouldSendDataCorrectly()
          Test that the data is correctly chunked.
 void shouldSendNothingOnSuccessiveCallsToFlush()
          Test successive calls to the output stream flush() method.
 void shouldSendThirtyDataPackets()
          Test the output stream flush() method.
 void shouldSendThreeDataPackets1()
          Test the output stream write(byte[]) method.
 void shouldSendThreeDataPackets2()
          Test the output stream write(byte) method.
 void shouldSendThreeDataPackets3()
          Test the output stream write(byte[], int, int) method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InBandBytestreamSessionTest

public InBandBytestreamSessionTest()
Method Detail

setup

public void setup()
Initialize fields used in the tests.


shouldSendThreeDataPackets1

public void shouldSendThreeDataPackets1()
                                 throws java.lang.Exception
Test the output stream write(byte[]) method.

Throws:
java.lang.Exception - should not happen

shouldSendThreeDataPackets2

public void shouldSendThreeDataPackets2()
                                 throws java.lang.Exception
Test the output stream write(byte) method.

Throws:
java.lang.Exception - should not happen

shouldSendThreeDataPackets3

public void shouldSendThreeDataPackets3()
                                 throws java.lang.Exception
Test the output stream write(byte[], int, int) method.

Throws:
java.lang.Exception - should not happen

shouldSendThirtyDataPackets

public void shouldSendThirtyDataPackets()
                                 throws java.lang.Exception
Test the output stream flush() method.

Throws:
java.lang.Exception - should not happen

shouldSendNothingOnSuccessiveCallsToFlush

public void shouldSendNothingOnSuccessiveCallsToFlush()
                                               throws java.lang.Exception
Test successive calls to the output stream flush() method.

Throws:
java.lang.Exception - should not happen

shouldSendDataCorrectly

public void shouldSendDataCorrectly()
                             throws java.lang.Exception
Test that the data is correctly chunked.

Throws:
java.lang.Exception - should not happen

shouldNotCloseBothStreamsIfOutputStreamIsClosed

public void shouldNotCloseBothStreamsIfOutputStreamIsClosed()
                                                     throws java.lang.Exception
If the input stream is closed the output stream should not be closed as well.

Throws:
java.lang.Exception - should not happen

shouldConfirmReceivedDataPacket

public void shouldConfirmReceivedDataPacket()
                                     throws java.lang.Exception
Valid data packets should be confirmed.

Throws:
java.lang.Exception - should not happen

shouldReplyWithErrorIfAlreadyUsedSequenceIsReceived

public void shouldReplyWithErrorIfAlreadyUsedSequenceIsReceived()
                                                         throws java.lang.Exception
If the data packet has a sequence that is already used an 'unexpected-request' error should be returned. See XEP-0047 Section 2.2.

Throws:
java.lang.Exception - should not happen

shouldReplyWithErrorIfDataIsInvalid

public void shouldReplyWithErrorIfDataIsInvalid()
                                         throws java.lang.Exception
If the data packet contains invalid Base64 encoding an 'bad-request' error should be returned. See XEP-0047 Section 2.2.

Throws:
java.lang.Exception - should not happen

shouldSendCloseRequestIfInvalidSequenceReceived

public void shouldSendCloseRequestIfInvalidSequenceReceived()
                                                     throws java.lang.Exception
If a data packet is received out of order the session should be closed. See XEP-0047 Section 2.2.

Throws:
java.lang.Exception - should not happen

shouldReadAllReceivedData1

public void shouldReadAllReceivedData1()
                                throws java.lang.Exception
Test the input stream read(byte[], int, int) method.

Throws:
java.lang.Exception - should not happen

shouldReadAllReceivedData2

public void shouldReadAllReceivedData2()
                                throws java.lang.Exception
Test the input stream read() method.

Throws:
java.lang.Exception - should not happen

shouldNotCloseBothStreamsIfInputStreamIsClosed

public void shouldNotCloseBothStreamsIfInputStreamIsClosed()
                                                    throws java.lang.Exception
If the output stream is closed the input stream should not be closed as well.

Throws:
java.lang.Exception - should not happen

shouldCloseBothStreamsIfSessionIsClosed

public void shouldCloseBothStreamsIfSessionIsClosed()
                                             throws java.lang.Exception
If the session is closed the input stream and output stream should be closed as well.

Throws:
java.lang.Exception - should not happen

shouldNotDeadlockIfInputStreamIsClosed

public void shouldNotDeadlockIfInputStreamIsClosed()
                                            throws java.lang.Exception
If the input stream is closed concurrently there should be no deadlock.

Throws:
java.lang.Exception - should not happen