1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18/**
19* @author Vera Y. Petrashkova
20* @version $Revision$
21*/
22
23package tests.security.cert;
24
25
26import junit.framework.Test;
27import junit.framework.TestCase;
28import junit.framework.TestSuite;
29
30import java.security.InvalidAlgorithmParameterException;
31import java.security.cert.CRL;
32import java.security.cert.CRLSelector;
33import java.security.cert.CertSelector;
34import java.security.cert.CertStoreException;
35import java.security.cert.CertStoreSpi;
36import java.security.cert.Certificate;
37
38import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters;
39import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi;
40
41/**
42 * Tests for <code>CertStoreSpi</code> class constructors and methods.
43 *
44 */
45public class CertStoreSpiTest extends TestCase {
46
47
48    /**
49     * Test for <code>CertStoreSpi</code> constructor Assertion: constructs
50     * CertStoreSpi
51     */
52    public void testCertStoreSpi01() throws InvalidAlgorithmParameterException,
53            CertStoreException {
54        CertStoreSpi certStoreSpi = null;
55        CertSelector certSelector = new tmpCertSelector();//new
56                                                          // X509CertSelector();
57        CRLSelector crlSelector = new tmpCRLSelector();//new X509CRLSelector();
58        try {
59            certStoreSpi = new MyCertStoreSpi(null);
60            fail("InvalidAlgorithmParameterException must be thrown");
61        } catch (InvalidAlgorithmParameterException e) {
62        }
63        certStoreSpi = new MyCertStoreSpi(new MyCertStoreParameters());
64        assertNull("Not null collection", certStoreSpi
65                .engineGetCertificates(certSelector));
66        assertNull("Not null collection", certStoreSpi
67                .engineGetCRLs(crlSelector));
68    }
69
70    public static Test suite() {
71        return new TestSuite(CertStoreSpiTest.class);
72    }
73
74    /**
75     * Additional classes for verification CertStoreSpi class
76     */
77    public static class tmpCRLSelector implements CRLSelector {
78        public Object clone() {
79            return null;
80        }
81        public boolean match (CRL crl) {
82            return false;
83        }
84    }
85    public static class tmpCertSelector implements CertSelector {
86        public Object clone() {
87            return null;
88        }
89        public boolean match (Certificate crl) {
90            return true;
91        }
92    }
93
94}
95