@Test
public void testPojoTypeWithInvalidFieldMapping() throws Exception {

	File tempFile = File.createTempFile("CsvReaderPojoType", "tmp");
	tempFile.deleteOnExit();
	tempFile.setWritable(true);
	@SuppressWarnings("unchecked")
	PojoTypeInfo<PojoItem> typeInfo = (PojoTypeInfo<PojoItem>) TypeExtractor.createTypeInfo(PojoItem.class);
	try {
		new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new String[]{"field1", "field2"});
		fail("The number of POJO fields cannot be same as that of selected CSV fields");
	} catch (IllegalArgumentException e) {
		// success
	}
	try {
		new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new String[]{"field1", "field2", null, "field4"});
		fail("Fields mapping cannot contain null.");
	} catch (NullPointerException e) {
		// success
	}
	try {
		new PojoCsvInputFormat<PojoItem>(new Path(tempFile.toURI().toString()), typeInfo, new String[]{"field1", "field2", "field3", "field5"});
		fail("Invalid field name");
	} catch (IllegalArgumentException e) {
		// success
	}
}