~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/backwards/src/test/org/apache/lucene/messages/TestNLS.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.messages;
2
 
 
3
 
/**
4
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
5
 
 * contributor license agreements.  See the NOTICE file distributed with
6
 
 * this work for additional information regarding copyright ownership.
7
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
8
 
 * (the "License"); you may not use this file except in compliance with
9
 
 * the License.  You may obtain a copy of the License at
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
13
 
 * Unless required by applicable law or agreed to in writing, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
import java.util.Locale;
21
 
 
22
 
import org.apache.lucene.util.LuceneTestCase;
23
 
 
24
 
/**
25
 
 */
26
 
public class TestNLS extends LuceneTestCase {
27
 
  public void testMessageLoading() {
28
 
    Message invalidSyntax = new MessageImpl(
29
 
        MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
30
 
    /* 
31
 
     * if the default locale is ja, you get ja as a fallback:
32
 
     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
33
 
     */
34
 
    if (!Locale.getDefault().getLanguage().equals("ja"))
35
 
      assertEquals("Syntax Error: XXX", invalidSyntax.getLocalizedMessage(Locale.ENGLISH));
36
 
  }
37
 
 
38
 
  public void testMessageLoading_ja() {
39
 
    Message invalidSyntax = new MessageImpl(
40
 
        MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
41
 
    assertEquals("構文エラー: XXX", invalidSyntax
42
 
        .getLocalizedMessage(Locale.JAPANESE));
43
 
  }
44
 
 
45
 
  public void testNLSLoading() {
46
 
    String message = NLS
47
 
        .getLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION, Locale.ENGLISH);
48
 
    /* 
49
 
     * if the default locale is ja, you get ja as a fallback:
50
 
     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
51
 
     */
52
 
    if (!Locale.getDefault().getLanguage().equals("ja"))
53
 
      assertEquals("Truncated unicode escape sequence.", message);
54
 
 
55
 
    message = NLS.getLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX, Locale.ENGLISH,
56
 
        "XXX");
57
 
    /* 
58
 
     * if the default locale is ja, you get ja as a fallback:
59
 
     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
60
 
     */
61
 
    if (!Locale.getDefault().getLanguage().equals("ja"))
62
 
      assertEquals("Syntax Error: XXX", message);
63
 
  }
64
 
 
65
 
  public void testNLSLoading_ja() {
66
 
    String message = NLS.getLocalizedMessage(
67
 
        MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
68
 
        Locale.JAPANESE);
69
 
    assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。", message);
70
 
 
71
 
    message = NLS.getLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
72
 
        Locale.JAPANESE, "XXX");
73
 
    assertEquals("構文エラー: XXX", message);
74
 
  }
75
 
 
76
 
  public void testNLSLoading_xx_XX() {
77
 
    Locale locale = new Locale("xx", "XX", "");
78
 
    String message = NLS.getLocalizedMessage(
79
 
        MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
80
 
        locale);
81
 
    /* 
82
 
     * if the default locale is ja, you get ja as a fallback:
83
 
     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
84
 
     */
85
 
    if (!Locale.getDefault().getLanguage().equals("ja"))
86
 
      assertEquals("Truncated unicode escape sequence.", message);
87
 
 
88
 
    message = NLS.getLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
89
 
        locale, "XXX");
90
 
    /* 
91
 
     * if the default locale is ja, you get ja as a fallback:
92
 
     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
93
 
     */
94
 
    if (!Locale.getDefault().getLanguage().equals("ja"))
95
 
      assertEquals("Syntax Error: XXX", message);
96
 
  }
97
 
 
98
 
  public void testMissingMessage() {
99
 
    Locale locale = Locale.ENGLISH;
100
 
    String message = NLS.getLocalizedMessage(
101
 
        MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);
102
 
 
103
 
    assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
104
 
        + locale.toString() + " not found.", message);
105
 
  }
106
 
}