Advertisement
Guest User

JUnit Tests

a guest
May 30th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. //Submitted by Dima Yankovoy 311868442 & Snir Yacoby 201561933
  2. package il.ac.hit.project.model;
  3.  
  4. import junit.framework.TestCase;
  5. import org.junit.After;
  6. import org.junit.Before;
  7. import org.junit.Test;
  8.  
  9. import java.text.DecimalFormat;
  10.  
  11. /**
  12.  * The JUnit tests for methods of class Currencies.
  13.  */
  14. public class CurrenciesTest extends TestCase {
  15.  
  16.     Currencies ob;
  17.  
  18.     @Before
  19.     public void setUp() throws Exception {
  20.         ob = new Currencies();
  21.         ob.importXML();
  22.         ob.readFromFile();
  23.     }
  24.  
  25.     @After
  26.     public void tearDown() throws Exception {
  27.  
  28.     }
  29.  
  30.     @Test
  31.     public void testGetLastUpdate() throws Exception {
  32.         assertNotNull(ob.getLastUpdate());
  33.     }
  34.  
  35.     @Test
  36.     public void testGetData() throws Exception {
  37.         assertNotNull(ob.getData());
  38.         assertTrue(ob.getData().length == 14);
  39.     }
  40.  
  41.     @Test
  42.     public void testConvert() throws Exception {
  43.         Double USD = Double.parseDouble(ob.getData()[0][3]);
  44.         Double GBP = Double.parseDouble(ob.getData()[1][3]);
  45.         Double result = Double.parseDouble(ob.convert("100",0,1));
  46.         assertEquals("100", new DecimalFormat("##.##").format(result * GBP / USD) );
  47.     }
  48.  
  49.     @Test
  50.     public void testGetStatus() throws Exception {
  51.         assertNotNull(ob.getStatus());
  52.     }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement