mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Unit tests for PaddedConnectionWriter. Also broke some shared test
code out into separate classes.
This commit is contained in:
29
test/net/sf/briar/transport/NullConnectionDecrypter.java
Normal file
29
test/net/sf/briar/transport/NullConnectionDecrypter.java
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user