use of java.security.SignatureException in project j2objc by google.
the class SignatureSpiTest method testEngineUpdate_ByteBuffer.
public void testEngineUpdate_ByteBuffer() {
MySignature signature = new MySignature("dummy");
try {
signature.initSign(new PrivateKey() {
public String getFormat() {
return null;
}
public byte[] getEncoded() {
return null;
}
public String getAlgorithm() {
return null;
}
});
} catch (InvalidKeyException e) {
fail("unexpected exception: " + e);
}
try {
signature.update(ByteBuffer.wrap("Hello".getBytes()));
assertTrue("SPI method not called", signature.wasMethodCalled("engineUpdate_ByteBuffer"));
} catch (SignatureException e) {
fail("unexpected exception");
}
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureTest method testSignbyteintint.
/*
* Class under test for sign(byte[], offset, len)
*/
public void testSignbyteintint() throws Exception {
MySignature1 s = new MySignature1("ABC");
byte[] outbuf = new byte[10];
try {
s.sign(outbuf, 0, outbuf.length);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initVerify(new MyPublicKey());
try {
s.sign(outbuf, 0, outbuf.length);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initSign(new MyPrivateKey());
assertEquals(s.getBufferLength(), s.sign(outbuf, 0, outbuf.length));
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("sign() failed", s.runEngineSign);
try {
s.initSign(new MyPrivateKey());
s.sign(outbuf, outbuf.length, 0);
fail("expected SignatureException");
} catch (SignatureException e) {
// ok
}
try {
s.initSign(new MyPrivateKey());
s.sign(outbuf, outbuf.length, 3);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// ok
}
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException07.
/**
* Test for <code>SignatureException(String, Throwable)</code> constructor
* Assertion: constructs SignatureException when <code>cause</code> is
* null <code>msg</code> is not null
*/
public void testSignatureException07() {
SignatureException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new SignatureException(msgs[i], null);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException01.
/**
* Test for <code>SignatureException()</code> constructor Assertion:
* constructs SignatureException with no detail message
*/
public void testSignatureException01() {
SignatureException tE = new SignatureException();
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException09.
/**
* Test for <code>SignatureException(String, Throwable)</code> constructor
* Assertion: constructs SignatureException when <code>cause</code> is not
* null <code>msg</code> is not null
*/
public void testSignatureException09() {
SignatureException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new SignatureException(msgs[i], tCause);
String getM = tE.getMessage();
String toS = tCause.toString();
if (msgs[i].length() > 0) {
assertTrue("getMessage() must contain ".concat(msgs[i]), getM.indexOf(msgs[i]) != -1);
if (!getM.equals(msgs[i])) {
assertTrue("getMessage() should contain ".concat(toS), getM.indexOf(toS) != -1);
}
}
assertNotNull("getCause() must not return null", tE.getCause());
assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
}
Aggregations