forked from I2P_Developers/i2p.i2p
Fix net.i2p.data.*Key tests, remove dead code
Broken in 463f5347b682f23a159bdeb06ffc8f55c5c2cff7 by an underlying API change. The dead code threw the previously-expected exception.
This commit is contained in:
@ -80,10 +80,8 @@ public abstract class SimpleDataStructure extends DataStructureImpl {
|
||||
throw new RuntimeException("Data already set");
|
||||
int length = length();
|
||||
_data = new byte[length];
|
||||
int read = read(in, _data);
|
||||
if (read != length)
|
||||
throw new DataFormatException("EOF reading " + getClass().getSimpleName() +
|
||||
", read: " + read + ", required: " + length);
|
||||
// Throws on incomplete read
|
||||
read(in, _data);
|
||||
}
|
||||
|
||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.EOFException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@ -87,8 +88,8 @@ public class PrivateKeyTest extends StructureTest {
|
||||
PrivateKey privateKey = new PrivateKey();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||
|
||||
exception.expect(DataFormatException.class);
|
||||
exception.expectMessage("EOF reading PrivateKey, read: 31, required: " + PrivateKey.KEYSIZE_BYTES);
|
||||
exception.expect(EOFException.class);
|
||||
exception.expectMessage("EOF after reading 31 bytes of " + PrivateKey.KEYSIZE_BYTES + " byte value");
|
||||
privateKey.readBytes(in);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.EOFException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@ -88,8 +89,8 @@ public class PublicKeyTest extends StructureTest {
|
||||
PublicKey publicKey = new PublicKey();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||
|
||||
exception.expect(DataFormatException.class);
|
||||
exception.expectMessage("EOF reading PublicKey, read: 31, required: " + PublicKey.KEYSIZE_BYTES);
|
||||
exception.expect(EOFException.class);
|
||||
exception.expectMessage("EOF after reading 31 bytes of " + PublicKey.KEYSIZE_BYTES + " byte value");
|
||||
publicKey.readBytes(in);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.EOFException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@ -88,8 +89,8 @@ public class SigningPrivateKeyTest extends StructureTest {
|
||||
SigningPrivateKey signingPrivateKey = new SigningPrivateKey();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("short"));
|
||||
|
||||
exception.expect(DataFormatException.class);
|
||||
exception.expectMessage("EOF reading SigningPrivateKey, read: 5, required: " + SigningPrivateKey.KEYSIZE_BYTES);
|
||||
exception.expect(EOFException.class);
|
||||
exception.expectMessage("EOF after reading 5 bytes of " + SigningPrivateKey.KEYSIZE_BYTES + " byte value");
|
||||
signingPrivateKey.readBytes(in);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.EOFException;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@ -88,8 +89,8 @@ public class SigningPublicKeyTest extends StructureTest {
|
||||
SigningPublicKey publicKey = new SigningPublicKey();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||
|
||||
exception.expect(DataFormatException.class);
|
||||
exception.expectMessage("EOF reading SigningPublicKey, read: 31, required: " + SigningPublicKey.KEYSIZE_BYTES);
|
||||
exception.expect(EOFException.class);
|
||||
exception.expectMessage("EOF after reading 31 bytes of " + SigningPublicKey.KEYSIZE_BYTES + " byte value");
|
||||
publicKey.readBytes(in);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user