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*/ 21 22package org.apache.harmony.security.tests.java.security.cert; 23 24 25import java.security.InvalidAlgorithmParameterException; 26import java.security.cert.CRL; 27import java.security.cert.CRLSelector; 28import java.security.cert.CertSelector; 29import java.security.cert.CertStoreException; 30import java.security.cert.CertStoreSpi; 31import java.security.cert.Certificate; 32 33import org.apache.harmony.security.tests.support.cert.MyCertStoreSpi; 34import org.apache.harmony.security.tests.support.cert.MyCertStoreParameters; 35 36import junit.framework.TestCase; 37import junit.framework.Test; 38import junit.framework.TestSuite; 39 40/** 41 * Tests for <code>CertStoreSpi</code> class constructors and methods. 42 * 43 */ 44 45public class CertStoreSpiTest extends TestCase { 46 47 /** 48 * Constructor for CertStoreSpiTest. 49 * 50 * @param arg0 51 */ 52 public CertStoreSpiTest(String arg0) { 53 super(arg0); 54 } 55 56 /** 57 * Test for <code>CertStoreSpi</code> constructor Assertion: constructs 58 * CertStoreSpi 59 */ 60 public void testCertStoreSpi01() throws InvalidAlgorithmParameterException, 61 CertStoreException { 62 CertStoreSpi certStoreSpi = null; 63 CertSelector certSelector = new tmpCertSelector();//new 64 // X509CertSelector(); 65 CRLSelector crlSelector = new tmpCRLSelector();//new X509CRLSelector(); 66 try { 67 certStoreSpi = new MyCertStoreSpi(null); 68 fail("InvalidAlgorithmParameterException must be thrown"); 69 } catch (InvalidAlgorithmParameterException e) { 70 } 71 certStoreSpi = new MyCertStoreSpi(new MyCertStoreParameters()); 72 assertNull("Not null collection", certStoreSpi 73 .engineGetCertificates(certSelector)); 74 assertNull("Not null collection", certStoreSpi 75 .engineGetCRLs(crlSelector)); 76 } 77 78 public static Test suite() { 79 return new TestSuite(CertStoreSpiTest.class); 80 } 81 82 /** 83 * Additional classes for verification CertStoreSpi class 84 */ 85 public static class tmpCRLSelector implements CRLSelector { 86 public Object clone() { 87 return null; 88 } 89 public boolean match (CRL crl) { 90 return false; 91 } 92 } 93 public static class tmpCertSelector implements CertSelector { 94 public Object clone() { 95 return null; 96 } 97 public boolean match (Certificate crl) { 98 return true; 99 } 100 } 101 102} 103