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");
|
throw new RuntimeException("Data already set");
|
||||||
int length = length();
|
int length = length();
|
||||||
_data = new byte[length];
|
_data = new byte[length];
|
||||||
int read = read(in, _data);
|
// Throws on incomplete read
|
||||||
if (read != length)
|
read(in, _data);
|
||||||
throw new DataFormatException("EOF reading " + getClass().getSimpleName() +
|
|
||||||
", read: " + read + ", required: " + length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
|
||||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -87,8 +88,8 @@ public class PrivateKeyTest extends StructureTest {
|
|||||||
PrivateKey privateKey = new PrivateKey();
|
PrivateKey privateKey = new PrivateKey();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||||
|
|
||||||
exception.expect(DataFormatException.class);
|
exception.expect(EOFException.class);
|
||||||
exception.expectMessage("EOF reading PrivateKey, read: 31, required: " + PrivateKey.KEYSIZE_BYTES);
|
exception.expectMessage("EOF after reading 31 bytes of " + PrivateKey.KEYSIZE_BYTES + " byte value");
|
||||||
privateKey.readBytes(in);
|
privateKey.readBytes(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -88,8 +89,8 @@ public class PublicKeyTest extends StructureTest {
|
|||||||
PublicKey publicKey = new PublicKey();
|
PublicKey publicKey = new PublicKey();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||||
|
|
||||||
exception.expect(DataFormatException.class);
|
exception.expect(EOFException.class);
|
||||||
exception.expectMessage("EOF reading PublicKey, read: 31, required: " + PublicKey.KEYSIZE_BYTES);
|
exception.expectMessage("EOF after reading 31 bytes of " + PublicKey.KEYSIZE_BYTES + " byte value");
|
||||||
publicKey.readBytes(in);
|
publicKey.readBytes(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -88,8 +89,8 @@ public class SigningPrivateKeyTest extends StructureTest {
|
|||||||
SigningPrivateKey signingPrivateKey = new SigningPrivateKey();
|
SigningPrivateKey signingPrivateKey = new SigningPrivateKey();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("short"));
|
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("short"));
|
||||||
|
|
||||||
exception.expect(DataFormatException.class);
|
exception.expect(EOFException.class);
|
||||||
exception.expectMessage("EOF reading SigningPrivateKey, read: 5, required: " + SigningPrivateKey.KEYSIZE_BYTES);
|
exception.expectMessage("EOF after reading 5 bytes of " + SigningPrivateKey.KEYSIZE_BYTES + " byte value");
|
||||||
signingPrivateKey.readBytes(in);
|
signingPrivateKey.readBytes(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -88,8 +89,8 @@ public class SigningPublicKeyTest extends StructureTest {
|
|||||||
SigningPublicKey publicKey = new SigningPublicKey();
|
SigningPublicKey publicKey = new SigningPublicKey();
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
ByteArrayInputStream in = new ByteArrayInputStream(DataHelper.getASCII("six times nine equals forty-two"));
|
||||||
|
|
||||||
exception.expect(DataFormatException.class);
|
exception.expect(EOFException.class);
|
||||||
exception.expectMessage("EOF reading SigningPublicKey, read: 31, required: " + SigningPublicKey.KEYSIZE_BYTES);
|
exception.expectMessage("EOF after reading 31 bytes of " + SigningPublicKey.KEYSIZE_BYTES + " byte value");
|
||||||
publicKey.readBytes(in);
|
publicKey.readBytes(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user