1347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom/* 2347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * Copyright (C) 2011 The Android Open Source Project 3347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * 4347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * Licensed under the Apache License, Version 2.0 (the "License"); 5347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * you may not use this file except in compliance with the License. 6347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * You may obtain a copy of the License at 7347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * 8347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * http://www.apache.org/licenses/LICENSE-2.0 9347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * 10347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * Unless required by applicable law or agreed to in writing, software 11347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * distributed under the License is distributed on an "AS IS" BASIS, 12347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * See the License for the specific language governing permissions and 14347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom * limitations under the License. 15347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom */ 16347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 17347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrompackage libcore.java.security.cert; 18347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 19347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstromimport java.security.cert.X509CRLSelector; 20347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstromimport java.util.Collection; 21347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstromimport javax.security.auth.x500.X500Principal; 22347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstromimport junit.framework.TestCase; 23347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 24347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrompublic final class X509CRLSelectorTest extends TestCase { 25347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 26347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom private static final String PRINCIPAL_STRING = 27347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom "C=US, ST=California, L=Mountain View, O=Google Inc, CN=www.google.com"; 28347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom private static final X500Principal PRINCIPAL = new X500Principal(PRINCIPAL_STRING); 29347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 30347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom public void testGetIssuersImmutable() { 31347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom X509CRLSelector crlSelector = new X509CRLSelector(); 32347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom crlSelector.addIssuer(PRINCIPAL); 33347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom Collection<X500Principal> issuers = crlSelector.getIssuers(); 34347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom try { 35347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom issuers.clear(); 36347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom fail(); 37347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom } catch (UnsupportedOperationException expected) { 38347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom } 39347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom } 40347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom 41347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom public void testGetIssuersNamesCopy() { 42347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom X509CRLSelector crlSelector = new X509CRLSelector(); 43347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom crlSelector.addIssuer(PRINCIPAL); 44347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom Collection<Object> issuers = crlSelector.getIssuerNames(); 45347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom assertEquals(1, issuers.size()); 46347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom issuers.clear(); 47347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom assertEquals(0, issuers.size()); 48347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom } 49347b2a604114602da9bc4ae040278f74d11c2f51Brian Carlstrom} 50