1/* 2 * Copyright (C) 2011 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 */ 16 17package libcore.java.security.cert; 18 19import java.security.cert.X509CRLSelector; 20import java.util.Collection; 21import javax.security.auth.x500.X500Principal; 22import junit.framework.TestCase; 23 24public final class X509CRLSelectorTest extends TestCase { 25 26 private static final String PRINCIPAL_STRING = 27 "C=US, ST=California, L=Mountain View, O=Google Inc, CN=www.google.com"; 28 private static final X500Principal PRINCIPAL = new X500Principal(PRINCIPAL_STRING); 29 30 public void testGetIssuersImmutable() { 31 X509CRLSelector crlSelector = new X509CRLSelector(); 32 crlSelector.addIssuer(PRINCIPAL); 33 Collection<X500Principal> issuers = crlSelector.getIssuers(); 34 try { 35 issuers.clear(); 36 fail(); 37 } catch (UnsupportedOperationException expected) { 38 } 39 } 40 41 public void testGetIssuersNamesCopy() { 42 X509CRLSelector crlSelector = new X509CRLSelector(); 43 crlSelector.addIssuer(PRINCIPAL); 44 Collection<Object> issuers = crlSelector.getIssuerNames(); 45 assertEquals(1, issuers.size()); 46 issuers.clear(); 47 assertEquals(0, issuers.size()); 48 } 49} 50