1561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/* 2561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Licensed to the Apache Software Foundation (ASF) under one or more 3561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * contributor license agreements. See the NOTICE file distributed with 4561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * this work for additional information regarding copyright ownership. 5561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * The ASF licenses this file to You under the Apache License, Version 2.0 6561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * (the "License"); you may not use this file except in compliance with 7561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * the License. You may obtain a copy of the License at 8561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * 9561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 10561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * 11561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Unless required by applicable law or agreed to in writing, software 12561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 13561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * See the License for the specific language governing permissions and 15561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * limitations under the License. 16561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 17561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 18561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/** 19561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes* @author Aleksei Y. Semenov 20561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes*/ 21561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 22561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughespackage org.apache.harmony.security.tests.java.security; 23561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport java.security.*; 24561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport org.apache.harmony.security.tests.support.IdentityScopeStub; 25561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 26561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughesimport junit.framework.TestCase; 27561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 28561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 29561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes/** 30561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Tests for <code>IdentityScope</code> 31e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes * 32561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 33561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 34561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughespublic class IdentityScopeTest extends TestCase { 35561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 36561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes IdentityScope is; 37561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 38561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 39561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Constructor for IdentityScopeTest. 40561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * @param arg0 41561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 42561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public IdentityScopeTest(String arg0) { 43561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes super(arg0); 44561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 45561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 46561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 47561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Class under test for String toString() 48561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 49561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testToString() { 50561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(new IdentityScopeStub("Aleksei Semenov").toString()); 51561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 52561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 53561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 54561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * test default constructor void IdentityScope() 55561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 56561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testIdentityScope() { 57561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(new IdentityScopeStub()); 58561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 59561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 60561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 61561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * check that void IdentityScope(String) creates instance with given name 62561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 63561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testIdentityScopeString() { 64561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes is = new IdentityScopeStub("Aleksei Semenov"); 65561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(is); 66561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertEquals("Aleksei Semenov", is.getName()); 67561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 68561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 69561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 70561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * check that void IdentityScope(String, IdentityScope) creates instance with given name and within given scope 71561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 72561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testIdentityScopeStringIdentityScope() throws Exception { 73561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes IdentityScope scope = new IdentityScopeStub("my scope"); 74561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes is = new IdentityScopeStub("Aleksei Semenov", scope); 75561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(is); 76561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertEquals("Aleksei Semenov", is.getName()); 77561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertEquals(scope.getName(), is.getScope().getName()); 78561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 79561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 80561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 81561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * just call IdentityScope.getSystemScope() 82561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 83561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testGetSystemScope() { 84561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes String name = Security.getProperty("system.scope"); 85561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(name); 86e98fbf8686c5289bf03fe5c3de7ff82d3a77104dElliott Hughes IdentityScope scope = IdentityScope.getSystemScope(); 87561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertNotNull(scope); 88561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertEquals(name, scope.getClass().getName()); 89561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 90561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 91561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes /** 92561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes * Class under test for Identity getIdentity(Principal) 93561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes */ 94561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes public final void testGetIdentityPrincipal() { 95561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes is = new IdentityScopeStub("Aleksei Semenov"); 96561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes IdentityScope sc2 = new IdentityScopeStub("aaa"); 97561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes assertSame(is, is.getIdentity(sc2)); 98561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes } 99561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes 100561ee011997c6c2f1befbfaa9d5f0a99771c1d63Elliott Hughes} 101