taskx/jtulach/against-solution02/test/apifest/CurrencyTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 11 Oct 2008 13:25:34 +0200
changeset 73 e8b0f13fd4fb
child 81 ec70f883de4a
permissions -rw-r--r--
Solution 02 is not backward compatible as it changed return type of one method in ConvertorFactory class
     1 package apifest;
     2 
     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.Money;
     9 
    10 
    11 /** Write a test that works with version from task A and fails with version B.
    12  */
    13 public class CurrencyTest extends TestCase {
    14     public CurrencyTest(String n) {
    15         super(n);
    16     }
    17     
    18     public void testCompatibility() throws Exception {
    19         Money m = new Money() {
    20             public BigDecimal getAmount() {
    21                 return new BigDecimal(1);
    22             }
    23 
    24             public Currency getCurrency() {
    25                 return Currency.getInstance("CZK");
    26             }
    27         };
    28         Convertor c = ConvertorFactory.createConvertor(m, m);
    29     }
    30 }