3 import junit.framework.TestCase;
4 import org.apidesign.apifest08.currency.Convertor;
5 import org.apidesign.apifest08.currency.ConvertorFactory;
6 import org.apidesign.apifest08.currency.CurrencyRate;
7 import org.apidesign.apifest08.currency.Rate;
10 /** Write a test that works with version from task A and fails with version B.
12 public class CurrencyTest extends TestCase {
13 public CurrencyTest(String n) {
17 public void testCompatibility() throws Exception {
19 Convertor c = ConvertorFactory.newInstance().createConvertor(
20 new MyOwnCurrencyRate("CZK", "USD", new Rate(1, 16), "ABCDEF"));
22 MyOwnCurrencyRate[] arr = c.getCurrencyRates().toArray(new MyOwnCurrencyRate[1]);
23 assertEquals("ABCDEF", arr[0].getMyImportantProperty());
26 class MyOwnCurrencyRate implements CurrencyRate {
28 private final String currency1;
29 private final String currency2;
30 private final Rate rate;
31 private final String myImportantProperty;
33 public MyOwnCurrencyRate(String currency1, String currency2, Rate rate, String myImportantProperty) {
34 this.currency1 = currency1;
35 this.currency2 = currency2;
37 this.myImportantProperty = myImportantProperty;
40 public String getCurrency1() {
44 public String getCurrency2() {
48 public Rate getRate() {
52 public String getMyImportantProperty() {
53 return myImportantProperty;