@Test
public void testFieldConverting() throws IOException {

	String fields = "TIMED, air_temp , TIMED , AiR_TeMp2";
	String formats = "Timestamp(d.M.y ) , Numeric , timestamp(k:m) , numeric    ";
	String badFormat = "Timestamp(d.M.y k:m) , numeric , numeric, numeric,numeric,dollluble ";
	String badFormat2 ="Timestamp(d.Mjo0o.y k:m) , numeric, numeric, numeric";
	
	CSVHandler wrapper = new CSVHandler();
	assertEquals(false,wrapper.initialize("test.csv.csv", fields,badFormat,',','\"',0,"NaN,-1234,4321"));
	assertEquals(false,wrapper.initialize("test.csv.csv", fields,badFormat,',','\"',0,"NaN,-1234,4321"));
	assertEquals(false,wrapper.initialize("test.csv.csv", fields,badFormat2,',','\"',0,"NaN,-1234,4321"));
	
	assertEquals(true,wrapper.initialize("test.csv.csv", fields,formats,',','\"',0,"NaN,-1234,4321"));
	
	FileUtils.writeStringToFile(new File(wrapper.getCheckPointFile()),  "","UTF-8");
	String[] formatsParsed = wrapper.getFormats();
	String[] fieldsParsed =  wrapper.getFields();
	assertEquals(true,compare(fieldsParsed, new String[] {"timed","air_temp","timed","air_temp2"}));
	assertEquals(true,compare(formatsParsed, new String[] {"Timestamp(d.M.y )","Numeric","timestamp(k:m)","numeric"}));
	
	TreeMap<String, Serializable> se = wrapper.convertTo(wrapper.getFormats(),wrapper.getFields(),wrapper.getNulls(),new String[] {} , wrapper.getSeparator());
	assertEquals(wrapper.getFields().length-1, se.keySet().size());//timestamp is douplicated.
	assertEquals(null, se.get("timed"));
	se = wrapper.convertTo(wrapper.getFormats(),wrapper.getFields(),wrapper.getNulls(),new String[] {"","","","-1234","4321","NaN"} , wrapper.getSeparator());
	assertEquals(null, se.get("timed"));
	
	se = wrapper.convertTo(wrapper.getFormats(),wrapper.getFields(),wrapper.getNulls(),new String[] {"","","","-1234","4321","NaN"} , wrapper.getSeparator());
	assertEquals(null, se.get("timed"));
	
	se = wrapper.convertTo(wrapper.getFormats(),wrapper.getFields(),wrapper.getNulls(),new String[] {"01.01.2009","1234","","-4321","ignore-me","NaN"} , wrapper.getSeparator());
	long parsedTimestamp = (Long)se.get("timed");
	assertEquals(true,parsedTimestamp>0);
	assertEquals(1234.0, se.get("air_temp"));
	assertEquals(-4321.0, se.get("air_temp2"));
	
	se = wrapper.convertTo(wrapper.getFormats(),wrapper.getFields(),wrapper.getNulls(),new String[] {"01.01.2009","-1234","10:10","-4321","ignore-me","NaN"} , wrapper.getSeparator());
	assertEquals(true,((Long)se.get("timed"))>parsedTimestamp);
	assertNull(se.get("air_temp"));

}