Added reasonable testing for StreamReciever, further testing would probably need StreamReciever to be rewritten #story[817]

This commit is contained in:
Peter Galloway
2017-04-28 18:29:35 +12:00
parent fe480d5cb6
commit 07bbd7e06d
2 changed files with 114 additions and 3 deletions
@@ -19,6 +19,7 @@ public class StreamReceiver {
public StreamReceiver(String hostAddress, int hostPort, PriorityBlockingQueue packetBuffer) {
try {
host = new Socket(hostAddress, hostPort);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
@@ -26,6 +27,12 @@ public class StreamReceiver {
this.packetBuffer = packetBuffer;
}
public StreamReceiver(Socket host, PriorityBlockingQueue packetBuffer){
this.host=host;
this.packetBuffer = packetBuffer;
}
public void connect(){
try {
stream = host.getInputStream();
@@ -66,7 +73,6 @@ public class StreamReceiver {
} catch (Exception e) {
moreBytes = false;
}
}
}
@@ -100,8 +106,8 @@ public class StreamReceiver {
}
/**
* takes an array of up to 7 bytes and returns a positive
* long constructed from the input bytes
* takes an array of up to 7 bytes in little endian format and
* returns a positive long constructed from the input bytes
*
* @return a positive long if there is less than 7 bytes -1 otherwise
*/