/* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/ /* * @test * @bug 4095319 4286358 * @summary Test cases for the containsKey, keySet, and handleKeySet * methods that are new in Mustang. * @build KeySetMessages KeySetMessages_zh_CN * @run main KeySetTest
*/
// Test containsKey() for (String key : fullKeys) { if (!rb.containsKey(key)) { thrownew RuntimeException("rb doesn't contain: " + key);
}
} for (String key : new String[] { "snack", "beer" }) { if (rb.containsKey(key)) { thrownew RuntimeException("rb contains: " + key);
}
}
// Make sure that the default handleKeySet implementation // returns the subset keys of the given locale.
TestBundle tb = new TestBundle(bundleName, locale);
Set<String> childKeys = tb.handleKeySet(); if (!(childKeys.containsAll(localKeys) || localKeys.containsAll(childKeys))) { thrownew RuntimeException("get " + childKeys + ", expected " + localKeys);
}
}
staticclass TestBundle extends ResourceBundle {
ResourceBundle bundle;
Method m;
public TestBundle() {}
public TestBundle(String name, Locale locale) {
bundle = ResourceBundle.getBundle(name, locale);
// Prepare for the handleGetObject call try { Class clazz = bundle.getClass();
m = clazz.getMethod("handleGetObject", String.class);
m.setAccessible(true);
} catch (Exception e) { thrownew RuntimeException("method preparation error", e);
}
}
public Enumeration<String> getKeys() { return bundle.getKeys();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.