author | japod@localhost |
Sun, 28 Sep 2008 14:12:38 +0200 | |
changeset 6 | 97662396c0fd |
child 16 | 2864c6d744c0 |
permissions | -rw-r--r-- |
japod@6 | 1 |
package org.apidesign.apifest08.test; |
japod@6 | 2 |
|
japod@6 | 3 |
import static junit.framework.Assert.assertEquals; |
japod@6 | 4 |
import static junit.framework.Assert.assertNotNull; |
japod@6 | 5 |
import static org.apidesign.apifest08.test.Task1Test.CZK; |
japod@6 | 6 |
import static org.apidesign.apifest08.test.Task1Test.USD; |
japod@6 | 7 |
|
japod@6 | 8 |
import java.util.Currency; |
japod@6 | 9 |
|
japod@6 | 10 |
import org.apidesign.apifest08.currency.ConvertorFactory; |
japod@6 | 11 |
import org.apidesign.apifest08.currency.UnsupportedConversionException; |
japod@6 | 12 |
import org.junit.Test; |
japod@6 | 13 |
|
japod@6 | 14 |
|
japod@6 | 15 |
public class ConvertorFactoryTest { |
japod@6 | 16 |
@Test(expected=NullPointerException.class) |
japod@6 | 17 |
public void testNullSource() |
japod@6 | 18 |
{ |
japod@6 | 19 |
ConvertorFactory.createConvertor(null, USD); |
japod@6 | 20 |
} |
japod@6 | 21 |
@Test(expected=NullPointerException.class) |
japod@6 | 22 |
public void testNullDestination() |
japod@6 | 23 |
{ |
japod@6 | 24 |
ConvertorFactory.createConvertor(CZK, null); |
japod@6 | 25 |
} |
japod@6 | 26 |
@Test(expected=IllegalArgumentException.class) |
japod@6 | 27 |
public void testShortSource() |
japod@6 | 28 |
{ |
japod@6 | 29 |
ConvertorFactory.createConvertor(Currency.getInstance("CZ"), USD); |
japod@6 | 30 |
} |
japod@6 | 31 |
@Test(expected=UnsupportedConversionException.class) |
japod@6 | 32 |
public void testUnknownCombination() |
japod@6 | 33 |
{ |
japod@6 | 34 |
ConvertorFactory.createConvertor(CZK, Currency.getInstance("ZAR")); |
japod@6 | 35 |
} |
japod@6 | 36 |
@Test |
japod@6 | 37 |
public void testOk() |
japod@6 | 38 |
{ |
japod@6 | 39 |
assertNotNull(ConvertorFactory.createConvertor(CZK, USD)); |
japod@6 | 40 |
} |
japod@6 | 41 |
@Test |
japod@6 | 42 |
public void testReverted() |
japod@6 | 43 |
{ |
japod@6 | 44 |
assertEquals(ConvertorFactory.createConvertor(CZK, USD).revert(), ConvertorFactory.createConvertor(USD, CZK)); |
japod@6 | 45 |
} |
japod@6 | 46 |
} |