|
|
|
|
@ -1,20 +1,41 @@
@@ -1,20 +1,41 @@
|
|
|
|
|
package org.springframework.format.number; |
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed 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. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
package org.springframework.format.number; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
import org.junit.After; |
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
import org.junit.Before; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder; |
|
|
|
|
import org.springframework.core.convert.support.ConversionServiceFactory; |
|
|
|
|
import org.springframework.format.annotation.NumberFormat; |
|
|
|
|
import org.springframework.format.annotation.NumberFormat.Style; |
|
|
|
|
import org.springframework.format.support.FormattingConversionService; |
|
|
|
|
import org.springframework.validation.DataBinder; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Keith Donald |
|
|
|
|
* @author Juergen Hoeller |
|
|
|
|
*/ |
|
|
|
|
public class NumberFormattingTests { |
|
|
|
|
|
|
|
|
|
private FormattingConversionService conversionService = new FormattingConversionService(); |
|
|
|
|
@ -23,6 +44,7 @@ public class NumberFormattingTests {
@@ -23,6 +44,7 @@ public class NumberFormattingTests {
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setUp() { |
|
|
|
|
ConversionServiceFactory.addDefaultConverters(conversionService); |
|
|
|
|
conversionService.addFormatterForFieldType(Number.class, new NumberFormatter()); |
|
|
|
|
conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory()); |
|
|
|
|
LocaleContextHolder.setLocale(Locale.US); |
|
|
|
|
|