2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package tests.targets.security.cert;
18 import dalvik.annotation.TestLevel;
19 import dalvik.annotation.TestTargetNew;
20 import dalvik.annotation.TestTargets;
22 import junit.framework.TestCase;
24 import java.security.InvalidAlgorithmParameterException;
25 import java.security.NoSuchAlgorithmException;
26 import java.security.cert.CertPath;
27 import java.security.cert.CertPathParameters;
28 import java.security.cert.CertPathValidator;
29 import java.security.cert.CertPathValidatorException;
30 import java.security.cert.CertPathValidatorResult;
32 public abstract class CertPathValidatorTest extends TestCase {
34 private final String algorithmName;
37 public CertPathValidatorTest(String algorithmName) {
38 this.algorithmName = algorithmName;
41 abstract CertPathParameters getParams();
42 abstract CertPath getCertPath();
43 abstract void validateResult(CertPathValidatorResult validatorResult);
47 level=TestLevel.ADDITIONAL,
52 level=TestLevel.ADDITIONAL,
54 args={CertPath.class, CertPathParameters.class}
57 level=TestLevel.COMPLETE,
62 public void testCertPathValidator() {
63 CertPathValidator certPathValidator = null;
65 certPathValidator = CertPathValidator.getInstance(algorithmName);
66 } catch (NoSuchAlgorithmException e) {
70 CertPathValidatorResult validatorResult = null;
72 validatorResult = certPathValidator.validate(getCertPath(),
74 } catch (CertPathValidatorException e) {
76 } catch (InvalidAlgorithmParameterException e) {
80 validateResult(validatorResult);