Remove previous ExtendedMesageFormat tests and update package suite to include ExtendedMessageFormatTest

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@631652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Niall Pemberton 2008-02-27 17:12:38 +00:00
parent 7f5ffc6036
commit 60e5d4933c
6 changed files with 14 additions and 973 deletions

View File

@ -1,306 +0,0 @@
/*
* 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.commons.lang.text;
import java.text.ChoiceFormat;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.FieldPosition;
import java.text.Format;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import org.apache.commons.lang.SystemUtils;
import junit.framework.TestCase;
/**
* Abstract testcase to verify behavior of default-configuration
* ExtendedMessageFormat vs. MessageFormat.
*
* @author Matt Benson
* @since 2.4
* @version $Id$
*/
public abstract class AbstractMessageFormatTest extends TestCase {
protected static final Double[] NUMBERS = { new Double(0.1),
new Double(1.1), new Double(2.1) };
protected static final Object[] DATES = {
new GregorianCalendar(1970, Calendar.JANUARY, 01, 0, 15, 20)
.getTime(),
new GregorianCalendar(1970, Calendar.FEBRUARY, 02, 12, 30, 35)
.getTime(),
new GregorianCalendar(1970, Calendar.MARCH, 03, 18, 45, 50)
.getTime() };
protected Locale locale;
/**
* {@inheritDoc}
*/
protected void setUp() throws Exception {
super.setUp();
this.locale = getLocale();
}
/**
* Create a MessageFormat.
* @param pattern
* @param locale
* @return
*/
protected abstract MessageFormat createMessageFormat(String pattern,
Locale locale);
/**
* Get the Locale to use.
* @return
*/
protected abstract Locale getLocale();
protected void doAssertions(String expected, String pattern, Object[] args) {
doAssertions(expected, pattern, args, pattern);
}
protected void doAssertions(String expected, String pattern, Object[] args,
String toPattern) {
MessageFormat f = createMessageFormat(pattern, locale);
assertEquals(expected, f.format(args));
if (SystemUtils.isJavaVersionAtLeast(140)) {
assertEquals(toPattern, f.toPattern());
}
}
protected void doAssertions(Format format, Object[] args) {
doAssertions(format, args, null);
}
protected void doAssertions(Format format, Object[] args, String formatName) {
doAssertions(format, args, formatName, null);
}
protected void doAssertions(Format format, Object[] args,
String formatName, String decodeFormatName) {
StringBuffer pattern = new StringBuffer();
StringBuffer expected = new StringBuffer();
StringBuffer decodePattern = new StringBuffer();
for (int i = 0; i < args.length; i++) {
pattern.append(i).append(": {").append(i);
if (formatName != null) {
pattern.append(',').append(formatName);
}
pattern.append("}; ");
expected.append(i).append(": ");
if (format != null) {
format.format(args[i], expected, new FieldPosition(0));
} else {
expected.append(String.valueOf(args[i]));
}
expected.append("; ");
decodePattern.append(i).append(": {").append(i);
if (decodeFormatName != null || formatName != null) {
decodePattern.append(',').append(
decodeFormatName == null ? formatName
: decodeFormatName);
}
decodePattern.append("}; ");
}
doAssertions(expected.toString(), pattern.toString(), args,
decodePattern.toString());
}
public void testNoFormatElements() {
StringBuffer pattern = new StringBuffer();
for (int i = 0; i < NUMBERS.length; i++) {
if (i > 0) {
pattern.append("; ");
}
pattern.append(i).append(": ").append(NUMBERS[i]);
}
String p = pattern.toString();
doAssertions(p, p, null);
}
public void testSimpleStrings() {
doAssertions(null, new Object[] { "foo", "bar", "baz"}, null);
}
public void testSimpleNumbers() {
doAssertions(NumberFormat.getInstance(locale), NUMBERS, null);
}
public void testSimpleDates() {
doAssertions(DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT, locale), DATES, null);
}
public void testNumber() {
doAssertions(NumberFormat.getInstance(locale), NUMBERS, "number");
}
public void testNumberLooseFormatting() {
doAssertions(NumberFormat.getInstance(locale), NUMBERS, " number ",
"number");
}
public void testInteger() {
doAssertions(getIntegerNumberFormat(locale), NUMBERS,
"number,integer");
}
public void testIntegerLooseFormatting() {
doAssertions(getIntegerNumberFormat(locale), NUMBERS,
" number , integer ", "number,integer");
}
public void testCurrency() {
doAssertions(NumberFormat.getCurrencyInstance(locale), NUMBERS,
"number,currency");
}
public void testPercent() {
doAssertions(NumberFormat.getPercentInstance(locale), NUMBERS,
"number,percent");
}
public void testNumberPattern() {
doAssertions(new DecimalFormat("#000.000", new DecimalFormatSymbols(
locale)), NUMBERS, "number,#000.000");
}
public void testDate() {
doAssertions(DateFormat.getDateInstance(DateFormat.DEFAULT, locale),
DATES, "date");
}
public void testDateLooseFormatting() {
doAssertions(DateFormat.getDateInstance(DateFormat.DEFAULT, locale),
DATES, " date ", "date");
}
public void testShortDate() {
DateFormat shortDf = DateFormat.getDateInstance(DateFormat.SHORT, locale);
DateFormat defaultDf = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
doAssertions(shortDf, DATES, "date,short",
shortDf.equals(defaultDf) ? "date" : "date,short");
}
public void testShortDateLooseFormatting() {
DateFormat shortDf = DateFormat.getDateInstance(DateFormat.SHORT, locale);
DateFormat defaultDf = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
doAssertions(shortDf, DATES, " date , short ",
shortDf.equals(defaultDf) ? "date" : "date,short");
}
public void testMediumDate() {
doAssertions(DateFormat.getDateInstance(DateFormat.MEDIUM, locale),
DATES, "date,medium", "date");
}
public void testLongDate() {
DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG, locale);
DateFormat defaultDf = DateFormat.getDateInstance(DateFormat.DEFAULT,
locale);
doAssertions(longDf, DATES, "date,long",
longDf.equals(defaultDf) ? "date" : "date,long");
}
public void testFullDate() {
DateFormat fullDf = DateFormat.getDateInstance(DateFormat.FULL, locale);
DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG, locale);
doAssertions(fullDf, DATES, "date,full",
fullDf.equals(longDf) ? "date,long" : "date,full");
}
public void testDatePattern() {
doAssertions(new SimpleDateFormat("Gyyyy.D", locale), DATES,
"date,Gyyyy.D");
}
public void testTime() {
doAssertions(DateFormat.getTimeInstance(DateFormat.DEFAULT, locale),
DATES, "time");
}
public void testShortTime() {
doAssertions(DateFormat.getTimeInstance(DateFormat.SHORT, locale),
DATES, "time,short");
}
public void testMediumTime() {
doAssertions(DateFormat.getTimeInstance(DateFormat.MEDIUM, locale),
DATES, "time,medium", "time");
}
public void testLongTime() {
doAssertions(DateFormat.getTimeInstance(DateFormat.LONG, locale),
DATES, "time,long");
}
public void testFullTime() {
DateFormat fullDf = DateFormat.getTimeInstance(DateFormat.FULL, locale);
DateFormat longDf = DateFormat.getTimeInstance(DateFormat.LONG, locale);
doAssertions(fullDf, DATES, "time,full",
fullDf.equals(longDf) ? "time,long" : "time,full");
}
public void testTimePattern() {
doAssertions(new SimpleDateFormat("aHms", locale), DATES, "date,aHms");
}
public void testChoice() {
doAssertions(new ChoiceFormat("0.0#x|1.0#y|2.0#z"), NUMBERS,
"choice,0.0#x|1.0#y|2.0#z");
}
public void testChoiceLooseFormatting() {
doAssertions(new ChoiceFormat("0.0#x |1.0#y |2.0#z "), NUMBERS,
"choice,0.0#x |1.0#y |2.0#z ");
}
public void testChoiceRecursive() {
NumberFormat nf = NumberFormat.getInstance(locale);
StringBuffer choice = new StringBuffer();
StringBuffer format = new StringBuffer("choice,");
for (int i = 0; i < NUMBERS.length; i++) {
Double d = new Double(Math.floor(NUMBERS[i].doubleValue()));
if (i > 0) {
choice.append('|');
format.append('|');
}
choice.append(d).append('#').append(
nf.format(NUMBERS[i].doubleValue()));
format.append(d).append('#').append('{').append(i).append('}');
}
doAssertions(new ChoiceFormat(choice.toString()), NUMBERS, format
.toString());
}
private NumberFormat getIntegerNumberFormat(Locale locale) {
NumberFormat result = NumberFormat.getInstance(locale);
result.setMaximumFractionDigits(0);
result.setParseIntegerOnly(true);
return result;
}
}

View File

@ -1,179 +0,0 @@
/*
* 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.commons.lang.text;
import java.text.MessageFormat;
import java.util.Locale;
/**
* Baseline tests for ExtendedMessageFormat
*
* @author Matt Benson
* @since 2.4
* @version $Id$
*/
public abstract class ExtendedMessageFormatBaselineTest extends
AbstractMessageFormatTest {
/**
* Tests for <code>Locale.US</code>
*
* @author mbenson
*/
public static class US extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.US;
}
}
/**
* Tests for <code>Locale.UK</code>
*
* @author mbenson
*/
public static class UK extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.UK;
}
}
/**
* Tests for <code>Locale.GERMANY</code>
*
* @author mbenson
*/
public static class DE extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.GERMANY;
}
}
/**
* Tests for <code>Locale.ITALY</code>
*
* @author mbenson
*/
public static class IT extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.ITALY;
}
}
/**
* Tests for <code>Locale.JAPAN</code>
*
* @author mbenson
*/
public static class JP extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.JAPAN;
}
}
/**
* Tests for <code>Locale.CHINA</code>
*
* @author mbenson
*/
public static class CN extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CHINA;
}
}
/**
* Tests for <code>Locale.CANADA</code>
*
* @author mbenson
*/
public static class CA extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CANADA;
}
}
/**
* Tests for <code>Locale.FRANCE</code>
*
* @author mbenson
*/
public static class FR extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.FRANCE;
}
}
/**
* Tests for <code>Locale.KOREA</code>
*
* @author mbenson
*/
public static class KR extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.KOREA;
}
}
/**
* Tests for <code>Locale.TAIWAN</code>
*
* @author mbenson
*/
public static class TW extends ExtendedMessageFormatBaselineTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.TAIWAN;
}
}
/**
* {@inheritDoc}
*/
protected MessageFormat createMessageFormat(String pattern, Locale locale) {
return new ExtendedMessageFormat(pattern, locale);
}
}

View File

@ -27,7 +27,9 @@
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite;
/** /**
* Test case for {@link ExtendedMessageFormat}. * Test case for {@link ExtendedMessageFormat}.
@ -45,6 +47,17 @@ public class ExtendedMessageFormatTest extends TestCase {
private Map registry = new HashMap(); private Map registry = new HashMap();
/**
* Return a new test suite containing this test case.
*
* @return a new test suite containing this test case
*/
public static Test suite() {
TestSuite suite = new TestSuite(ExtendedMessageFormatTest.class);
suite.setName("ExtendedMessageFormat Tests");
return suite;
}
/** /**
* Create a new test case. * Create a new test case.
* *

View File

@ -1,276 +0,0 @@
/*
* 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.commons.lang.text;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.Format;
import java.text.MessageFormat;
import java.text.ParsePosition;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Locale;
/**
* Extension tests for {@link ExtendedMessageFormat}
*
* @author Matt Benson
* @since 2.4
* @version $Id$
*/
public abstract class MessageFormatExtensionTest extends
AbstractMessageFormatTest {
/**
* Tests for <code>Locale.US</code>
*
* @author mbenson
*/
public static class US extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.US;
}
}
/**
* Tests for <code>Locale.UK</code>
*
* @author mbenson
*/
public static class UK extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.UK;
}
}
/**
* Tests for <code>Locale.GERMANY</code>
*
* @author mbenson
*/
public static class DE extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.GERMANY;
}
}
/**
* Tests for <code>Locale.ITALY</code>
*
* @author mbenson
*/
public static class IT extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.ITALY;
}
}
/**
* Tests for <code>Locale.JAPAN</code>
*
* @author mbenson
*/
public static class JP extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.JAPAN;
}
}
/**
* Tests for <code>Locale.CHINA</code>
*
* @author mbenson
*/
public static class CN extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CHINA;
}
}
/**
* Tests for <code>Locale.CANADA</code>
*
* @author mbenson
*/
public static class CA extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CANADA;
}
}
/**
* Tests for <code>Locale.FRANCE</code>
*
* @author mbenson
*/
public static class FR extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.FRANCE;
}
}
/**
* Tests for <code>Locale.KOREA</code>
*
* @author mbenson
*/
public static class KR extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.KOREA;
}
}
/**
* Tests for <code>Locale.TAIWAN</code>
*
* @author mbenson
*/
public static class TW extends MessageFormatExtensionTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.TAIWAN;
}
}
static class ProperNameCapitalizationFormat extends Format {
private static final long serialVersionUID = -6081911520622186866L;
private static final StrMatcher MATCH = StrMatcher
.charSetMatcher(" ,.");
/**
* {@inheritDoc}
*/
public StringBuffer format(Object obj, StringBuffer toAppendTo,
FieldPosition fpos) {
if (!(obj instanceof String)) {
throw new IllegalArgumentException();
}
char[] buffer = ((String) obj).toCharArray();
ParsePosition pos = new ParsePosition(0);
while (pos.getIndex() < buffer.length) {
char c = buffer[pos.getIndex()];
if (Character.isLowerCase(c)) {
c = Character.toUpperCase(c);
}
if (Character.isUpperCase(c)) {
toAppendTo.append(c);
next(pos);
}
int start = pos.getIndex();
seekDelimiter(buffer, pos);
toAppendTo.append(new String(buffer, start, pos.getIndex()
- start).toLowerCase());
}
return toAppendTo;
}
/**
* Unable to do much; return the String.
*/
public Object parseObject(String source, ParsePosition pos) {
return source.substring(pos.getIndex());
}
private static void seekDelimiter(char[] buffer, ParsePosition pos) {
for (; pos.getIndex() < buffer.length
&& MATCH.isMatch(buffer, pos.getIndex()) == 0; next(pos))
;
if (pos.getIndex() >= buffer.length) {
return;
}
int len = 0;
do {
len = MATCH.isMatch(buffer, pos.getIndex());
pos.setIndex(pos.getIndex() + len);
} while (len > 0 && pos.getIndex() < buffer.length);
}
private static void next(ParsePosition pos) {
pos.setIndex(pos.getIndex() + 1);
}
}
/**
* {@inheritDoc}
*/
protected MessageFormat createMessageFormat(String pattern, Locale locale) {
final ProperNameCapitalizationFormat properNameCapitalizationFormat = new ProperNameCapitalizationFormat();
final FormatFactory ff = new FormatFactory() {
public Format getFormat(String name, String arguments, Locale locale) {
return "properName".equals(name) ? properNameCapitalizationFormat : null;
}
};
return new ExtendedMessageFormat(pattern, locale, new HashMap() { { put("properName", ff); }});
}
public void testProperName() {
doAssertions("John Q. Public; John Q. Public",
"{0,properName}; {1,properName}", new String[] {
"JOHN Q. PUBLIC", "john q. public" });
}
public void testMixed() {
StringBuffer expected = new StringBuffer("John Q. Public was born on ");
Date dob = new GregorianCalendar(1970, Calendar.JANUARY, 01, 0, 15, 20)
.getTime();
DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG, locale);
longDf.format(dob, expected, new FieldPosition(0));
expected.append('.');
String pattern = "{0,properName} was born on {1,date,long}.";
StringBuffer toPattern = new StringBuffer(pattern);
if (longDf.equals(DateFormat.getDateInstance(DateFormat.DEFAULT, locale))) {
int idx = pattern.indexOf(",long");
toPattern.delete(idx, idx + ",long".length());
}
doAssertions(expected.toString(),
pattern, new Object[] {
"john q. public",
new GregorianCalendar(1970, Calendar.JANUARY, 01, 0,
15, 20).getTime() }, toPattern.toString());
}
}

View File

@ -1,182 +0,0 @@
/*
* 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.commons.lang.text;
import java.text.MessageFormat;
import java.util.Locale;
/**
* Baseline tests for java.text.MessageFormat.
*
* @author Matt Benson
* @since 2.4
* @version $Id$
*/
public abstract class MessageFormatTest extends AbstractMessageFormatTest {
/**
* Tests for <code>Locale.US</code>
*
* @author mbenson
*/
public static class US extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.US;
}
}
/**
* Tests for <code>Locale.UK</code>
*
* @author mbenson
*/
public static class UK extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.UK;
}
}
/**
* Tests for <code>Locale.GERMANY</code>
*
* @author mbenson
*/
public static class DE extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.GERMANY;
}
}
/**
* Tests for <code>Locale.ITALY</code>
*
* @author mbenson
*/
public static class IT extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.ITALY;
}
}
/**
* Tests for <code>Locale.JAPAN</code>
*
* @author mbenson
*/
public static class JP extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.JAPAN;
}
}
/**
* Tests for <code>Locale.CHINA</code>
*
* @author mbenson
*/
public static class CN extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CHINA;
}
}
/**
* Tests for <code>Locale.CANADA</code>
*
* @author mbenson
*/
public static class CA extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.CANADA;
}
}
/**
* Tests for <code>Locale.FRANCE</code>
*
* @author mbenson
*/
public static class FR extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.FRANCE;
}
}
/**
* Tests for <code>Locale.KOREA</code>
*
* @author mbenson
*/
public static class KR extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.KOREA;
}
}
/**
* Tests for <code>Locale.TAIWAN</code>
*
* @author mbenson
*/
public static class TW extends MessageFormatTest {
/**
* {@inheritDoc}
*/
protected Locale getLocale() {
return Locale.TAIWAN;
}
}
/**
* {@inheritDoc}
*/
protected MessageFormat createMessageFormat(String pattern, Locale locale) {
MessageFormat result = new MessageFormat(pattern);
if (!Locale.getDefault().equals(locale)) {
result.setLocale(locale);
result.applyPattern(pattern);
}
return result;
}
}

View File

@ -50,42 +50,13 @@ public static Test suite() {
TestSuite suite = new TestSuite(); TestSuite suite = new TestSuite();
suite.setName("Commons-Lang-Text Tests"); suite.setName("Commons-Lang-Text Tests");
suite.addTest(CompositeFormatTest.suite()); suite.addTest(CompositeFormatTest.suite());
suite.addTest(ExtendedMessageFormatTest.suite());
suite.addTest(StrBuilderTest.suite()); suite.addTest(StrBuilderTest.suite());
suite.addTest(StrBuilderAppendInsertTest.suite()); suite.addTest(StrBuilderAppendInsertTest.suite());
suite.addTest(StrLookupTest.suite()); suite.addTest(StrLookupTest.suite());
suite.addTest(StrMatcherTest.suite()); suite.addTest(StrMatcherTest.suite());
suite.addTest(StrSubstitutorTest.suite()); suite.addTest(StrSubstitutorTest.suite());
suite.addTest(StrTokenizerTest.suite()); suite.addTest(StrTokenizerTest.suite());
suite.addTestSuite(MessageFormatTest.US.class);
suite.addTestSuite(MessageFormatTest.UK.class);
suite.addTestSuite(MessageFormatTest.DE.class);
suite.addTestSuite(MessageFormatTest.IT.class);
suite.addTestSuite(MessageFormatTest.JP.class);
suite.addTestSuite(MessageFormatTest.CA.class);
suite.addTestSuite(MessageFormatTest.CN.class);
suite.addTestSuite(MessageFormatTest.FR.class);
suite.addTestSuite(MessageFormatTest.KR.class);
suite.addTestSuite(MessageFormatTest.TW.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.US.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.UK.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.DE.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.IT.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.JP.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.CA.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.CN.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.FR.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.KR.class);
suite.addTestSuite(ExtendedMessageFormatBaselineTest.TW.class);
suite.addTestSuite(MessageFormatExtensionTest.US.class);
suite.addTestSuite(MessageFormatExtensionTest.UK.class);
suite.addTestSuite(MessageFormatExtensionTest.DE.class);
suite.addTestSuite(MessageFormatExtensionTest.IT.class);
suite.addTestSuite(MessageFormatExtensionTest.JP.class);
suite.addTestSuite(MessageFormatExtensionTest.CA.class);
suite.addTestSuite(MessageFormatExtensionTest.CN.class);
suite.addTestSuite(MessageFormatExtensionTest.FR.class);
suite.addTestSuite(MessageFormatExtensionTest.KR.class);
suite.addTestSuite(MessageFormatExtensionTest.TW.class);
return suite; return suite;
} }