From b8a9d2ca108af229c3eda56ed57ba3bc2e303654 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 12 Aug 2009 17:59:08 +0000 Subject: QPID-2002 : Added test to ensure that the ResourceBundle is loadable even if the current Locale is not one that has a specific file. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@803630 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/server/logging/LogMessageTest.java | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java (limited to 'java/broker/src/test') diff --git a/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java b/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java new file mode 100644 index 0000000000..0f3f7bd2b5 --- /dev/null +++ b/java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java @@ -0,0 +1,71 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.server.logging; + +import junit.framework.TestCase; + +import java.util.Locale; +import java.util.ResourceBundle; + +public class LogMessageTest extends TestCase +{ + + /** + * Test that the US local is loadable. + */ + public void testUSLocale() + { + Locale usLocal = Locale.US; + Locale.setDefault(usLocal); + ResourceBundle _messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages", + usLocal); + + assertNotNull("Unable to load ResourceBundle", _messages); + + assertEquals("Loaded bundle has incorrect locale.", usLocal, _messages.getLocale()); + } + + /** + * Test that loading an undefined locale will result in loadig of the + * default US locale. + */ + public void testUndefinedLocale() + { + Locale japanese = Locale.JAPANESE; + + Locale.setDefault(japanese); + try + { + ResourceBundle _messages = ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.LogMessages", + japanese); + + assertNotNull("Unable to load ResourceBundle", _messages); + + // If we attempt to load an undefined locale it should default to the Root locale. + assertEquals("Loaded bundle has incorrect locale.", Locale.ROOT, _messages.getLocale()); + } + catch (Throwable t) + { + fail(t.getMessage()); + } + } + +} -- cgit v1.2.1