3 import java.math.BigDecimal;
4 import java.util.Currency;
5 import junit.framework.TestCase;
6 import org.apidesign.apifest08.currency.Convertor;
7 import org.apidesign.apifest08.currency.ConvertorFactory;
8 import org.apidesign.apifest08.currency.InvalidConversionException;
11 /** Write a test that works with version from task A and fails with version B.
13 public class CurrencyTest extends TestCase {
14 public CurrencyTest(String n) {
18 public void testCompatibility() throws Exception {
20 // incompatibility2(); //another test proving incompatibility in versions
21 // incompatibility3(); //another test proving incompatibility in versions
24 private void incompatibility1() throws Exception {
25 Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1));
26 assertTrue("", c.toString().startsWith("org.apidesign.apifest08.currency.ConvertorImpl"));
29 private void incompatibility2() throws Exception {
30 Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1));
31 assertEquals("Testing hashcode", 961187025, c.hashCode());
34 private void incompatibility3() throws Exception {
35 Convertor co = new Convertor() {
36 public BigDecimal convert(Currency from, Currency to, BigDecimal amount) throws InvalidConversionException {