Make tests a little more bullet-proof.

This commit is contained in:
Gary Gregory 2017-10-09 14:52:43 -06:00
parent 0726ffe1e9
commit 87eff4c78f

View File

@ -138,7 +138,7 @@ public void testExtendedAndBuiltInFormats() {
} }
final StringBuilder expected = new StringBuilder(); final StringBuilder expected = new StringBuilder();
expected.append("Name: "); expected.append("Name: ");
expected.append(args[0].toString().toUpperCase()); expected.append(args[0].toString().toUpperCase(Locale.ROOT));
expected.append(" DOB: "); expected.append(" DOB: ");
expected.append(df.format(args[1])); expected.append(df.format(args[1]));
expected.append(" Salary: "); expected.append(" Salary: ");
@ -422,8 +422,9 @@ private static class UpperCaseFormat extends Format {
@Override @Override
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) { public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
return toAppendTo.append(((String)obj).toUpperCase()); return toAppendTo.append(((String) obj).toUpperCase(Locale.ROOT));
} }
@Override @Override
public Object parseObject(final String source, final ParsePosition pos) { public Object parseObject(final String source, final ParsePosition pos) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -437,6 +438,7 @@ public Object parseObject(final String source, final ParsePosition pos) {
*/ */
private static class LowerCaseFormatFactory implements FormatFactory { private static class LowerCaseFormatFactory implements FormatFactory {
private static final Format LOWER_INSTANCE = new LowerCaseFormat(); private static final Format LOWER_INSTANCE = new LowerCaseFormat();
@Override @Override
public Format getFormat(final String name, final String arguments, final Locale locale) { public Format getFormat(final String name, final String arguments, final Locale locale) {
return LOWER_INSTANCE; return LOWER_INSTANCE;
@ -447,6 +449,7 @@ public Format getFormat(final String name, final String arguments, final Locale
*/ */
private static class UpperCaseFormatFactory implements FormatFactory { private static class UpperCaseFormatFactory implements FormatFactory {
private static final Format UPPER_INSTANCE = new UpperCaseFormat(); private static final Format UPPER_INSTANCE = new UpperCaseFormat();
@Override @Override
public Format getFormat(final String name, final String arguments, final Locale locale) { public Format getFormat(final String name, final String arguments, final Locale locale) {
return UPPER_INSTANCE; return UPPER_INSTANCE;
@ -456,6 +459,7 @@ public Format getFormat(final String name, final String arguments, final Locale
* {@link FormatFactory} implementation to override date format "short" to "default". * {@link FormatFactory} implementation to override date format "short" to "default".
*/ */
private static class OverrideShortDateFormatFactory implements FormatFactory { private static class OverrideShortDateFormatFactory implements FormatFactory {
@Override @Override
public Format getFormat(final String name, final String arguments, final Locale locale) { public Format getFormat(final String name, final String arguments, final Locale locale) {
return !"short".equals(arguments) ? null return !"short".equals(arguments) ? null