use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathValidator3Test method testValidate01.
/**
* Test for <code>validate(CertPath certpath, CertPathParameters params)</code> method
* Assertion: throws InvalidAlgorithmParameterException
* when params is instance of PKIXParameters and
* certpath is not X.509 type
*
*/
public void testValidate01() throws InvalidAlgorithmParameterException, CertPathValidatorException {
if (!PKIXSupport) {
fail(NotSupportMsg);
return;
}
MyCertPath mCP = new MyCertPath(new byte[0]);
CertPathParameters params = new PKIXParameters(TestUtils.getTrustAnchorSet());
CertPathValidator[] certPV = createCPVs();
assertNotNull("CertPathValidator objects were not created", certPV);
for (int i = 0; i < certPV.length; i++) {
try {
certPV[i].validate(mCP, null);
fail("InvalidAlgorithmParameterException must be thrown");
} catch (InvalidAlgorithmParameterException e) {
}
try {
certPV[i].validate(null, params);
fail("NullPointerException must be thrown");
} catch (NullPointerException e) {
}
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathCertPathRepTest method testReadResolve.
public final void testReadResolve() {
MyCertPath cp = new MyCertPath(testEncoding);
MyCertPathRep rep = cp.new MyCertPathRep("MyEncoding", testEncoding);
try {
Object obj = rep.readResolve();
fail("ObjectStreamException was not thrown.");
} catch (ObjectStreamException e) {
//expected
}
rep = cp.new MyCertPathRep("MyEncoding", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
try {
rep.readResolve();
fail("ObjectStreamException expected");
} catch (ObjectStreamException e) {
// expected
System.out.println(e);
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathTest method testHashCode.
/**
* Test for <code>hashCode()</code> method<br>
* Assertion: returns hash of the <code>Certificate</code> instance
*/
public final void testHashCode() {
CertPath cp1 = new MyCertPath(testEncoding);
CertPath cp2 = new MyCertPath(testEncoding);
CertPath cp3 = new MyCertPath(testEncoding1);
assertTrue(cp1.hashCode() == cp2.hashCode());
assertTrue(cp1.hashCode() != cp3.hashCode());
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathTest method testCertPath.
//
// Tests
//
/**
* Test for <code>CertPath(String type)</code> method<br>
* Assertion: returns hash of the <code>Certificate</code> instance
*/
public final void testCertPath() {
try {
CertPath cp1 = new MyCertPath(testEncoding);
assertEquals("MyEncoding", cp1.getType());
assertTrue(Arrays.equals(testEncoding, cp1.getEncoded()));
} catch (CertificateEncodingException e) {
fail("Unexpected CertificateEncodingException " + e.getMessage());
}
try {
CertPath cp1 = new MyCertPath(null);
} catch (Exception e) {
fail("Unexpected exception " + e.getMessage());
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class CertPathTest method testEqualsObject04.
/**
* Test for <code>equals(Object)</code> method<br>
* Assertion: object not equals to other which is not
* instance of <code>CertPath</code>
*/
public final void testEqualsObject04() {
CertPath cp1 = new MyCertPath(testEncoding);
assertFalse(cp1.equals("MyEncoding"));
}
Aggregations