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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package tests.api.java.util;
20 import dalvik.annotation.TestTargetNew;
21 import dalvik.annotation.TestTargets;
22 import dalvik.annotation.TestLevel;
23 import dalvik.annotation.TestTargetClass;
25 import java.util.Enumeration;
26 import java.util.ListResourceBundle;
27 import java.util.Locale;
28 import java.util.ResourceBundle;
29 import java.util.Vector;
31 @TestTargetClass(java.util.ListResourceBundle.class)
32 public class ListResourceBundleTest extends junit.framework.TestCase {
35 * @tests java.util.ListResourceBundle#getKeys()
39 level = TestLevel.COMPLETE,
45 level = TestLevel.COMPLETE,
47 method = "ListResourceBundle",
51 level = TestLevel.COMPLETE,
53 method = "getContents",
57 public void test_getKeys() {
58 ResourceBundle bundle;
59 String name = "tests.support.Support_TestResource";
60 Locale.setDefault(new Locale("en", "US"));
61 bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
62 Enumeration keys = bundle.getKeys();
63 Vector result = new Vector();
64 while (keys.hasMoreElements()) {
65 result.addElement(keys.nextElement());
67 assertTrue("Missing key parent1", result.contains("parent1"));
68 assertTrue("Missing key parent2", result.contains("parent2"));
69 assertTrue("Missing key parent3", result.contains("parent3"));
70 assertTrue("Missing key parent4", result.contains("parent4"));
71 assertTrue("Missing key child1", result.contains("child1"));
72 assertTrue("Missing key child2", result.contains("child2"));
73 assertTrue("Missing key child3", result.contains("child3"));
79 level = TestLevel.COMPLETE,
81 method = "handleGetObject",
82 args = {java.lang.String.class}
85 level = TestLevel.COMPLETE,
87 method = "ListResourceBundle",
91 level = TestLevel.COMPLETE,
93 method = "getContents",
97 public void test_handleGetObjectLjava_lang_String() {
98 ListResourceBundle bundle;
99 String name = "tests.support.Support_TestResource";
100 Locale.setDefault(new Locale("en", "US"));
101 bundle = (ListResourceBundle)ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
102 Enumeration keys = bundle.getKeys();
103 String keyValue = null;
104 Vector result = new Vector();
105 while (keys.hasMoreElements()) {
106 result.addElement(bundle.handleGetObject((String)keys.nextElement()));
108 assertEquals(9, result.size());
109 assertTrue(result.contains(null));
110 assertTrue(result.contains("frFRVARValue4"));
111 assertTrue(result.contains("frFRVARChildValue1"));
112 assertTrue(result.contains("frFRVARChildValue2"));
113 assertTrue(result.contains("frFRVARChildValue3"));
114 assertTrue(result.remove(null));
115 assertTrue(result.remove(null));
116 assertTrue(result.remove(null));
119 protected void setUp() {
122 protected void tearDown() {