fun doTestTransfer(size: Int) { Thread.setDefaultUncaughtExceptionHandler(this) val start: Long val elapsed: Long val received: Int sendData = createDummyData(size) sendStreamSize = size recvStream = ByteArrayOutputStream(size) start = PseudoTCPBase.now() startClocks() try { connect() } catch (ex: IOException) { fail(ex.getMessage()) } assert_Connected_wait(kConnectTimeoutMs) val transferTout: Long = maxTransferTime(sendData.length, kMinTransferRate) val transfferInTime: Boolean = assert_Disconnected_wait(transferTout) elapsed = PseudoTCPBase.now() - start stopClocks() received = recvStream.size() assertEquals( "Transfer timeout, transferred: " + received + " required: " + sendData.length + " elapsed: " + elapsed + " limit: " + transferTout, true, transfferInTime ) assertEquals(size, received) val recvdArray: ByteArray = recvStream.toByteArray() assertArrayEquals(sendData, recvdArray) logger.log( Level.INFO, "Transferred " + received + " bytes in " + elapsed + " ms (" + size * 8 / elapsed + " Kbps" ) }
Transfers the data of < tt > size < /tt > bytes