Skip to content

Commit a7119ee

Browse files
committed
Added tests for "Accessing Monetary Amount Formats"
1 parent 4fe104b commit a7119ee

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.javamoney.tck.tests;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertNotNull;
5+
import static org.junit.Assert.assertTrue;
6+
7+
import java.text.DecimalFormat;
8+
import java.util.Locale;
9+
import java.util.Set;
10+
11+
import javax.money.format.AmountStyle;
12+
import javax.money.format.MonetaryAmountFormat;
13+
import javax.money.format.MonetaryFormats;
14+
15+
import org.jboss.test.audit.annotations.SpecAssertion;
16+
import org.jboss.test.audit.annotations.SpecVersion;
17+
import org.junit.Test;
18+
19+
@SpecVersion(spec = "JSR 354", version = "1.0.0")
20+
public class AccessingMonetaryAmountFormatTest {
21+
22+
@SpecAssertion(section = "4.4.1", id = "441-B1")
23+
@Test
24+
public void testLocalesSupported() {
25+
Locale[] jdkDecimalFormatLocales = DecimalFormat.getAvailableLocales();
26+
for (Locale jdkDecimalFormatLocale : jdkDecimalFormatLocales) {
27+
MonetaryAmountFormat amountFormat = MonetaryFormats
28+
.getAmountFormat(jdkDecimalFormatLocale);
29+
assertNotNull(amountFormat);
30+
assertEquals(jdkDecimalFormatLocale, amountFormat.getAmountStyle()
31+
.getLocale());
32+
}
33+
}
34+
35+
@Test
36+
@SpecAssertion(section = "4.4.1", id = "441-B2")
37+
public void testGetAmountFormat() {
38+
for (Locale locale : DecimalFormat.getAvailableLocales()) {
39+
assertNotNull(MonetaryFormats.getAmountFormat(AmountStyle
40+
.of(locale)));
41+
}
42+
}
43+
44+
@Test
45+
@SpecAssertion(section = "4.4.1", id = "441-B3")
46+
public void testGetAvailableLocales() {
47+
Set<Locale> locales = MonetaryFormats.getAvailableLocales();
48+
for (Locale locale : DecimalFormat.getAvailableLocales()) {
49+
assertTrue(locales.contains(locale));
50+
}
51+
}
52+
53+
@Test
54+
@SpecAssertion(section = "4.4.1", id = "441-B3")
55+
public void testAmountStyleOf() {
56+
for (Locale locale : DecimalFormat.getAvailableLocales()) {
57+
assertNotNull(AmountStyle.of(locale));
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)