FileDocCategorySizeDatePackage
CertPathValidator3Test.javaAPI DocAndroid 1.5 API4560Wed May 06 22:41:06 BST 2009tests.security.cert

CertPathValidator3Test

public class CertPathValidator3Test extends TestCase
Tests for CertPathValidator class methods.

Fields Summary
private static final String
defaultType
private static boolean
PKIXSupport
private static Provider
defaultProvider
private static String
defaultProviderName
private static String
NotSupportMsg
Constructors Summary
Methods Summary
private static java.security.cert.CertPathValidator[]createCPVs()


     
        defaultProvider = SpiEngUtils.isSupport(defaultType,
                CertPathValidator1Test.srvCertPathValidator);
        PKIXSupport = (defaultProvider != null);
        defaultProviderName = (PKIXSupport ? defaultProvider.getName() : null);
        NotSupportMsg = defaultType.concat(" is not supported");
    
        if (!PKIXSupport) {
            fail(NotSupportMsg);
            return null;
        }
        try {
            CertPathValidator[] certPVs = new CertPathValidator[3];
            certPVs[0] = CertPathValidator.getInstance(defaultType);
            certPVs[1] = CertPathValidator.getInstance(defaultType,
                    defaultProviderName);
            certPVs[2] = CertPathValidator.getInstance(defaultType,
                    defaultProvider);
            return certPVs;
        } catch (Exception e) {
            return null;
        }
    
public voidtestValidate01()
Test for validate(CertPath certpath, CertPathParameters params) method Assertion: throws InvalidAlgorithmParameterException when params is instance of PKIXParameters and certpath is not X.509 type

        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) {
            }
        }