jtulach@84: package apifest; jtulach@84: jtulach@84: import java.math.BigDecimal; jtulach@84: import java.util.Currency; jtulach@84: import junit.framework.TestCase; jtulach@84: import org.apidesign.apifest08.currency.Convertor; jtulach@84: import org.apidesign.apifest08.currency.ConvertorFactory; jtulach@84: import org.apidesign.apifest08.currency.InvalidConversionException; jtulach@84: jtulach@84: jtulach@84: /** Write a test that works with version from task A and fails with version B. jtulach@84: */ jtulach@84: public class CurrencyTest extends TestCase { jtulach@84: public CurrencyTest(String n) { jtulach@84: super(n); jtulach@84: } jtulach@84: jtulach@84: public void testCompatibility() throws Exception { jtulach@84: incompatibility1(); jtulach@84: // incompatibility2(); //another test proving incompatibility in versions jtulach@84: // incompatibility3(); //another test proving incompatibility in versions jtulach@84: } jtulach@84: jtulach@84: private void incompatibility1() throws Exception { jtulach@84: Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1)); jtulach@84: assertTrue("", c.toString().startsWith("org.apidesign.apifest08.currency.ConvertorImpl")); jtulach@84: } jtulach@84: jtulach@84: private void incompatibility2() throws Exception { jtulach@84: Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1)); jtulach@84: assertEquals("Testing hashcode", 961187025, c.hashCode()); jtulach@84: } jtulach@84: jtulach@84: private void incompatibility3() throws Exception { jtulach@84: Convertor co = new Convertor() { jtulach@84: public BigDecimal convert(Currency from, Currency to, BigDecimal amount) throws InvalidConversionException { jtulach@84: return null; jtulach@84: } jtulach@84: }; jtulach@84: } jtulach@84: jtulach@84: }