ORCentral
|
00001 package eu.coform.test; 00002 00003 import static org.junit.Assert.*; 00004 00005 import java.util.Date; 00006 00007 00008 import org.junit.Before; 00009 import org.junit.Test; 00010 00011 import eu.coform.DateTime; 00012 import eu.coform.Filestruct; 00013 import eu.coform.command.CreateNewUUIDCommand; 00014 import eu.coform.database.DBException; 00015 import eu.coform.database.command.InsertFileDBCommand; 00016 00017 public class InsertFileDBCommandTest { 00018 00019 InsertFileDBCommand com; 00020 @Before 00021 public void setUp() throws Exception { 00022 Filestruct file = new Filestruct(); 00023 DateTime time = new DateTime(); 00024 Date date = new Date(); 00025 time.setDatetime(date.getTime()/1000); 00026 file.setCreationDate(time); 00027 file.setFilename("myfile"); 00028 CreateNewUUIDCommand uuidcom = new CreateNewUUIDCommand(); 00029 file.setFilestructID(uuidcom.execute()); 00030 file.setMimetype(1); 00031 file.setDatasetID(null);//not needed 00032 file.setM_Md5sum(uuidcom.execute()); // fake sum 00033 file.setSize(1000); 00034 file.setStatus(1); 00035 com = new InsertFileDBCommand(file, 1); // FIXME write better test 00036 } 00037 00038 @Test 00039 public void testExec() { 00040 try { 00041 setUp(); 00042 } catch (Exception e) { 00043 assert(false); 00044 // TODO Auto-generated catch block 00045 e.printStackTrace(); 00046 } 00047 try { 00048 com.exec(); 00049 } catch (DBException e) { 00050 assert(false); 00051 // TODO Auto-generated catch block 00052 e.printStackTrace(); 00053 } 00054 } 00055 00056 }