Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hackergarten Zurich Pull 2 #3

Closed
wants to merge 5 commits into from

2 participants

This page is out of date. Refresh to see the latest.
View
9 pom.xml
@@ -345,11 +345,6 @@
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>6.8.5</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
@@ -391,10 +386,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </dependency>
- <dependency>
<groupId>${impl.groupId}</groupId>
<artifactId>${impl.artifactId}</artifactId>
<type>${impl.packageType}</type>
View
12 src/test/java/org/javamoney/tck/tests/CurrencyUnitTest.java
@@ -143,18 +143,6 @@ public void testIsImmutable() {
}
}
- @SpecAssertion(section = "4.2.1", id = "421-B5")
- @Test
- public void testIsThreadSafe() throws NoSuchMethodException,
- SecurityException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException {
- for (Currency cur : Currency.getAvailableCurrencies()) {
- CurrencyUnit unit = MonetaryCurrencies.getCurrency(cur
- .getCurrencyCode());
- fail("Not yet implemented: IsThreadSafe");
- }
- }
-
@SpecAssertion(section = "4.2.1", id = "421-B6")
@Test
public void testImplementsSerializable() {
View
55 src/test/java/org/javamoney/tck/tests/MonetaryAmountTest.java
@@ -8,6 +8,7 @@
import java.util.Currency;
import javax.money.MonetaryAmount;
+import javax.money.MonetaryAmountFactory;
import javax.money.MonetaryAmounts;
import javax.money.MonetaryOperator;
@@ -33,7 +34,7 @@ public void testEnsureMonetaryAmount() {
public void testCurrencyCode() {
for (Class type : MonetaryAmounts.getAmountTypes()) {
for (Currency jdkCur : Currency.getAvailableCurrencies()) {
- MonetaryAmount amount = MonetaryAmounts.getAmountFactory()
+ MonetaryAmount amount = MonetaryAmounts.getAmountFactory(type)
.setCurrency(jdkCur.getCurrencyCode()).setNumber(10.15)
.create();
assertNotNull(amount);
@@ -56,7 +57,7 @@ public void testWith() {
@Ignore
public void testQuery() {
for (Class type : MonetaryAmounts.getAmountTypes()) {
- MonetaryAmount amount = MonetaryAmounts.getAmountFactory()
+ MonetaryAmount amount = MonetaryAmounts.getAmountFactory(type)
.setCurrency("XXX").setNumber(0).create();
// amount.query();
fail("not implemented.");
@@ -68,11 +69,11 @@ public void testQuery() {
@Test
public void testImplementsEquals() {
for (Class type : MonetaryAmounts.getAmountTypes()) {
- MonetaryAmount amount = MonetaryAmounts.getAmountFactory()
+ MonetaryAmount amount = MonetaryAmounts.getAmountFactory(type)
.setCurrency("XXX").setNumber(0).create();
- ClassTester.testHasPublicStaticMethodOpt(type, type, "equals",
- MonetaryOperator.class);
- MonetaryAmount amount2 = MonetaryAmounts.getAmountFactory()
+ ClassTester.testHasPublicMethod(type, type, "equals",
+ Object.class);
+ MonetaryAmount amount2 = MonetaryAmounts.getAmountFactory(type)
.setCurrency("XXX").setNumber(0).create();
assertEquals(amount, amount2);
}
@@ -82,11 +83,10 @@ public void testImplementsEquals() {
@Test
public void testImplementsHashCode() {
for (Class type : MonetaryAmounts.getAmountTypes()) {
- MonetaryAmount amount = MonetaryAmounts.getAmountFactory()
+ MonetaryAmount amount = MonetaryAmounts.getAmountFactory(type)
.setCurrency("USD").setNumber(0).create();
- ClassTester.testHasPublicStaticMethodOpt(type, type, "hashCode",
- MonetaryOperator.class);
- MonetaryAmount amount2 = MonetaryAmounts.getAmountFactory()
+ ClassTester.testHasPublicMethod(type, type, "hashCode");
+ MonetaryAmount amount2 = MonetaryAmounts.getAmountFactory(type)
.setCurrency("USD").setNumber(0).create();
assertEquals(amount.hashCode(), amount2.hashCode());
}
@@ -97,26 +97,27 @@ public void testImplementsHashCode() {
public void testImplementComparable() {
for (Class type : MonetaryAmounts.getAmountTypes()) {
ClassTester.testComparable(type);
- MonetaryAmount amount = MonetaryAmounts.getAmountFactory()
+ MonetaryAmountFactory factory = MonetaryAmounts.getAmountFactory(type);
+ MonetaryAmount amount = factory
.setCurrency("XXX").setNumber(0).create();
- ClassTester.testHasPublicStaticMethodOpt(type, type, "hashCode",
- MonetaryOperator.class);
- MonetaryAmount amount2 = MonetaryAmounts.getAmountFactory()
+ MonetaryAmount amount2 = factory
.setCurrency("XXX").setNumber(0).create();
+ MonetaryAmount amount3 = factory
+ .setCurrency("CHF").setNumber(1).create();
+ MonetaryAmount amount4 = factory
+ .setCurrency("XXX").setNumber(1).create();
+
assertTrue("Comparable failed for: " + type.getName(),
- ((Comparable) amount).compareTo(amount2) == 0);
- MonetaryAmount amount3 = MonetaryAmounts.getAmountFactory()
- .setCurrency("CHF").setNumber(1).create();
- assertTrue("Comparable failed for: " + type.getName(),
- ((Comparable) amount).compareTo(amount3) > 0);
- assertTrue("Comparable failed for: " + type.getName(),
- ((Comparable) amount3).compareTo(amount) < 0);
- MonetaryAmount amount4 = MonetaryAmounts.getAmountFactory()
- .setCurrency("XXX").setNumber(1).create();
- assertTrue("Comparable failed for: " + type.getName(),
- ((Comparable) amount3).compareTo(amount4) < 0);
- assertTrue("Comparable failed for: " + type.getName(),
- ((Comparable) amount4).compareTo(amount3) > 0);
+ ((Comparable) amount).compareTo(amount3) > 0);
+
+ assertTrue("Comparable failed for: " + type.getName(),
+ ((Comparable) amount3).compareTo(amount) < 0);
+
+ assertTrue("Comparable failed for: " + type.getName(),
+ ((Comparable) amount).compareTo(amount4) < 0);
+
+ assertTrue("Comparable failed for: " + type.getName(),
+ ((Comparable) amount4).compareTo(amount) > 0);
}
}
View
7 test-audit.xml
@@ -78,8 +78,13 @@
<text>CurrencyUnit implementation must be immutable.
</text>
</assertion>
- <assertion id="421-B5">
+ <assertion id="421-B5" testable="false">
<text>CurrencyUnit implementation must be thread safe.
+
+ It is not clear how this can be tested provided that CurrencyUnit interface
+ only provides getters.
+ Should the test try to use reflection to find some state? And how to prove that
+ even if CurrencyUnit has mutable state it might be thread safe.
</text>
</assertion>
<assertion id="421-B6">
Something went wrong with that request. Please try again.