Update of /cvsroot/tail/Tail/src/test/net/sf/tail/reader
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31504/src/test/net/sf/tail/reader
Modified Files:
CedroTimeSeriesLoaderTest.java
Log Message:
refatoração dos testes
Index: CedroTimeSeriesLoaderTest.java
===================================================================
RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/reader/CedroTimeSeriesLoaderTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** CedroTimeSeriesLoaderTest.java 17 May 2007 16:59:55 -0000 1.7
--- CedroTimeSeriesLoaderTest.java 17 May 2007 20:16:11 -0000 1.8
***************
*** 2,11 ****
--- 2,16 ----
import static org.junit.Assert.assertEquals;
+
import java.io.FileInputStream;
import java.sql.Timestamp;
+ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+
import junit.framework.JUnit4TestAdapter;
+ import net.sf.tail.Tick;
import net.sf.tail.TimeSeries;
+
import org.junit.Before;
import org.junit.Test;
***************
*** 21,96 ****
}
@Test
public void testLine3() throws Exception {
!
! // TODO: Duplicado em todos os testes (dtsato)
! SimpleDateFormat simpleDate = new SimpleDateFormat("dd/M/yyyy");
! Date date = null;
! date = simpleDate.parse("2/5/2007");
! Timestamp timestamp = new Timestamp(date.getTime());
! double[] values = {71.70,72.06,72.75,71.70,0.99,72.81,108200.00,7854215.00,152.00};
!
! verifyTick(values, timestamp, 2);
!
!
!
}
@Test
public void testeLine2() throws Exception {
!
! Date date = null;
! SimpleDateFormat simpleDate = new SimpleDateFormat("dd/M/yyyy");
!
! date = simpleDate.parse("30/4/2007");
!
! Timestamp timestamp = new Timestamp(date.getTime());
!
! double[] valores = {73.09,72.81,73.10,72.20,1.00,73.09,83200.00,6045660.00,103.00};
!
! verifyTick(valores, timestamp, 1);
!
}
@Test
public void testLine1() throws Exception {
!
! Date date = null;
! SimpleDateFormat simpleDate = new SimpleDateFormat("dd/M/yyyy");
!
!
! date = simpleDate.parse("27/4/2007");
- Timestamp timestamp = new Timestamp(date.getTime());
-
- double[] valores = {71.00,73.09,73.29,68.76,1.02,71.40,59100.00,4180018.00,141.00};
-
- verifyTick(valores, timestamp, 0);
-
}
!
! /*
! * TODO: Isso me parece estranho. Primeiro que tem muita coisa duplicada.
! * E segundo que ele precisa ficar fazendo assertEquals com cada coisa do Tick.
! * Me pareceria mais intuitivo um assertEquals entre ticks. Se o equals daqui
! * não fizer sentido como equals() da aplicação, temos que pensar num jeito
! * de usar uma versão do tick para testes. Talvez criar um TickComparator na
! * estrutura de testes que verifica cada campo. Isso pode ser reaproveitado
! * em vários outros testes. (dtsato)
! *
! */
! private void verifyTick(double[] values, Timestamp timestamp, int index) {
! assertEquals(timestamp, ts.getTick(index).getData());
!
! assertEquals(values[0], ts.getTick(index).getOpenPrice());
! assertEquals(values[1], ts.getTick(index).getClosePrice());
! assertEquals(values[2], ts.getTick(index).getMaxPrice());
! assertEquals(values[3], ts.getTick(index).getMinPrice());
! assertEquals(values[4], ts.getTick(index).getChange());
! assertEquals(values[5], ts.getTick(index).getPreviousPrice());
! assertEquals(values[6], ts.getTick(index).getVolumeAmount());
! assertEquals(values[7], ts.getTick(index).getVolumeFinancier());
! assertEquals((int)values[8], ts.getTick(index).getTrades());
! }
!
//Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux)
//e o JUnit4
--- 26,64 ----
}
+ private Timestamp getTimeStamp(int year,int month,int day){
+ Date date = null;
+ SimpleDateFormat simpleDate = new SimpleDateFormat("dd/M/yyyy");
+ try {
+ date = simpleDate.parse(day+"/"+month+"/"+year);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return new Timestamp(date.getTime());
+ }
+
@Test
public void testLine3() throws Exception {
!
! Timestamp timestamp = getTimeStamp(2007,5,2);
! Tick tick = new Tick(timestamp,71.70,72.06,72.75,71.70,0.99,72.81,108200.00,7854215.00,152);
! assertEquals(tick, ts.getTick(2));
}
@Test
public void testeLine2() throws Exception {
!
! Timestamp timestamp = getTimeStamp(2007, 4, 30);
! Tick tick = new Tick(timestamp,73.09,72.81,73.10,72.20,1.00,73.09,83200.00,6045660.00,103);
! assertEquals(tick, ts.getTick(1));
}
@Test
public void testLine1() throws Exception {
!
! Timestamp timestamp = getTimeStamp(2007, 4, 27);
! Tick tick = new Tick(timestamp,71.00,73.09,73.29,68.76,1.02,71.40,59100.00,4180018.00,141);
! assertEquals(tick, ts.getTick(0));
}
!
//Método adicionado por causa da compatibilidade do Eclipse 3.1.2(Rede Linux)
//e o JUnit4
|