AbstractFileLineIterator implements
                                              FileLineIterator<T> { protected String getFileName() { return fileName; } AbstractFileLineIterator(String fileName, Class<T> clazz,
            Map<String, ColumnParser> columnParserMap); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override void closeFile(); @Override List<String> getHeader(); @Override List<String> getTrailer(); @Override void skip(int skipLines); int getCurrentLineCount();  }
@SuppressWarnings("rawtypes") @Test public void testAbstractFileLineIteratorStringClassMap02() throws Exception { String fileName = null; Class<AbstractFileLineIterator_Stub01> clazz = AbstractFileLineIterator_Stub01.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("fileName is required.", e.getMessage()); assertSame(IllegalArgumentException.class, e.getCause().getClass()); assertNull(e.getFileName()); } }
@Test public void testAbstractFileLineIteratorStringClassMap03() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞03"; Class<AbstractFileLineIterator_Stub02> clazz = AbstractFileLineIterator_Stub02.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub02>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("FileFormat annotation is not found.", e.getMessage()); assertSame(IllegalStateException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@Test public void testAbstractFileLineIteratorStringClassMap05() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞05"; Class<AbstractFileLineIterator_Stub04> clazz = AbstractFileLineIterator_Stub04.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub04>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("Delimiter is the same as EncloseChar and is no use.", e.getMessage()); assertSame(IllegalStateException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@SuppressWarnings("rawtypes") @Test public void testAbstractFileLineIteratorStringClassMap06() throws Exception { String fileName = ""; Class<AbstractFileLineIterator_Stub01> clazz = AbstractFileLineIterator_Stub01.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("fileName is required.", e.getMessage()); assertSame(IllegalArgumentException.class, e.getCause().getClass()); assertEquals("", e.getFileName()); } }
@SuppressWarnings("rawtypes") @Test public void testAbstractFileLineIteratorStringClassMap07() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞07"; Class<AbstractFileLineIterator_Stub01> clazz = null; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("clazz is required.", e.getMessage()); assertSame(IllegalArgumentException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@SuppressWarnings("rawtypes") @Test public void testAbstractFileLineIteratorStringClassMap08() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞08"; Class<AbstractFileLineIterator_Stub01> clazz = AbstractFileLineIterator_Stub01.class; Map<String, ColumnParser> columnParserMap = null; try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("columnFormaterMap is required.", e.getMessage()); assertSame(IllegalArgumentException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@Test public void testAbstractFileLineIteratorStringClassMap09() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞11"; Class<AbstractFileLineIterator_Stub05> clazz = AbstractFileLineIterator_Stub05.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub05>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("Failed in instantiation of clazz.", e.getMessage()); assertSame(InstantiationException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@Test public void testAbstractFileLineIteratorStringClassMap10() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞12"; Class<AbstractFileLineIterator_Stub06> clazz = AbstractFileLineIterator_Stub06.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("int", new IntColumnParser()); columnParserMap.put("java.lang.String", new NullColumnParser()); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub06>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("clazz's nullary constructor is not accessible", e .getMessage()); assertSame(IllegalAccessException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@SuppressWarnings("rawtypes") @Test public void testAbstractFileLineIteratorStringClassMap11() throws Exception { String fileName = "AbstractFileLineIterator_＜init＞13"; Class<AbstractFileLineIterator_Stub01> clazz = AbstractFileLineIterator_Stub01.class; Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); try { new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, clazz, columnParserMap); fail("FileExceptionがスローされませんでした。"); } catch (FileException e) { assertSame(FileException.class, e.getClass()); assertEquals("columnFormaterMap is required.", e.getMessage()); assertSame(IllegalArgumentException.class, e.getCause().getClass()); assertSame(fileName, e.getFileName()); } }
@Test public void testBuildLineReader05() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_buildLineReader01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20> fileLineIterator = new AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20>( fileName, AbstractFileLineIterator_Stub20.class, columnParserMap); String fileName_test = "AbstractFileLineIterator_buildLineReader_noExist.txt"; ReflectionTestUtils.setField(fileLineIterator, "fileName", fileName_test); ReflectionTestUtils.setField(fileLineIterator, "lineReader", null); ReflectionTestUtils.setField(fileLineIterator, "reader", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildLineReader"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { assertNull(ReflectionTestUtils.getField(fileLineIterator, "reader")); assertNull(ReflectionTestUtils.getField(fileLineIterator, "lineReader")); assertSame(FileException.class, e.getTargetException().getClass()); assertEquals("Failed in generation of reader.", e.getTargetException().getMessage()); assertSame(FileNotFoundException.class, e.getTargetException().getCause().getClass()); assertSame(fileName_test, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildLineReader06() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_buildLineReader01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20> fileLineIterator = new AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20>( fileName, AbstractFileLineIterator_Stub20.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fileEncoding", "aaa"); ReflectionTestUtils.setField(fileLineIterator, "lineReader", null); ReflectionTestUtils.setField(fileLineIterator, "reader", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildLineReader"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { assertNull(ReflectionTestUtils.getField(fileLineIterator, "reader")); assertNull(ReflectionTestUtils.getField(fileLineIterator, "lineReader")); assertSame(FileException.class, e.getTargetException().getClass()); assertEquals("Failed in generation of reader.", e.getTargetException().getMessage()); assertSame(UnsupportedEncodingException.class, e.getTargetException().getCause() .getClass()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildLineReader07() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_buildLineReader01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl04<AbstractFileLineIterator_Stub20> fileLineIterator = new AbstractFileLineIteratorImpl04<AbstractFileLineIterator_Stub20>( fileName, AbstractFileLineIterator_Stub20.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "lineFeedChar", "\r\r\r"); ReflectionTestUtils.setField(fileLineIterator, "lineReader", null); ReflectionTestUtils.setField(fileLineIterator, "reader", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildLineReader"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { Object reader = ReflectionTestUtils.getField(fileLineIterator, "reader"); assertEquals(BufferedReader.class, reader.getClass()); Object reader02 = ReflectionTestUtils.getField(fileLineIterator, "lineReader"); assertNull(reader02); assertSame(FileException.class, e.getTargetException().getClass()); assertEquals("lineFeedChar length must be 0 or 1 or 2. but: 3", e.getTargetException() .getMessage()); assertSame(IllegalStateException.class, e.getTargetException().getCause().getClass()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildLineReader08() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_buildLineReader01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20> fileLineIterator = new AbstractFileLineIteratorImpl03<AbstractFileLineIterator_Stub20>( fileName, AbstractFileLineIterator_Stub20.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "lineFeedChar", "\r\r\r"); ReflectionTestUtils.setField(fileLineIterator, "lineReader", null); ReflectionTestUtils.setField(fileLineIterator, "reader", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildLineReader"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { Object reader = ReflectionTestUtils.getField(fileLineIterator, "reader"); assertEquals(BufferedReader.class, reader.getClass()); Object reader02 = ReflectionTestUtils.getField(fileLineIterator, "lineReader"); assertNull(reader02); assertSame(FileException.class, e.getTargetException().getClass()); assertEquals("lineFeedChar length must be 0 or 1 or 2. but: 3", e.getTargetException() .getMessage()); assertSame(IllegalStateException.class, e.getTargetException().getCause().getClass()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildFields05() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub33> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub33>( fileName, AbstractFileLineIterator_Stub33.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fields", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした"); } catch (InvocationTargetException e) { Object result_fields = (Field[]) ReflectionTestUtils.getField( fileLineIterator, "fields"); assertNull(result_fields); assertEquals(FileException.class, e.getTargetException().getClass()); assertEquals("Column Index is duplicate : 1", e.getTargetException().getMessage()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildFields06() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub34> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub34>( fileName, AbstractFileLineIterator_Stub34.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fields", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした"); } catch (InvocationTargetException e) { assertEquals(FileException.class, e.getTargetException().getClass()); assertEquals( "columnIndex in FileLineObject is not sequential order.", e.getTargetException() .getMessage()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); assertSame(IllegalStateException.class, e.getTargetException().getCause().getClass()); } }
@Test public void testBuildFields09() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub38> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub38>( fileName, AbstractFileLineIterator_Stub38.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fields", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionが発生していません。"); } catch (InvocationTargetException e) { assertTrue(IllegalStateException.class.isAssignableFrom(e.getTargetException() .getCause().getClass())); assertEquals("Column Index in FileLineObject is bigger than the " + "total number of the field.", e.getTargetException().getMessage()); assertEquals(fileName, ((FileException)e.getTargetException()).getFileName()); Object result_fields = ReflectionTestUtils.getField(fileLineIterator, "fields"); assertNull(result_fields); } }
@Test public void testBuildFields10() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub39> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub39>( fileName, AbstractFileLineIterator_Stub39.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fields", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionが発生していません。"); } catch (InvocationTargetException e) { assertTrue(IllegalStateException.class.isAssignableFrom(e.getTargetException() .getCause().getClass())); assertEquals("Column Index in FileLineObject is the minus number.", e.getTargetException().getMessage()); assertEquals(fileName, ((FileException)e.getTargetException()).getFileName()); Object result_fields = ReflectionTestUtils.getField(fileLineIterator, "fields"); assertNull(result_fields); } }
@Test public void testBuildFields11() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub90> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub90>( fileName, AbstractFileLineIterator_Stub90.class, columnParserMap); ReflectionTestUtils.setField(fileLineIterator, "fields", null); try { Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionが発生していません。"); } catch (InvocationTargetException e) { assertTrue(IllegalStateException.class.isAssignableFrom(e.getTargetException() .getCause().getClass())); assertEquals("There is a type which isn't supported in a mapping " + "target field in FileLineObject.", e.getTargetException().getMessage()); assertEquals(fileName, ((FileException)e.getTargetException()).getFileName()); Object result_fields = ReflectionTestUtils.getField(fileLineIterator, "fields"); assertNull(result_fields); } }
@Test @SuppressWarnings("unchecked") public void testBuildStringConverter08() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub46> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub46>( fileName, AbstractFileLineIterator_Stub46.class, columnParserMap); @SuppressWarnings("rawtypes") Map<Class, StringConverter> cache_stringConverterCacheMap = new HashMap<Class, StringConverter>(); ReflectionTestUtils.setField(fileLineIterator, "stringConverterCacheMap", cache_stringConverterCacheMap); Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); try { method = AbstractFileLineIterator.class.getDeclaredMethod("buildStringConverters"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileLineExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { StringConverter[] stringConverters = (StringConverter[]) ReflectionTestUtils.getField(fileLineIterator, "stringConverters"); assertNull(stringConverters); Field field = AbstractFileLineIterator.class.getDeclaredField("stringConverterCacheMap"); field.setAccessible(true); @SuppressWarnings("rawtypes") Map<Class, StringConverter> stringConverterCacheMap = (Map<Class, StringConverter>) field.get(fileLineIterator); assertEquals(1, stringConverterCacheMap.size()); Object cacheMap01 = stringConverterCacheMap .get(NullStringConverter.class); assertSame(NullStringConverter.class, cacheMap01.getClass()); assertEquals(FileLineException.class, e.getTargetException().getClass()); assertEquals("Failed in an instantiate of a stringConverter.", e.getTargetException() .getMessage()); assertEquals(InstantiationException.class, e.getTargetException().getCause().getClass()); assertSame(fileName, ((FileLineException)e.getTargetException()).getFileName()); assertEquals(-1, ((FileLineException)e.getTargetException()).getLineNo()); assertEquals("column2", ((FileLineException)e.getTargetException()).getColumnName()); assertEquals(1, ((FileLineException)e.getTargetException()).getColumnIndex()); } }
@Test @SuppressWarnings("unchecked") public void testBuildStringConverter09() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub47> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub47>( fileName, AbstractFileLineIterator_Stub47.class, columnParserMap); @SuppressWarnings("rawtypes") Map<Class, StringConverter> cache_stringConverterCacheMap = new HashMap<Class, StringConverter>(); ReflectionTestUtils.setField(fileLineIterator, "stringConverterCacheMap", cache_stringConverterCacheMap); Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); try { method = AbstractFileLineIterator.class.getDeclaredMethod("buildStringConverters"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileLineExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { StringConverter[] stringConverters = (StringConverter[]) ReflectionTestUtils.getField(fileLineIterator, "stringConverters"); assertNull(stringConverters); Field field = AbstractFileLineIterator.class.getDeclaredField("stringConverterCacheMap"); field.setAccessible(true); @SuppressWarnings("rawtypes") Map<Class, StringConverter> stringConverterCacheMap = (Map<Class, StringConverter>) field.get(fileLineIterator); assertEquals(1, stringConverterCacheMap.size()); Object cacheMap01 = stringConverterCacheMap .get(NullStringConverter.class); assertSame(NullStringConverter.class, cacheMap01.getClass()); assertEquals(FileLineException.class, e.getTargetException().getClass()); assertEquals("Failed in an instantiate of a stringConverter.", e.getTargetException() .getMessage()); assertEquals(IllegalAccessException.class, e.getTargetException().getCause().getClass()); assertSame(fileName, ((FileLineException)e.getTargetException()).getFileName()); assertEquals(-1, ((FileLineException)e.getTargetException()).getLineNo()); assertEquals("column2", ((FileLineException)e.getTargetException()).getColumnName()); assertEquals(1, ((FileLineException)e.getTargetException()).getColumnIndex()); } }
@Test public void testBuildMethods04() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_bulidFields01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub52> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub52>( fileName, AbstractFileLineIterator_Stub52.class, columnParserMap); Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildFields"); method.setAccessible(true); method.invoke(fileLineIterator); try { method = AbstractFileLineIterator.class.getDeclaredMethod("buildMethods"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした。"); } catch (InvocationTargetException e) { Method[] methods = (Method[]) ReflectionTestUtils.getField( fileLineIterator, "methods"); assertNull(methods); assertSame(FileException.class, e.getTargetException().getClass()); assertEquals("The setter method of column doesn't exist.", e.getTargetException() .getMessage()); assertSame(NoSuchMethodException.class, e.getTargetException().getCause().getClass()); assertSame(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testBuildTrailerQueue06() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_buildTrailerQueue02.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub72> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub72>( fileName, AbstractFileLineIterator_Stub72.class, columnParserMap); Method method = AbstractFileLineIterator.class.getDeclaredMethod("buildLineReader"); method.setAccessible(true); method.invoke(fileLineIterator); try { method = AbstractFileLineIterator.class.getDeclaredMethod("buildTrailerQueue"); method.setAccessible(true); method.invoke(fileLineIterator); fail("FileExceptionがスローされませんでした"); } catch (InvocationTargetException e) { assertEquals(FileException.class, e.getTargetException().getClass()); assertEquals("The data which can be acquired doesn't exist.", e.getTargetException() .getMessage()); assertEquals(NoSuchElementException.class, e.getTargetException().getCause().getClass()); assertEquals(fileName, ((FileException)e.getTargetException()).getFileName()); } }
@Test public void testGetFileName01() throws Exception { URL url = this.getClass().getResource( "AbstractFileLineIterator_skip01.txt"); String fileName = url.getPath(); Map<String, ColumnParser> columnParserMap = new HashMap<String, ColumnParser>(); columnParserMap.put("java.lang.String", new NullColumnParser()); @SuppressWarnings("rawtypes") AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01> fileLineIterator = new AbstractFileLineIteratorImpl02<AbstractFileLineIterator_Stub01>( fileName, AbstractFileLineIterator_Stub01.class, columnParserMap); String fileName_dummy = "ファイル名"; ReflectionTestUtils.setField(fileLineIterator, "fileName", fileName_dummy); String result = fileLineIterator.getFileName(); assertEquals(fileName_dummy, result); }