View Javadoc

1   /*
2    * Created by smenor on Jan 8, 2005
3    *
4    * Copyright (C) 2005
5    * Arizona State University - Cancer Research Institute
6    * All rights Reserved.
7    */
8   package edu.asu.cri.MirkE.dataStructures;
9   
10  import java.util.Iterator;
11  
12  import edu.asu.cri.MirkE.exceptions.MirkEApplicationException;
13  
14  import edu.asu.cri.MirkE.exceptions.MirkESystemException;
15  
16  import junit.framework.TestCase;
17  
18  /***
19   * @author smenor
20   *
21   */
22  public class DataSetTest extends TestCase {
23      edu.asu.cri.MirkE.dataStructures.DataSet dataSet;
24      
25      /***
26       * @param args
27       */
28      public static void main(String[] args) {
29      }
30      
31      /*
32       * @see TestCase#setUp()
33       TestCase throws only exception hence the try catch
34       */
35      protected void setUp() throws  Exception {
36         
37          try{
38              super.setUp();
39              dataSet = new edu.asu.cri.MirkE.dataStructures.DataSet();
40          
41          
42          }  catch(MirkESystemException exception){
43  
44              throw new Exception("3 catch  MirkEApplicationException",exception);
45  
46          }  catch(Exception exception){
47  
48              throw new Exception("1 catch  MirkEApplicationException",exception);
49  
50          }
51  
52      }
53      
54      /*
55       * @see TestCase#tearDown()
56       */
57      protected void tearDown() throws Exception {
58          super.tearDown();
59      }
60      
61      /***
62       * Constructor for DataSetTest.
63       * @param arg0
64       */
65      public DataSetTest(String arg0) {
66          super(arg0);
67      }
68      
69      /***
70       * 
71       */
72      public void testSave() {
73          
74      }
75      
76      /***
77       * @throws Exception
78       *
79       */
80      public void testSaveUnit() throws Exception {
81          Unit kelvin = Unit.createUnit("kelvin");
82          
83          Unit meters = Unit.createUnit("meters");
84          
85          Unit inches = Unit.createUnit("inches", 39.3, 0, meters);
86          java.util.List list =null;
87  
88          try{
89              dataSet.save(kelvin);
90              dataSet.save(meters);
91              dataSet.save(inches);
92              list = dataSet.find("from Unit as u where u.unitName = 'meters'");
93          }catch(MirkEApplicationException e){
94              throw new Exception("2 catch  MirkEApplicationException",e);
95          }
96  
97          Iterator listIterator = list.iterator();
98          assertTrue(listIterator.hasNext());
99          
100         Unit retrievedMeters = (Unit)listIterator.next(); 
101         
102         assertEquals(
103                 retrievedMeters.convertTo(1, meters),
104                 1,
105                 0.0001);
106         
107         assertEquals(
108                 meters.convertTo(1, retrievedMeters),
109                 1,
110                 0.0001);
111         
112         assertEquals(
113                 retrievedMeters.convertTo(1, retrievedMeters),
114                 1,
115                 0.0001);
116         
117         assertEquals(
118                 retrievedMeters.convertTo(1, inches),
119                 39.3,
120                 0.0001);
121     }
122     
123     /***
124      *
125      */
126     public void testSaveUnitValue() {
127         
128     }
129     
130     /***
131      *
132      */
133     public void testSaveMeasuredValue() {
134          
135     }
136     
137     /***
138      * 
139      */
140     public void testDelete() {
141     }
142     
143     /***
144      * 
145      */
146     public void testFind() {
147     }
148     
149 }