1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16package tests.targets.security.cert;
17
18import dalvik.annotation.TestLevel;
19import dalvik.annotation.TestTargetNew;
20import dalvik.annotation.TestTargets;
21
22import junit.framework.TestCase;
23
24import java.security.cert.CertPath;
25import java.security.cert.CertPathParameters;
26import java.security.cert.CertPathValidator;
27import java.security.cert.CertPathValidatorResult;
28
29public abstract class CertPathValidatorTest extends TestCase {
30
31    private final String algorithmName;
32
33
34    public CertPathValidatorTest(String algorithmName) {
35        this.algorithmName = algorithmName;
36    }
37
38    abstract CertPathParameters getParams();
39    abstract CertPath getCertPath();
40    abstract void validateResult(CertPathValidatorResult validatorResult);
41
42    @TestTargets({
43        @TestTargetNew(
44                level=TestLevel.ADDITIONAL,
45                method="getInstance",
46                args={String.class}
47        ),
48        @TestTargetNew(
49                level=TestLevel.ADDITIONAL,
50                method="validate",
51                args={CertPath.class, CertPathParameters.class}
52        ),
53        @TestTargetNew(
54                level=TestLevel.COMPLETE,
55                method="method",
56                args={}
57        )
58    })
59    public void testCertPathValidator() throws Exception {
60        CertPathValidator certPathValidator = CertPathValidator.getInstance(
61                algorithmName);
62
63        CertPathValidatorResult validatorResult = certPathValidator.validate(
64                getCertPath(), getParams());
65
66        validateResult(validatorResult);
67    }
68
69
70}
71