ORCentral
|
00001 package eu.coform.test; 00002 00003 import static org.junit.Assert.*; 00004 00005 import java.util.Date; 00006 00007 import org.junit.Before; 00008 import org.junit.Test; 00009 00010 import eu.coform.Dataset; 00011 import eu.coform.DateTime; 00012 import eu.coform.Filestruct; 00013 import eu.coform.Location; 00014 import eu.coform.ORException; 00015 import eu.coform.Session; 00016 import eu.coform.command.CreateNewUUIDCommand; 00017 import eu.coform.command.datasetingestion.IngestDatasetCommand; 00018 import eu.coform.command.location.QueryAllLocationCommand; 00019 import eu.coform.command.loginsession.LoginCommand; 00020 00021 public class IngestDatasetCommandTest { 00022 private LoginCommand loginCom = null; 00023 private QueryAllLocationCommand allLoc = null; 00024 private Dataset set = new Dataset(); 00025 private CreateNewUUIDCommand uuidcom = new CreateNewUUIDCommand(); 00026 private Session session; 00027 00028 @Before 00029 public void setUp() throws Exception { 00030 set.setDatasetID(null); 00031 DateTime time = new DateTime(); 00032 Date date = new Date(); 00033 time.setDatetime(date.getTime()/1000); 00034 Filestruct bin = new Filestruct(); 00035 bin.setCreationDate(time); 00036 bin.setFilename("binfile"); 00037 bin.setDatasetID(null); 00038 bin.setMimetype(1); 00039 bin.setFilestructID(null); 00040 bin.setM_Md5sum(uuidcom.execute()); // fake sum 00041 bin.setSize(1000); 00042 bin.setStatus(1); 00043 set.setFileBinary(bin); 00044 00045 Filestruct meta = new Filestruct(); 00046 meta.setCreationDate(time); 00047 meta.setFilename("metafile"); 00048 meta.setDatasetID(null); 00049 meta.setMimetype(1); 00050 meta.setFilestructID(null); 00051 meta.setM_Md5sum(uuidcom.execute()); // fake sum 00052 meta.setSize(1000); 00053 meta.setStatus(1); 00054 set.setFileMetadata(meta); 00055 00056 Filestruct area = new Filestruct(); 00057 area.setCreationDate(time); 00058 area.setFilename("areafile"); 00059 area.setDatasetID(null); 00060 area.setMimetype(1); 00061 area.setFilestructID(null); 00062 area.setM_Md5sum(uuidcom.execute()); // fake sum 00063 area.setSize(1000); 00064 area.setStatus(1); 00065 set.setFileAreatable(area); 00066 00067 Filestruct thumb = new Filestruct(); 00068 thumb.setCreationDate(time); 00069 thumb.setFilename("areafile"); 00070 thumb.setDatasetID(null); 00071 thumb.setMimetype(1); 00072 thumb.setFilestructID(null); 00073 thumb.setM_Md5sum(uuidcom.execute()); // fake sum 00074 thumb.setSize(1000); 00075 thumb.setStatus(1); 00076 set.setFileThumbnail(thumb); 00077 00078 allLoc = new QueryAllLocationCommand(); 00079 Location[] locs = allLoc.execute(); 00080 loginCom = new LoginCommand(); 00081 loginCom.setLocation(locs[0]); 00082 loginCom.setMinutesTimout(100); 00083 loginCom.setPassword("werner"); 00084 loginCom.setUsername("werner"); 00085 session = loginCom.execute(); 00086 } 00087 00088 @Test 00089 public void testExecute() { 00090 00091 IngestDatasetCommand com = new IngestDatasetCommand(session, set, "<rdf>rdf</rdf>"); 00092 try { 00093 com.execute(); 00094 } catch (ORException e) { 00095 // TODO Auto-generated catch block 00096 e.printStackTrace(); 00097 assert(false); //TODO write better test ... but this sufficient as first version 00098 00099 } 00100 } 00101 00102 }