AuthenticatorRequestorTypeTest.java revision cc05ad238516f1303687aba4a978e24e57c0c07a
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package tests.api.java.net; 18 19import junit.framework.TestCase; 20 21import dalvik.annotation.TestTargets; 22import dalvik.annotation.TestLevel; 23import dalvik.annotation.TestTargetNew; 24import dalvik.annotation.TestTargetClass; 25 26import java.net.Authenticator; 27 28@TestTargetClass(Authenticator.RequestorType.class) 29public class AuthenticatorRequestorTypeTest extends TestCase { 30 31 @TestTargetNew( 32 level = TestLevel.COMPLETE, 33 notes = "", 34 method = "valueOf", 35 args = {java.lang.String.class} 36 ) 37 public void test_valueOfLjava_lang_String() { 38 assertEquals(Authenticator.RequestorType.PROXY, 39 Authenticator.RequestorType.valueOf("PROXY")); 40 assertEquals(Authenticator.RequestorType.SERVER, 41 Authenticator.RequestorType.valueOf("SERVER")); 42 try { 43 Authenticator.RequestorType.valueOf("TEST"); 44 fail("IllegalArgumentException was not thrown."); 45 } catch(IllegalArgumentException iae) { 46 //expected 47 } 48 } 49 50 @TestTargetNew( 51 level = TestLevel.COMPLETE, 52 notes = "", 53 method = "values", 54 args = {} 55 ) 56 public void test_values () { 57 Authenticator.RequestorType[] expectedTypes = { 58 Authenticator.RequestorType.PROXY, 59 Authenticator.RequestorType.SERVER 60 }; 61 62 Authenticator.RequestorType[] types = 63 Authenticator.RequestorType.values(); 64 assertEquals(expectedTypes.length, types.length); 65 66 for(int i = 0; i < expectedTypes.length; i++) { 67 assertEquals(expectedTypes[i], types[i]); 68 } 69 } 70} 71