use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult01.
//
// Tests
//
/**
* Test #1 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: Creates an instance of <code>PKIXCertPathBuilderResult</code>
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testPKIXCertPathBuilderResult01() throws InvalidKeySpecException, NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r = new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), testPublicKey);
assertTrue(r instanceof PKIXCertPathBuilderResult);
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class PKIXCertPathBuilderResultTest method testPKIXCertPathBuilderResult04.
/**
* Test #4 for <code>PKIXCertPathBuilderResult(CertPath, TrustAnchor,
* PolicyNode, PublicKey)</code> constructor<br>
* Assertion: <code>NullPointerException</code>
* if trustAnchor is <code>null</code>
*/
public final void testPKIXCertPathBuilderResult04() {
try {
// pass null
new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), null, TestUtils.getPolicyTree(), testPublicKey);
fail("NPE expected");
} catch (NullPointerException e) {
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class PKIXCertPathBuilderResultTest method testToString.
/**
* Test for <code>toString()</code> method<br>
* Assertion: the printable representation of this object
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
public final void testToString() throws InvalidKeySpecException, NoSuchAlgorithmException {
TrustAnchor ta = TestUtils.getTrustAnchor();
if (ta == null) {
fail(getName() + ": not performed (could not create test TrustAnchor)");
}
CertPathBuilderResult r = new PKIXCertPathBuilderResult(new MyCertPath(testEncoding), ta, TestUtils.getPolicyTree(), testPublicKey);
assertNotNull(r.toString());
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class TimestampTest method testHashCode.
/*
* Class under test for String hashCode()
*/
public void testHashCode() {
Timestamp one = new Timestamp(now, cpath);
Timestamp two = new Timestamp(now, cpath);
Timestamp three = new Timestamp(now, new MyCertPath(new byte[] { 10, 20, 30 }));
Timestamp four = null;
assertTrue(one.hashCode() == two.hashCode());
assertTrue(one.hashCode() != three.hashCode());
assertTrue(two.hashCode() != three.hashCode());
try {
four.hashCode();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertPath in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory13.
/**
* Test for <code>generateCertPath(InputStream inStream)</code>
* <code>generateCertPath(InputStream inStream, String encoding)</code>
* methods
* Assertion: throw CertificateException when isStream contains invalid datas
*/
// Test passed on RI
public void testCertificateFactory13() throws IOException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
byte[] enc = { (byte) 0, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
MyCertPath mc = new MyCertPath(enc);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(mc);
oos.flush();
oos.close();
byte[] arr = os.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(arr);
for (int i = 0; i < certFs.length; i++) {
try {
certFs[i].generateCertPath(is);
fail("CertificateException must be thrown because input stream contains incorrect datas");
} catch (CertificateException e) {
}
Iterator<String> it = certFs[i].getCertPathEncodings();
while (it.hasNext()) {
try {
certFs[i].generateCertPath(is, it.next());
fail("CertificateException must be thrown because input stream contains incorrect datas");
} catch (CertificateException e) {
}
}
}
}
Aggregations