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 Alexander Y. Kleymenov 20 * @version $Revision$ 21 */ 22 23 package tests.security.cert; 24 25 import junit.framework.TestCase; 26 27 import java.io.IOException; 28 import java.security.cert.X509CRLSelector; 29 import java.util.Iterator; 30 import java.util.TreeSet; 31 32 import javax.security.auth.x500.X500Principal; 33 34 public class X509CRLSelectorTest extends TestCase { 35 36 /** 37 * java.security.cert.X509CRLSelector#addIssuer(javax.security.auth.x500.X500Principal) 38 */ 39 public void test_addIssuerLjavax_security_auth_x500_X500Principal01() 40 throws Exception { 41 //Regression for HARMONY-465 42 X509CRLSelector obj = new X509CRLSelector(); 43 try { 44 obj.addIssuer((X500Principal) null); 45 fail("NullPointerException expected"); 46 } catch (NullPointerException e) { 47 // expected 48 } 49 } 50 51 /** 52 * java.security.cert.X509CRLSelector#addIssuerName(java.lang.String) 53 */ 54 public void test_addIssuerNameLjava_lang_String01() throws Exception { 55 //Regression for HARMONY-465 56 X509CRLSelector obj = new X509CRLSelector(); 57 try { 58 obj.addIssuerName("234"); 59 fail("IOException expected"); 60 } catch (IOException e) { 61 // expected 62 } 63 64 // Regression for HARMONY-1076 65 try { 66 new X509CRLSelector().addIssuerName("w=y"); 67 fail("IOException expected"); 68 } catch (IOException e) { 69 // expected 70 } 71 } 72 73 /** 74 * java.security.cert.X509CRLSelector#addIssuerName(java.lang.String) 75 */ 76 public void test_addIssuerNameLjava_lang_String02() throws IOException { 77 // Regression for HARMONY-736 78 X509CRLSelector selector = new X509CRLSelector(); 79 80 // no exception for null 81 selector.addIssuerName((String) null); 82 } 83 84 85 /** 86 * java.security.cert.X509CRLSelector#addIssuerName(byte[]) 87 */ 88 public void test_addIssuerName$B_3() throws Exception { 89 //Regression for HARMONY-465 90 X509CRLSelector obj = new X509CRLSelector(); 91 try { 92 obj.addIssuerName(new byte[] { (byte) 2, (byte) 3, (byte) 4 }); 93 fail("IOException expected"); 94 } catch (IOException e) { 95 // expected 96 } 97 } 98 99 /** 100 * java.security.cert.X509CRLSelector#addIssuerName(byte[]) 101 */ 102 public void test_addIssuerName$B_4() throws Exception { 103 //Regression for HARMONY-465 104 X509CRLSelector obj = new X509CRLSelector(); 105 try { 106 obj.addIssuerName((byte[]) null); 107 fail("NullPointerException expected"); 108 } catch (NullPointerException e) { 109 // expected 110 } 111 } 112 113 /** 114 * setIssuerNames(Collection <?> names) 115 */ 116 public void test_setIssuerNamesLjava_util_Collection01() throws IOException { 117 // Regression for HARMONY-737 118 X509CRLSelector selector = new X509CRLSelector(); 119 selector.setIssuerNames(new TreeSet<Comparable>() { 120 private static final long serialVersionUID = 6009545505321092498L; 121 122 public Iterator<Comparable> iterator() { 123 return null; 124 } 125 }); 126 } 127 } 128