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 */
17
18package org.apache.harmony.luni.tests.java.util;
19
20import java.util.Enumeration;
21import java.util.Locale;
22import java.util.ResourceBundle;
23import java.util.Set;
24import java.util.Vector;
25
26import tests.resources.subfolder.tests.resources.hyts_resource_fr_FR;
27public class ListResourceBundleTest extends junit.framework.TestCase {
28
29	/**
30	 * @tests java.util.ListResourceBundle#getKeys()
31	 */
32	public void test_getKeys() {
33		ResourceBundle bundle;
34		String name = "tests.support.Support_TestResource";
35		Locale.setDefault(new Locale("en", "US"));
36		bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
37		Enumeration<String> keys = bundle.getKeys();
38		Vector<String> result = new Vector<String>();
39		while (keys.hasMoreElements()) {
40			result.addElement(keys.nextElement());
41		}
42		assertTrue("Missing key parent1", result.contains("parent1"));
43		assertTrue("Missing key parent2", result.contains("parent2"));
44		assertTrue("Missing key parent3", result.contains("parent3"));
45		assertTrue("Missing key parent4", result.contains("parent4"));
46		assertTrue("Missing key child1", result.contains("child1"));
47		assertTrue("Missing key child2", result.contains("child2"));
48		assertTrue("Missing key child3", result.contains("child3"));
49	}
50
51    /**
52     * @tests {@link java.util.ListResourceBundle#handleKeySet()}
53     * @since 1.6
54     */
55    @SuppressWarnings("nls")
56    public void test_handleKeySet() {
57        ResourceBundle.clearCache();
58        hyts_resource_fr_FR bundle = (hyts_resource_fr_FR) ResourceBundle
59                .getBundle(
60                        "tests.resources.subfolder.tests.resources.hyts_resource",
61                        new Locale("fr", "FR"));
62        Set<String> set = bundle.handleKeySet();
63        assertEquals(4, set.size());
64        assertTrue(set.contains("subChild1"));
65        assertTrue(set.contains("subChild2"));
66        assertTrue(set.contains("subParent3"));
67        assertTrue(set.contains("subParent4"));
68        set = bundle.keySet();
69        assertEquals(6, set.size());
70        assertTrue(set.contains("subChild1"));
71        assertTrue(set.contains("subChild2"));
72        assertTrue(set.contains("subParent1"));
73        assertTrue(set.contains("subParent2"));
74        assertTrue(set.contains("subParent3"));
75        assertTrue(set.contains("subParent4"));
76    }
77
78    public void test_handleGetObject(){
79        ResourceBundle.clearCache();
80        hyts_resource_fr_FR bundle = (hyts_resource_fr_FR) ResourceBundle
81                .getBundle(
82                        "tests.resources.subfolder.tests.resources.hyts_resource",
83                        new Locale("fr", "FR"));
84        try{
85            bundle.handleGetObject(null);
86            fail("Should throw NPE");
87        }catch(NullPointerException e){
88        }
89    }
90	protected void setUp() {
91	}
92
93	protected void tearDown() {
94	}
95}
96