/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author Aleksei Y. Semenov * @version $Revision$ */ package tests.java.security; import java.security.Identity; import java.security.IdentityScope; import java.security.KeyManagementException; import java.security.Permission; import java.security.Permissions; import java.security.PublicKey; import java.security.SecurityPermission; import org.apache.harmony.security.tests.support.CertificateStub; import org.apache.harmony.security.tests.support.IdentityStub; import org.apache.harmony.security.tests.support.PublicKeyStub; import org.apache.harmony.security.tests.support.SystemScope; import junit.framework.TestCase; /** * Tests for class Identity * */ @SuppressWarnings("deprecation") public class IdentityTest extends TestCase { public static class MySecurityManager extends SecurityManager { public Permissions denied = new Permissions(); public void checkPermission(Permission permission){ if (denied!=null && denied.implies(permission)) throw new SecurityException(); } } public void testHashCode() { new IdentityStub("testHashCode").hashCode(); } public void testEquals() throws Exception { IdentityStub i1 = new IdentityStub("testEquals"); Object value[] = { null, Boolean.FALSE, new Object(), Boolean.FALSE, i1, Boolean.TRUE, new IdentityStub(i1.getName()), Boolean.TRUE }; for (int k=0; k