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 */ 17package java.security; 18 19import java.net.URI; 20import java.net.URISyntaxException; 21 22import javax.security.auth.login.Configuration; 23 24import junit.framework.TestCase; 25 26public class URIParameterTest extends TestCase { 27 28 private URIParameter uriParameter; 29 private URI uri; 30 31 /** 32 * @tests {@link java.security.URIParamter#constructor(java.net.URI)} 33 */ 34 public void test_Constructor() throws URISyntaxException { 35 try { 36 new URIParameter(null); 37 fail("Should throw NPE"); 38 } catch (NullPointerException e) { 39 // expected 40 } 41 42 assertTrue(uriParameter instanceof Policy.Parameters); 43 assertTrue(uriParameter instanceof Configuration.Parameters); 44 } 45 46 /** 47 * @tests {@link java.security.URIParameter#getURI()} 48 */ 49 public void testGetURI() { 50 URI u = uriParameter.getURI(); 51 assertEquals(uri, u); 52 assertSame(uri, u); 53 } 54 55 /* 56 * @see TestCase#setUp() 57 */ 58 protected void setUp() throws Exception { 59 super.setUp(); 60 uri = new URI("http://www.test.com"); 61 uriParameter = new URIParameter(uri); 62 } 63 64 /* 65 * @see TestCase#tearDown() 66 */ 67 protected void tearDown() throws Exception { 68 super.tearDown(); 69 uriParameter = null; 70 uri = null; 71 } 72} 73