summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-02-08 12:30:12 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-02-16 11:02:39 (GMT)
commit2ebf488dfee7156fbbe0b3d3eccebe13d86a8634 (patch)
tree8f0c873e2048e9f3a5bca51f358f60b21e690dd2 /src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java
parent810abab2eb236c68c75025e383609d952af71e4f (diff)
downloadstroke-2ebf488dfee7156fbbe0b3d3eccebe13d86a8634.zip
stroke-2ebf488dfee7156fbbe0b3d3eccebe13d86a8634.tar.bz2
Add the FileTransfer tests
Add the missing FileTransfer tests to stroke. When porting the tests I found some of them were failing and required changes to the classes being tested to fix. Had to add a DummyNetworkEnvironment as well for the OutgoingJingleFileTransferTest. Test-information: All unit tests pass. Change-Id: Id511a556ef3a5d66e0e107f36f736db3bbb3a437
Diffstat (limited to 'src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java')
-rw-r--r--src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java
index 8452e36..8facca0 100644
--- a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java
+++ b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java
@@ -15,6 +15,7 @@ import com.isode.stroke.network.Connection;
import com.isode.stroke.network.HostAddressPort;
import com.isode.stroke.base.ByteArray;
import com.isode.stroke.base.SafeByteArray;
+import com.isode.stroke.base.StartStoppable;
import com.isode.stroke.signals.SignalConnection;
import com.isode.stroke.signals.Signal1;
import com.isode.stroke.signals.Signal;
@@ -23,11 +24,11 @@ import com.isode.stroke.signals.Slot1;
import java.util.logging.Logger;
-public class SOCKS5BytestreamServerSession extends SOCKS5AbstractBytestreamSession {
+public class SOCKS5BytestreamServerSession extends SOCKS5AbstractBytestreamSession implements StartStoppable {
private Connection connection;
private SOCKS5BytestreamRegistry bytestreams;
- private ByteArray unprocessedData;
+ private ByteArray unprocessedData = new ByteArray();
private State state;
private int chunkSize;
private String streamID = "";
@@ -131,8 +132,12 @@ public class SOCKS5BytestreamServerSession extends SOCKS5AbstractBytestreamSess
disconnectedConnection.disconnect();
dataReadConnection.disconnect();
- dataWrittenConnection.disconnect();
- dataAvailableConnection.disconnect();
+ if (dataWrittenConnection != null) {
+ dataWrittenConnection.disconnect();
+ }
+ if (dataAvailableConnection != null) {
+ dataAvailableConnection.disconnect();
+ }
readBytestream = null;
state = State.Finished;
if (error) {
@@ -180,10 +185,10 @@ public class SOCKS5BytestreamServerSession extends SOCKS5AbstractBytestreamSess
unprocessedData.clear();
streamID = requestID.toString();
boolean hasBytestream = bytestreams.hasBytestream(streamID);
- SafeByteArray result = new SafeByteArray("0x05");
+ SafeByteArray result = new SafeByteArray((byte)0x05);
result.append(hasBytestream ? (byte)0x0 : (byte)0x4);
result.append(new ByteArray(new byte[]{0x00, 0x03}));
- result.append(Integer.toString(requestID.getSize()));
+ result.append((byte)requestID.getSize());
result.append(requestID.append(new ByteArray(new byte[]{0x00, 0x00})));
if (!hasBytestream) {
logger_.fine("Readstream or Wrtiestream with ID " + streamID + " not found!\n");