author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 25 Oct 2008 20:53:00 +0200 | |
changeset 84 | 2ae6e4aa7aef |
permissions | -rw-r--r-- |
jtulach@84 | 1 |
package apifest; |
jtulach@84 | 2 |
|
jtulach@84 | 3 |
import java.math.BigDecimal; |
jtulach@84 | 4 |
import java.util.Currency; |
jtulach@84 | 5 |
import junit.framework.TestCase; |
jtulach@84 | 6 |
import org.apidesign.apifest08.currency.Amount; |
jtulach@84 | 7 |
import org.apidesign.apifest08.currency.Convertor; |
jtulach@84 | 8 |
import org.apidesign.apifest08.currency.UnsupportedConversionException; |
jtulach@84 | 9 |
//import static org.apidesign.apifest08.test.Currencies.CZK; |
jtulach@84 | 10 |
//import static org.apidesign.apifest08.test.Currencies.SKK; |
jtulach@84 | 11 |
//import static org.apidesign.apifest08.test.Currencies.USD; |
jtulach@84 | 12 |
|
jtulach@84 | 13 |
/** Write a test that works with version from task A and fails with version B. |
jtulach@84 | 14 |
*/ |
jtulach@84 | 15 |
public class CurrencyTest extends TestCase { |
jtulach@84 | 16 |
public CurrencyTest(String n) { |
jtulach@84 | 17 |
super(n); |
jtulach@84 | 18 |
} |
jtulach@84 | 19 |
|
jtulach@84 | 20 |
public void testCompatibility() throws Exception { |
jtulach@84 | 21 |
Currency CZK = Currency.getInstance("CZK"); |
jtulach@84 | 22 |
Currency USD = Currency.getInstance("USD"); |
jtulach@84 | 23 |
Currency SKK = Currency.getInstance("SKK"); |
jtulach@84 | 24 |
|
jtulach@84 | 25 |
|
jtulach@84 | 26 |
Convertor c = new Convertor(new BigDecimal(17), USD, CZK); |
jtulach@84 | 27 |
try { |
jtulach@84 | 28 |
Amount a = c.convert(new BigDecimal("10"), USD, SKK); |
jtulach@84 | 29 |
//fail(); |
jtulach@84 | 30 |
} catch (UnsupportedConversionException e) { |
jtulach@84 | 31 |
assertEquals("Conversion from the currency USD to the currency SKK or vice versa in not supported.", e.getMessage()); |
jtulach@84 | 32 |
} |
jtulach@84 | 33 |
} |
jtulach@84 | 34 |
} |