diff -r 000000000000 -r 2ae6e4aa7aef taskx/psmid/against-solution04/test/apifest/CurrencyTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskx/psmid/against-solution04/test/apifest/CurrencyTest.java Sat Oct 25 20:53:00 2008 +0200 @@ -0,0 +1,42 @@ +package apifest; + +import java.math.BigDecimal; +import java.util.Currency; +import junit.framework.TestCase; +import org.apidesign.apifest08.currency.Convertor; +import org.apidesign.apifest08.currency.ConvertorFactory; +import org.apidesign.apifest08.currency.InvalidConversionException; + + +/** Write a test that works with version from task A and fails with version B. + */ +public class CurrencyTest extends TestCase { + public CurrencyTest(String n) { + super(n); + } + + public void testCompatibility() throws Exception { + incompatibility1(); + // incompatibility2(); //another test proving incompatibility in versions + // incompatibility3(); //another test proving incompatibility in versions + } + + private void incompatibility1() throws Exception { + Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1)); + assertTrue("", c.toString().startsWith("org.apidesign.apifest08.currency.ConvertorImpl")); + } + + private void incompatibility2() throws Exception { + Convertor c = ConvertorFactory.getConvertor("CZK", BigDecimal.valueOf(17.0), "USD", BigDecimal.valueOf(1)); + assertEquals("Testing hashcode", 961187025, c.hashCode()); + } + + private void incompatibility3() throws Exception { + Convertor co = new Convertor() { + public BigDecimal convert(Currency from, Currency to, BigDecimal amount) throws InvalidConversionException { + return null; + } + }; + } + +}