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 package tests.security.acl; 19 20 import dalvik.annotation.TestTargets; 21 import dalvik.annotation.TestLevel; 22 import dalvik.annotation.TestTargetNew; 23 import dalvik.annotation.TestTargetClass; 24 25 import junit.framework.TestCase; 26 27 import java.security.acl.Permission; 28 29 import org.apache.harmony.security.tests.support.acl.*; 30 31 @TestTargetClass(Permission.class) 32 public class IPermissionTest extends TestCase { 33 34 class MyPermission extends PermissionImpl { 35 public MyPermission(String str) { 36 super(str); 37 } 38 } 39 40 /** 41 * @tests java.security.acl.Permission#equals(Object another) 42 */ 43 @TestTargetNew( 44 level = TestLevel.COMPLETE, 45 notes = "", 46 method = "equals", 47 args = {java.lang.Object.class} 48 ) 49 public void test_equals() { 50 try { 51 MyPermission mp1 = new MyPermission("TestPermission"); 52 MyPermission mp2 = new MyPermission("NewTestPermission"); 53 Object another = new Object(); 54 assertFalse(mp1.equals(another)); 55 assertFalse(mp1.equals(mp2)); 56 assertTrue(mp1.equals(new MyPermission("TestPermission"))); 57 } catch (Exception e) { 58 fail("Unexpected exception - subtest1"); 59 } 60 } 61 62 /** 63 * @tests java.security.acl.Permission#toString() 64 */ 65 @TestTargetNew( 66 level = TestLevel.COMPLETE, 67 notes = "", 68 method = "toString", 69 args = {} 70 ) 71 public void test_toString() { 72 try { 73 MyPermission obj = new MyPermission("TestPermission"); 74 String res = obj.toString(); 75 assertEquals(res, "TestPermission"); 76 } catch (Exception e) { 77 fail("Unexpected exception - subtest2"); 78 } 79 } 80 }