Search in sources :

Example 1 with MyCertificateRep

use of org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep in project robovm by robovm.

the class CertificateCertificateRepTest method testReadResolve.

/**
     * Test for <code>readResolve()</code> method<br>
     */
public final void testReadResolve() {
    MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
    MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    try {
        rep.readResolve();
        fail("ObjectStreamException expected");
    } catch (ObjectStreamException e) {
    // expected
    }
    MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
    try {
        Certificate obj = (Certificate) rep1.readResolve();
        assertEquals("0.3.5", obj.getPublicKey().getAlgorithm());
        assertEquals("X.509", obj.getPublicKey().getFormat());
        assertEquals("X.509", obj.getType());
    } catch (ObjectStreamException e) {
        fail("Unexpected ObjectStreamException " + e.getMessage());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 2 with MyCertificateRep

use of org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep in project j2objc by google.

the class CertificateCertificateRepTest method testReadResolve.

/**
 * Test for <code>readResolve()</code> method<br>
 */
public final void testReadResolve() {
    MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
    MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    try {
        rep.readResolve();
        fail("ObjectStreamException expected");
    } catch (ObjectStreamException e) {
    // expected
    }
    MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
    try {
        Certificate obj = (Certificate) rep1.readResolve();
        assertEquals("0.3.5", obj.getPublicKey().getAlgorithm());
        assertEquals("X.509", obj.getPublicKey().getFormat());
        assertEquals("X.509", obj.getType());
    } catch (ObjectStreamException e) {
        fail("Unexpected ObjectStreamException " + e.getMessage());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 3 with MyCertificateRep

use of org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep in project j2objc by google.

the class CertificateCertificateRepTest method testCertificateCertificateRep.

/**
 * Test for
 * <code>Certificate.CertificateRep(String type, byte[] data)</code>
 * method<br>
 */
public final void testCertificateCertificateRep() {
    MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
    MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    assertTrue(Arrays.equals(new byte[] { (byte) 1, (byte) 2, (byte) 3 }, rep.getData()));
    assertEquals("TEST_TYPE", rep.getType());
    try {
        c1.new MyCertificateRep(null, null);
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
    try {
        MyCertificate.MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
        assertEquals("X509", rep1.getType());
        assertTrue(Arrays.equals(TestUtils.getX509Certificate_v3(), rep1.getData()));
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException)

Example 4 with MyCertificateRep

use of org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep in project robovm by robovm.

the class CertificateCertificateRepTest method testCertificateCertificateRep.

/**
     * Test for
     * <code>Certificate.CertificateRep(String type, byte[] data)</code>
     * method<br>
     */
public final void testCertificateCertificateRep() {
    MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
    MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    assertTrue(Arrays.equals(new byte[] { (byte) 1, (byte) 2, (byte) 3 }, rep.getData()));
    assertEquals("TEST_TYPE", rep.getType());
    try {
        c1.new MyCertificateRep(null, null);
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
    try {
        MyCertificate.MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
        assertEquals("X509", rep1.getType());
        assertTrue(Arrays.equals(TestUtils.getX509Certificate_v3(), rep1.getData()));
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException)

Aggregations

ObjectStreamException (java.io.ObjectStreamException)4 MyCertificate (org.apache.harmony.security.tests.support.cert.MyCertificate)4 MyCertificateRep (org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep)4 Certificate (java.security.cert.Certificate)2