use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testUpdatebyteArray.
/*
* Class under test for void update(byte[])
*/
public void testUpdatebyteArray() throws Exception {
MySignature1 s = new MySignature1("ABC");
byte[] b = { 1, 2, 3, 4 };
try {
s.update(b);
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initVerify(new MyPublicKey());
s.update(b);
s.initSign(new MyPrivateKey());
s.update(b);
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("update() failed", s.runEngineUpdate2);
try {
Signature sig = getTestSignature();
sig.update(b);
fail("expected SignatureException");
} catch (SignatureException e) {
// ok
}
try {
Signature sig = getTestSignature();
sig.update((byte[]) null);
fail("expected NullPointerException");
} catch (SignatureException e) {
// ok
} catch (NullPointerException e) {
// ok
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testUpdatebyteArrayintint2.
/*
* Class under test for void update(byte[], int, int)
*/
@KnownFailure("Android throws IllegalArgumentException, RI throws NullpointerException")
public void testUpdatebyteArrayintint2() throws Exception {
MySignature1 s = new MySignature1("ABC");
byte[] b = { 1, 2, 3, 4 };
s.initVerify(new MyPublicKey());
s.update(b, 0, 3);
s.initSign(new MyPrivateKey());
s.update(b, 0, 3);
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("update() failed", s.runEngineUpdate2);
try {
s.update(null, 0, 3);
fail("NullPointerException wasn't thrown");
} catch (NullPointerException npe) {
// ok
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testInitVerifyCertificate.
/*
* Class under test for void initVerify(Certificate)
*/
public void testInitVerifyCertificate() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initVerify(new MyCertificate());
assertEquals("state", MySignature1.VERIFY, s.getState());
assertTrue("initVerify() failed", s.runEngineInitVerify);
try {
Signature sig = getTestSignature();
sig.initVerify(new MyCertificate());
fail("expected InvalidKeyException");
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected : " + e);
}
}
Aggregations