Skip to content

Commit 0f2c1e5

Browse files
committed
- Renamed tests to align with audit control file and spec.
- Started to add skelton test bodies corresponding with the audit control tags. - added non testable flags for use cases sections.
1 parent a02bd6f commit 0f2c1e5

9 files changed

+919
-464
lines changed

src/test/java/org/javamoney/tck/tests/AccessingMonetaryAmountFormatTest.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/test/java/org/javamoney/tck/tests/CurrencyUnitTest.java

Lines changed: 0 additions & 160 deletions
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package org.javamoney.tck.tests;
2+
3+
import org.jboss.test.audit.annotations.SpecAssertion;
4+
import org.jboss.test.audit.annotations.SpecVersion;
5+
import org.junit.Test;
6+
7+
import javax.money.MonetaryAmount;
8+
import javax.money.MonetaryAmounts;
9+
import javax.money.format.AmountStyle;
10+
import javax.money.format.MonetaryAmountFormat;
11+
import javax.money.format.MonetaryFormats;
12+
import java.text.DecimalFormat;
13+
import java.util.Currency;
14+
import java.util.Locale;
15+
import java.util.Set;
16+
17+
import static org.junit.Assert.*;
18+
19+
@SpecVersion(spec = "JSR 354", version = "1.0.0")
20+
public class FormattingMonetaryAmountsTest{
21+
22+
/**
23+
* Format several amounts, created using the default factory,
24+
* but
25+
* also a test instance, provided by the TCK, to ensure no
26+
* implementation
27+
* dependencies on the implementation.
28+
*/
29+
@SpecAssertion(section = "4.4.1", id = "441-A1")
30+
@Test
31+
public void testNoDepOnAmountImplementation(){
32+
final Locale defaultLocale = Locale.getDefault();
33+
MonetaryAmountFormat amountFormat = MonetaryFormats.getAmountFormat(defaultLocale);
34+
final Number[] values = new Number[]{100, 10000000000000L};// TODO
35+
// other
36+
// values
37+
// and
38+
// currencies
39+
final Currency currency = Currency.getAvailableCurrencies().iterator().next();
40+
for(Number value : values){
41+
MonetaryAmount amount =
42+
MonetaryAmounts.getAmountFactory().setCurrency(currency.getCurrencyCode()).setNumber(value)
43+
.create();
44+
String formattedAmount = amountFormat.format(amount);
45+
MonetaryAmount amountMock = TestMonetaryAmountFactory.getAmount(value, currency);
46+
String formattedAmountMock = amountFormat.format(amountMock);
47+
assertNotNull(formattedAmountMock);
48+
assertEquals(formattedAmountMock, formattedAmount);
49+
}
50+
}
51+
52+
/*
53+
<assertion id="441-A2">
54+
<text>Print several amounts, created using the default factory, but
55+
also a test instance, provided by the TCK, to ensure no
56+
implementation
57+
dependencies on the implementation.
58+
</text>
59+
</assertion>
60+
<assertion id="441-A3">
61+
<text>Parse back several amounts, input created using the
62+
formatting
63+
from 'Format_formatAmounts'.
64+
</text>
65+
</assertion>
66+
<assertion id="441-A4">
67+
<text>Get/set different amount styles (especially patterns, group
68+
sizes, group characters) and compare results with results as from
69+
RI.
70+
Also apply patterns without currency invovled.
71+
</text>
72+
</assertion>
73+
<assertion id="441-A5">
74+
<text>Get/set different monetary contexts and compare results with
75+
results from parsed amounts.
76+
</text>
77+
</assertion>
78+
<assertion id="441-A6">
79+
<text>Get/set default currency, try to parse patterns without
80+
currency information.
81+
</text>
82+
</assertion>
83+
*/
84+
85+
/**
86+
* AccessingMonetaryAmountFormat using
87+
* MonetaryFormats.getAmountFormat(Locale locale), all locales
88+
* available also from java.text.DecimalFormat must be supported.
89+
*/
90+
@SpecAssertion(section = "4.4.1", id = "441-B1")
91+
@Test
92+
public void testLocalesSupported(){
93+
Locale[] jdkDecimalFormatLocales = DecimalFormat.getAvailableLocales();
94+
for(Locale jdkDecimalFormatLocale : jdkDecimalFormatLocales){
95+
MonetaryAmountFormat amountFormat = MonetaryFormats.getAmountFormat(jdkDecimalFormatLocale);
96+
assertNotNull(amountFormat);
97+
assertEquals(jdkDecimalFormatLocale, amountFormat.getAmountStyle().getLocale());
98+
}
99+
}
100+
101+
/**
102+
* AccessingMonetaryAmountFormat using
103+
* MonetaryFormats.getAmountFormat(AmountStyle style), all locales
104+
* available also from java.text.DecimalFormat must be supported
105+
* (using AmountStyle.of(Locale)).
106+
*/
107+
@Test
108+
@SpecAssertion(section = "4.4.1", id = "441-B2")
109+
public void testGetAmountFormat(){
110+
for(Locale locale : DecimalFormat.getAvailableLocales()){
111+
assertNotNull(MonetaryFormats.getAmountFormat(AmountStyle.of(locale)));
112+
}
113+
}
114+
115+
/**
116+
* Test MonetaryFormats.getAvailableLocales, all locales available also from java.text.DecimalFormat must be
117+
* supported (using AmountStyle.of(Locale)), more locales are possible.
118+
*/
119+
@Test
120+
@SpecAssertion(section = "4.4.1", id = "441-B3")
121+
public void testGetAvailableLocales(){
122+
Set<Locale> locales = MonetaryFormats.getAvailableLocales();
123+
for(Locale locale : DecimalFormat.getAvailableLocales()){
124+
assertTrue(locales.contains(locale));
125+
}
126+
}
127+
128+
/**
129+
* Test MonetaryFormats.getAvailableLocales, all locales available also from java.text.DecimalFormat must be
130+
* supported (using AmountStyle.of(Locale)), more locales are possible.
131+
*/
132+
@Test
133+
@SpecAssertion(section = "4.4.1", id = "441-B3")
134+
public void testAmountStyleOf(){
135+
for(Locale locale : DecimalFormat.getAvailableLocales()){
136+
assertNotNull(AmountStyle.of(locale));
137+
}
138+
}
139+
}

0 commit comments

Comments
 (0)