diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2009-08-12 17:59:08 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2009-08-12 17:59:08 +0000 |
| commit | b8a9d2ca108af229c3eda56ed57ba3bc2e303654 (patch) | |
| tree | 426fcf2933c45487bed5ed9caae6a76fac13df12 /java/broker/src/test | |
| parent | 18e76de9f3b2147ec83b2346feaaa12d922de858 (diff) | |
| download | qpid-python-b8a9d2ca108af229c3eda56ed57ba3bc2e303654.tar.gz | |
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
Diffstat (limited to 'java/broker/src/test')
| -rw-r--r-- | java/broker/src/test/java/org/apache/qpid/server/logging/LogMessageTest.java | 71 |
1 files changed, 71 insertions, 0 deletions
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()); + } + } + +} |
