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 libcore.java.net;
18
19import java.net.Authenticator;
20import junit.framework.TestCase;
21
22public class OldAuthenticatorRequestorTypeTest extends TestCase {
23
24    public void test_valueOfLjava_lang_String() {
25        assertEquals(Authenticator.RequestorType.PROXY,
26                Authenticator.RequestorType.valueOf("PROXY"));
27        assertEquals(Authenticator.RequestorType.SERVER,
28                Authenticator.RequestorType.valueOf("SERVER"));
29        try {
30            Authenticator.RequestorType.valueOf("TEST");
31            fail("IllegalArgumentException was not thrown.");
32        } catch(IllegalArgumentException expected) {
33        }
34    }
35
36    public void test_values () {
37        Authenticator.RequestorType[] expectedTypes = {
38                Authenticator.RequestorType.PROXY,
39                Authenticator.RequestorType.SERVER
40        };
41
42        Authenticator.RequestorType[] types = Authenticator.RequestorType.values();
43        assertEquals(expectedTypes.length, types.length);
44
45        for(int i = 0; i < expectedTypes.length; i++) {
46            assertEquals(expectedTypes[i], types[i]);
47        }
48    }
49}
50