Skip to content

Commit ae91037

Browse files
committed
- Added test skeletons for many areas, some still missing.
- Commented out areas in test-audit.xml that are only recommendations. - Moved test classes along the functionalities in separate packages.
1 parent 45de32c commit ae91037

17 files changed

+1459
-68
lines changed

src/test/java/org/javamoney/tck/JSR354TestConfiguration.java

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,46 @@
99
*/
1010
package org.javamoney.tck;
1111

12-
import java.util.Collection;
13-
import java.util.ServiceLoader;
14-
1512
import javax.money.CurrencyUnit;
1613
import javax.money.MonetaryAmount;
14+
import javax.money.MonetaryOperator;
1715
import javax.money.spi.MonetaryAmountFactoryProviderSpi;
16+
import java.util.Collection;
17+
import java.util.ServiceLoader;
1818

1919
/**
2020
* Libraries that implement this JSR and want to be tested with this TCK must implement this
2121
* interface and register it using the {@link ServiceLoader}.
22-
*
22+
*
2323
* @author Anatole Tresch
2424
*/
25-
public interface JSR354TestConfiguration {
25+
public interface JSR354TestConfiguration{
26+
27+
/**
28+
* Return a collection with all {@link MonetaryAmount} classes that are implemented. The list
29+
* must not be empty and should contain <b>every</b> amount class implemented.<br/>
30+
* This enables the TCK to check in addition to the basic implementation compliance, if
31+
* according {@link MonetaryAmountFactoryProviderSpi} are registered/available correctly.
32+
*
33+
* @return a collection with all implemented amount classes, not null.
34+
*/
35+
Collection<Class> getAmountClasses();
36+
37+
/**
38+
* List a collection of {@link CurrencyUnit} implementation.<br/>
39+
* This enables the TCK to check the basic implementation compliance,
40+
*
41+
* @return
42+
*/
43+
Collection<Class> getCurrencyClasses();
2644

27-
/**
28-
* Return a collection with all {@link MonetaryAmount} classes that are implemented. The list
29-
* must not be empty and should contain <b>every</b> amount class implemented.<br/>
30-
* This enables the TCK to check in addition to the basic implementation compliance, if
31-
* according {@link MonetaryAmountFactoryProviderSpi} are registered/available correctly.
32-
*
33-
* @return a collection with all implemented amount classes, not null.
34-
*/
35-
Collection<Class> getAmountClasses();
3645

37-
/**
38-
* List a collection of {@link CurrencyUnit} implementation.<br/>
39-
* This enables the TCK to check the basic implementation compliance,
40-
* @return
41-
*/
42-
Collection<Class> getCurrencyClasses();
46+
/**
47+
* This method allows to let instances of MonetaryOperator to be tested for requirements and recommendations.
48+
*
49+
* @return the list of operators to be checked, not null. It is allowed to return an empty list here, which will
50+
* disable TCK tests for MonetaryOperator instances.
51+
*/
52+
Collection<MonetaryOperator> getMonetaryOperators4Test();
4353

4454
}

src/test/java/org/javamoney/tck/TCKTestSetup.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
/*
2+
* Copyright (c) 2012, 2013, Werner Keil, Credit Suisse (Anatole Tresch). Licensed under the Apache
3+
* License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4+
* License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
5+
* Unless required by applicable law or agreed to in writing, software distributed under the License
6+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
7+
* or implied. See the License for the specific language governing permissions and limitations under
8+
* the License. Contributors: Anatole Tresch - initial version.
9+
*/
110
package org.javamoney.tck;
211

12+
import javax.money.MonetaryOperator;
313
import java.util.Arrays;
414
import java.util.Collection;
15+
import java.util.Collections;
516
import java.util.ServiceLoader;
617

718
public final class TCKTestSetup {
@@ -60,6 +71,11 @@ public Collection<Class> getCurrencyClasses() {
6071
}
6172
}
6273

63-
}
74+
@Override
75+
public Collection<MonetaryOperator> getMonetaryOperators4Test(){
76+
return Collections.emptyList();
77+
}
78+
79+
}
6480

6581
}

src/test/java/org/javamoney/tck/TCKValidationException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright (c) 2012, 2013, Werner Keil, Credit Suisse (Anatole Tresch). Licensed under the Apache
3+
* License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4+
* License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
5+
* Unless required by applicable law or agreed to in writing, software distributed under the License
6+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
7+
* or implied. See the License for the specific language governing permissions and limitations under
8+
* the License. Contributors: Anatole Tresch - initial version.
9+
*/
110
package org.javamoney.tck;
211

312
public final class TCKValidationException extends RuntimeException {
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
3+
* CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
4+
* PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
5+
* DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
6+
* AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
7+
* BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
8+
* API ("Specification") Copyright (c) 2012-2013, Credit Suisse All rights
9+
* reserved.
10+
*/
11+
12+
package org.javamoney.tck.tests;
13+
14+
import org.jboss.test.audit.annotations.SpecVersion;
15+
import org.junit.Assert;
16+
import org.junit.Test;
17+
18+
/**
19+
* Created by Anatole on 10.03.14.
20+
*/
21+
@SpecVersion(spec = "JSR 354", version = "1.0.0")
22+
public class AccessingCurrenciesAmountsRoundingsTest{
23+
24+
@Test
25+
public void placeholder(){
26+
Assert.fail();
27+
}
28+
29+
/*
30+
<group>
31+
<text>A. Accessing Currencies</text>
32+
<assertion id="427-A1">
33+
<text>Test if MonetaryCurrencies provides all ISO related entries,
34+
similar to the JDK.
35+
</text>
36+
</assertion>
37+
<assertion id="427-A2">
38+
<text>Test if MonetaryCurrencies provides all Locale related
39+
entries, similar to the JDK.
40+
</text>
41+
</assertion>
42+
<assertion id="427-A3">
43+
<text>Test if MonetaryCurrencies provides correct check for ISO
44+
codes.
45+
</text>
46+
</assertion>
47+
<assertion id="427-A4">
48+
<text>Test if MonetaryCurrencies provides correct check for
49+
Locales.
50+
</text>
51+
</assertion>
52+
<assertion id="427-A5">
53+
<text>Test for custom MonetaryCurrencies provided, based on the TCK
54+
TestProvider.
55+
</text>
56+
</assertion>
57+
</group>
58+
<group>
59+
<text>B. Accessing Monetary Amount Factories</text>
60+
<assertion id="427-B1">
61+
<text>Ensure the types available, must be at least one type (if one
62+
has a specified AmountFlavor, 2 are recommended).
63+
</text>
64+
</assertion>
65+
<assertion id="427-B2">
66+
<text>Ensure amount factories are accessible for all types
67+
available,
68+
providing also the
69+
some test implementations with the
70+
TCK.
71+
</text>
72+
</assertion>
73+
<assertion id="427-B3">
74+
<text>Ensure amount factories are accessible for all types
75+
available,
76+
providing also the
77+
some test implementations with the
78+
TCK,
79+
and that
80+
every factory accessed
81+
is a new instance.
82+
</text>
83+
</assertion>
84+
<assertion id="427-B4">
85+
<text>Ensure correct query function implementations, providing also
86+
the
87+
some test implementations with the TCK.
88+
</text>
89+
</assertion>
90+
<assertion id="427-B5">
91+
<text>Ensure a default factory is returned. Test javamoney.config
92+
for
93+
configuring default value.
94+
</text>
95+
</assertion>
96+
</group>
97+
<group>
98+
<text>C. Accessing Roundings</text>
99+
<assertion id="427-C1">
100+
<text>Access roundings using all defined currencies, including TCK
101+
custom currencies.
102+
</text>
103+
</assertion>
104+
<assertion id="427-C2">
105+
<text>Access roundings using a MonetaryContext. Use different
106+
MathContext/RoundingMode, as an attribute, when running
107+
on the JDK.
108+
</text>
109+
</assertion>
110+
<assertion id="427-C3">
111+
<text>Access custom roundings and ensure TCK custom roundings are
112+
registered.
113+
</text>
114+
</assertion>
115+
<assertion id="427-C4">
116+
<text>Test TCK custom roundings.
117+
</text>
118+
</assertion>
119+
</group>
120+
*/
121+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE
3+
* CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT.
4+
* PLEASE READ THE TERMS AND CONDITIONS OF THIS AGREEMENT CAREFULLY. BY
5+
* DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF THE
6+
* AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE"
7+
* BUTTON AT THE BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency
8+
* API ("Specification") Copyright (c) 2012-2013, Credit Suisse All rights
9+
* reserved.
10+
*/
11+
12+
package org.javamoney.tck.tests;
13+
14+
import org.jboss.test.audit.annotations.SpecVersion;
15+
import org.junit.Assert;
16+
import org.junit.Test;
17+
18+
/**
19+
* Created by Anatole on 10.03.14.
20+
*/
21+
@SpecVersion(spec = "JSR 354", version = "1.0.0")
22+
public class CreatingMonetaryAmountsTest{
23+
24+
@Test
25+
public void placeholder(){
26+
Assert.fail();
27+
}
28+
29+
/*
30+
<group>
31+
<text>A. Accessing MonetaryAmount Factories</text>
32+
<assertion id="426-A1">
33+
<text>Access a MonetaryAmountFactory for each registered type.
34+
</text>
35+
</assertion>
36+
<assertion id="426-A2">
37+
<text>Checks if getAmountType returns the correct type.</text>
38+
</assertion>
39+
<assertion id="426-A3">
40+
<text>Checks for default and max MonetaryContext.</text>
41+
</assertion>
42+
<assertion id="426-A4">
43+
<text>Checks if capabilities of default MonetaryContext are less
44+
than Max
45+
MonetaryContext.
46+
</text>
47+
</assertion>
48+
</group>
49+
<group>
50+
<text>B. Testing Creation of Amounts with zero values</text>
51+
<assertion id="426-B1">
52+
<text>For each MonetaryAmount Factory: Create zero amounts from a
53+
factory with currencies.
54+
</text>
55+
</assertion>
56+
<assertion id="426-B2">
57+
<text>For each MonetaryAmount Factory: Create zero amounts from a
58+
factory with monetary contexts.
59+
</text>
60+
</assertion>
61+
<assertion id="426-B3">
62+
<text>For each MonetaryAmount Factory: Bad Case: Create zero amounts
63+
from a factory with an invalid currency.
64+
</text>
65+
</assertion>
66+
<assertion id="426-B4">
67+
<text>For each MonetaryAmount Factory: Bad Case: Create zero amounts
68+
from a factory with an invalid MonetaryContext.
69+
</text>
70+
</assertion>
71+
</group>
72+
<group>
73+
<text>C. Testing Creation of Amounts with positive values</text>
74+
<assertion id="426-C1">
75+
<text>For each MonetaryAmount Factory: Create positive amounts from
76+
a factory with currencies.
77+
</text>
78+
</assertion>
79+
<assertion id="426-C2">
80+
<text>For each MonetaryAmount Factory: Create positive amounts from
81+
a factory with monetary contexts.
82+
</text>
83+
</assertion>
84+
<assertion id="426-C3">
85+
<text>For each MonetaryAmount Factory: Bad Case: Create positive
86+
amounts from a factory with an invalid numeric value (exceeding max
87+
MonetaryContext).
88+
</text>
89+
</assertion>
90+
<assertion id="426-C4">
91+
<text>For each MonetaryAmount Factory: Bad Case: Create positive
92+
amounts from a factory with an invalid currency.
93+
</text>
94+
</assertion>
95+
<assertion id="426-C5">
96+
<text>For each MonetaryAmount Factory: Bad Case: Create positive
97+
amounts from a factory with an invalid MonetaryContext.
98+
</text>
99+
</assertion>
100+
</group>
101+
<group>
102+
<text>D. Testing Creation of Amounts with negative values</text>
103+
<assertion id="426-D1">
104+
<text>For each MonetaryAmount Factory: Create negative amounts from
105+
a factory with currencies.
106+
</text>
107+
</assertion>
108+
<assertion id="426-D2">
109+
<text>For each MonetaryAmount Factory: Create negative amounts from
110+
a factory with monetary contexts.
111+
</text>
112+
</assertion>
113+
<assertion id="426-D3">
114+
<text>For each MonetaryAmount Factory: Bad Case: Create negative
115+
amounts from a factory with an invalid numeric value (exceeding max
116+
MonetaryContext).
117+
</text>
118+
</assertion>
119+
<assertion id="426-D4">
120+
<text>For each MonetaryAmount Factory: Bad Case: Create negative
121+
amounts from a factory with an invalid currency.
122+
</text>
123+
</assertion>
124+
<assertion id="426-D5">
125+
<text>For each MonetaryAmount Factory: Bad Case: Create negative
126+
amounts from a factory with an invalid MonetaryContext.
127+
</text>
128+
</assertion>
129+
</group>
130+
*/
131+
132+
}

0 commit comments

Comments
 (0)