Unit tests for PaddedConnectionWriter. Also broke some shared test

code out into separate classes.
This commit is contained in:
akwizgran
2011-08-19 19:47:24 +02:00
parent 4e2a74858b
commit d11f7ef824
6 changed files with 252 additions and 99 deletions

View File

@@ -0,0 +1,29 @@
package net.sf.briar.transport;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
/** A ConnectionDecrypter that performs no decryption. */
class NullConnectionDecrypter implements ConnectionDecrypter {
private final InputStream in;
NullConnectionDecrypter(InputStream in) {
this.in = in;
}
public InputStream getInputStream() {
return in;
}
public void readMac(byte[] mac) throws IOException {
int offset = 0;
while(offset < mac.length) {
int read = in.read(mac, offset, mac.length - offset);
if(read == -1) break;
offset += read;
}
if(offset < mac.length) throw new EOFException();
}
}