/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 5102289 6278334
* @summary Test the default Control implementation. The expiration
* functionality of newBundle, getTimeToLive, and needsReload is
* tested by ExpirationTest.sh. The factory methods are tested
* separately.
* @build TestResourceRB
* @build NonResourceBundle
* @run main DefaultControlTest
*/
public class DefaultControlTest {
// The ResourceBundle.Control instance
};
// Full arguments for NPE testing
BUNDLE };
static int errors;
// Test getFormats(String)
// Test getCandidateLocales(String, Locale)
// Test getFallbackLocale(String, Locale)
// Test newBundle(String, Locale, String, ClassLoader, boolean)
// Test toBundleName(String, Locale)
// Test getTimeToLive(String, Locale)
// Test needsReload(String, Locale, String, ClassLoader,
// ResourceBundle, long)
// Test toResourceName(String, String)
if (errors > 0) {
}
}
private static void checkConstants() {
// Check FORMAT_*
"java.properties"))) {
error("Wrong Control.FORMAT_DEFAULT");
}
error("Wrong Control.FORMAT_CLASS");
}
error("Wrong Control.FORMAT_PROPERTIES");
}
// Check TTL_*
}
error("Wrong Control.TTL_NO_EXPIRATION_CONTROL: %d%n",
}
}
try {
} catch (UnsupportedOperationException e) {
}
}
private static void testGetFormats() {
}
try {
error("getFormats doesn't throw NPE.");
} catch (NullPointerException e) {
}
}
private static void testGetCandidateLocales() {
new Locale("ja"),
new Locale("") });
new Locale("ja"),
new Locale("") });
new Locale("ja"),
new Locale("") });
new Locale("ja"),
new Locale("") });
new Locale("") });
new Locale("") });
new Locale("") });
new Locale("") });
error("Wrong candidates for %s: got %s, expected %s%n",
}
}
final int NARGS = 2;
try {
error("getCandidateLocales(%s, %s) doesn't throw NPE.%n",
} catch (NullPointerException e) {
}
}
}
private static void testGetFallbackLocale() {
try {
error("getFallbackLocale: got %s, expected %s%n",
}
}
} finally {
}
final int NARGS = 2;
try {
} catch (NullPointerException e) {
}
}
}
private static void testNewBundle() {
int testNo = 0;
try {
testNo = 1;
PROPERTIES, LOADER, false);
if (!s.equals("Japan")) {
}
testNo = 2;
}
} catch (Throwable e) {
e.printStackTrace();
}
// Test exceptions
try {
// MalformedDataRB contains an invalid Unicode notation which
// causes to throw an IllegalArgumentException.
PROPERTIES, LOADER, false);
error("newBundle: doesn't throw IllegalArgumentException with malformed data.");
} catch (IllegalArgumentException iae) {
} catch (Exception e) {
error("newBundle: threw %s%n", e);
}
try {
"foo.bar", LOADER, false);
error("newBundle: doesn't throw IllegalArgumentException with invalid format.");
} catch (IllegalArgumentException iae) {
} catch (Exception e) {
error("newBundle: threw %s%n", e);
}
try {
"java.class", LOADER, false);
error("newBundle: doesn't throw ClassCastException with a non-ResourceBundle subclass.");
} catch (ClassCastException cce) {
} catch (Exception e) {
error("newBundle: threw %s%n", e);
}
// NPE test
final int NARGS = 4;
try {
false);
error("newBundle(%s, %s, %s, %s, false) doesn't throw NPE.%n",
} catch (NullPointerException npe) {
} catch (Exception e) {
error("newBundle(%s, %s, %s, %s, false) threw %s.%n",
}
}
}
private static void testGetTimeToLive() {
}
final int NARGS = 2;
try {
} catch (NullPointerException e) {
}
}
}
// The functionality of needsReload is tested by
// ExpirationTest.sh. Only parameter checking is tested here.
private static void testNeedsReload() {
// NPE test
final int NARGS = 5;
try {
error("needsReload(%s, %s, %s, %s, %s, loadTime) doesn't throw NPE.%n",
} catch (NullPointerException e) {
}
}
}
private static void testToBundleName() {
name);
}
}
final int NARGS = 2;
try {
} catch (NullPointerException e) {
}
}
}
private static void testToResourceName() {
// bundleName, suffix, expected result
{ ".", "", "/." },
{ "", "", "." },
// data for NPE tests
};
boolean npeThrown = false;
try {
} catch (NullPointerException npe) {
npeThrown = true;
}
}
} else {
if (!npeThrown) {
}
}
}
}
/**
* Produces permutations argument data that contains at least one
* null.
*/
for (int i = 0; i < length; i++) {
} else {
}
}
return data;
}
return "null";
}
errors++;
}
errors++;
}
}