use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testInitSignPrivateKeySecureRandom.
/*
* Class under test for void initSign(PrivateKey, SecureRandom)
*/
public void testInitSignPrivateKeySecureRandom() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initSign(new MyPrivateKey(), new SecureRandom());
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("initSign() failed", s.runEngineInitSign);
try {
Signature sig = getTestSignature();
sig.initSign(null, null);
fail("expected InvalidKeyException");
} catch (InvalidKeyException e) {
// ok
} catch (NoSuchAlgorithmException e) {
fail("unexpected : " + e);
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testGetAlgorithm.
public void testGetAlgorithm() {
MySignature1 s = new MySignature1("ABC");
assertEquals("state", MySignature1.UNINITIALIZED, s.getState());
assertEquals("algorithm", "ABC", s.getAlgorithm());
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testSign.
/*
* Class under test for byte[] sign()
*/
public void testSign() throws Exception {
MySignature1 s = new MySignature1("ABC");
try {
s.sign();
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initVerify(new MyPublicKey());
try {
s.sign();
fail("No expected SignatureException");
} catch (SignatureException e) {
}
s.initSign(new MyPrivateKey());
s.sign();
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("sign() failed", s.runEngineSign);
}
use of org.apache.harmony.security.tests.support.MySignature1 in project robovm by robovm.
the class SignatureTest method testGetProvider.
public void testGetProvider() {
MySignature1 s = new MySignature1("ABC");
assertEquals("state", MySignature1.UNINITIALIZED, s.getState());
assertNull("provider", s.getProvider());
}
use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
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