use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
the class SignatureTest method testClone.
/*
* Class under test for Object clone()
*/
public void testClone() {
MySignature1 s = new MySignature1("ABC");
try {
s.clone();
fail("No expected CloneNotSupportedException");
} catch (CloneNotSupportedException e) {
}
MySignature sc = new MySignature();
try {
sc.clone();
} catch (CloneNotSupportedException e) {
fail("unexpected exception: " + e);
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
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 testUpdatebyteArrayintint2.
/*
* Class under test for void update(byte[], int, int)
*/
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
} catch (IllegalArgumentException se) {
// ok
}
}
use of org.apache.harmony.security.tests.support.MySignature1 in project j2objc by google.
the class SignatureTest method testInitSignPrivateKey.
/*
* Class under test for void initSign(PrivateKey)
*/
public void testInitSignPrivateKey() throws InvalidKeyException {
MySignature1 s = new MySignature1("ABC");
s.initSign(new MyPrivateKey());
assertEquals("state", MySignature1.SIGN, s.getState());
assertTrue("initSign() failed", s.runEngineInitSign);
try {
Signature signature = getTestSignature();
signature.initSign(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 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
}
}
Aggregations