package tests;
import java.sql.ResultSet;
import java.sql.Statement;
import junit.framework.TestCase;
import src.Context;
import src.FilaInscricaoMigration;
import src.Migrator;
/**
* TODO Montar um cenario de testes
*/
public class FilaInscricaoMigrationTest extends TestCase {
public void testGetResultSet() throws Exception {
Migrator migration = new FilaInscricaoMigration(Context
.getSourceConnection(), Context.getDestinationConnection(),
new Long(41), new Long(15));
ResultSet rs = migration.getResultSet();
rs.next();
assertEquals(6, rs.getMetaData().getColumnCount());
}
public void testExecute() throws Exception {
Migrator migration = new FilaInscricaoMigration(Context
.getSourceConnection(), Context.getDestinationConnection(),
new Long(41), new Long(15));
ResultSet rs = migration.getResultSet();
rs.next();
migration.execute(rs);
Statement stm = (Statement) Context.getDestinationConnection()
.createStatement();
ResultSet rs2 = (ResultSet) stm
.executeQuery("SELECT id FROM FILAINSCRICAO WHERE id = "
+ rs.getLong(1));
rs2.next();
assertEquals(rs2.getLong(1), rs.getLong(1));
stm.executeUpdate("DELETE FROM FILAINSCRICAO WHERE id = " + rs2.getLong(1));
}
}