@@ -159,15 +159,29 @@ void testInferFromArrayNodeData() throws Exception {
159159 @ Test
160160 @ DisplayName ("Test infer from List containing File objects" )
161161 void testInferFromListWithFiles () throws Exception {
162- File testFile = getResourceFile ("/testsuite-data/files/csv/1mb.csv" );
163- File testFile2 = getResourceFile ("/testsuite-data/files/csv/10mb.csv" );
162+ String testFileContent = TestHelper .getResourceFileContent ("/testsuite-data/files/csv/1mb.csv" );
163+ String testFile2Content = TestHelper .getResourceFileContent ("/testsuite-data/files/csv/10mb.csv" );
164+ File tempDirPath = Files .createTempDirectory ("datapackage-" ).toFile ();
165+
166+ // Write content to temporary files
167+ File testFile = new File (tempDirPath , "test1.csv" );
168+ Files .write (testFile .toPath (), testFileContent .getBytes (StandardCharsets .UTF_8 ));
169+
170+ File testFile2 = new File (tempDirPath , "test2.csv" );
171+ Files .write (testFile2 .toPath (), testFile2Content .getBytes (StandardCharsets .UTF_8 ));
172+
164173 List <File > fileList = Arrays .asList (testFile , testFile2 );
165174
166175 Schema schema = Schema .infer (fileList , StandardCharsets .UTF_8 );
167176
168177 Assertions .assertNotNull (schema );
169178 Assertions .assertTrue (schema .getFields ().size () > 0 );
170179 Assertions .assertTrue (schema .isValid ());
180+
181+ // Clean up
182+ testFile .deleteOnExit ();
183+ testFile2 .deleteOnExit ();
184+ tempDirPath .deleteOnExit ();
171185 }
172186
173187 @ Test
0 commit comments