2137N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
2137N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2137N/A *
2137N/A * This code is free software; you can redistribute it and/or modify it
2137N/A * under the terms of the GNU General Public License version 2 only, as
2137N/A * published by the Free Software Foundation.
2137N/A *
2137N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2137N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2137N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2137N/A * version 2 for more details (a copy is included in the LICENSE file that
2137N/A * accompanied this code).
2137N/A *
2137N/A * You should have received a copy of the GNU General Public License version
2137N/A * 2 along with this work; if not, write to the Free Software Foundation,
2137N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2137N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2137N/A */
2137N/A
2137N/A/*
2137N/A * @test
2137N/A * @bug 5047314
2137N/A * @summary verify that compare() and getCollationKey() don't go into an infinite loop for unfinished Thai/Lao text.
2137N/A * @run main/timeout=60 Bug5047314
2137N/A */
2137N/Aimport java.text.Collator;
2137N/Aimport java.util.Locale;
2137N/A
2137N/Apublic class Bug5047314 {
2137N/A
2137N/A private static Collator colLao = Collator.getInstance(new Locale("lo"));
2137N/A private static Collator colThai = Collator.getInstance(new Locale("th"));
2137N/A
2137N/A private static String[] textLao = {
2137N/A "\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"
2137N/A };
2137N/A private static String[] textThai = {
2137N/A "\u0e40", "\u0e41", "\u0e42", "\u0e43", "\u0e44"
2137N/A };
2137N/A
2137N/A public static void main(String[] args) {
2137N/A testLao1();
2137N/A testLao2();
2137N/A testThai1();
2137N/A testThai2();
2137N/A }
2137N/A
2137N/A private static void testLao1() {
2137N/A System.out.print("Test(Lao 1) .... ");
2137N/A for (int i = 0; i < textLao.length; i++) {
2137N/A colLao.compare(textLao[i], textLao[i]);
2137N/A }
2137N/A System.out.println("Passed.");
2137N/A }
2137N/A
2137N/A private static void testLao2() {
2137N/A System.out.print("Test(Lao 2) .... ");
2137N/A for (int i = 0; i < textLao.length; i++) {
2137N/A colLao.compare(textLao[i], textLao[i]);
2137N/A }
2137N/A System.out.println("Passed.");
2137N/A }
2137N/A
2137N/A private static void testThai1() {
2137N/A System.out.print("Test(Thai 1) .... ");
2137N/A for (int i = 0; i < textThai.length; i++) {
2137N/A colThai.compare(textThai[i], textThai[i]);
2137N/A }
2137N/A System.out.println("Passed.");
2137N/A }
2137N/A
2137N/A private static void testThai2() {
2137N/A System.out.print("Test(Thai 2) .... ");
2137N/A for (int i = 0; i < textThai.length; i++) {
2137N/A colThai.getCollationKey(textThai[i]);
2137N/A }
2137N/A System.out.println("Passed.");
2137N/A }
2137N/A
2137N/A}