2424import static org .junit .Assert .assertEquals ;
2525import static org .junit .Assert .fail ;
2626
27- import io .scif .io .ByteArrayHandle ;
28- import io .scif .services .LocationService ;
29-
27+ import java .io .File ;
3028import java .io .IOException ;
3129import java .lang .reflect .Field ;
3230import java .util .HashMap ;
3331import java .util .List ;
3432import java .util .function .Function ;
3533
34+ import org .junit .After ;
35+ import org .junit .Before ;
3636import org .junit .Test ;
3737import org .scijava .Context ;
38+ import org .scijava .io .DataHandle ;
39+ import org .scijava .io .DataHandleService ;
40+ import org .scijava .io .FileLocation ;
3841import org .scijava .io .IOPlugin ;
3942import org .scijava .io .IOService ;
43+ import org .scijava .io .Location ;
4044import org .scijava .plugin .Parameter ;
4145import org .scijava .util .ClassUtils ;
4246
@@ -49,6 +53,15 @@ public class DefaultTableIOPluginTest {
4953
5054 private static final Context ctx = new Context ();
5155
56+ @ Before
57+ @ After
58+ public void removeTempFiles () {
59+ Location source = new FileLocation ("table.txt" );
60+ new File (source .getURI ()).delete ();
61+ source = new FileLocation ("fake.csv" );
62+ new File (source .getURI ()).delete ();
63+ }
64+
5265 /**
5366 * Tests if the parser works on a common tab-delimited table.
5467 */
@@ -241,18 +254,21 @@ private void assertTableEquals(final String[] colHeaders,
241254 private GenericTable openTable (final String tableSource ,
242255 final IOPlugin <GenericTable > tableIO ) throws IOException
243256 {
244- final ByteArrayHandle bah = new ByteArrayHandle (tableSource .getBytes ());
245- ctx .service (LocationService .class ).mapFile ("table.txt" , bah );
257+ final Location dest = new FileLocation ("table.txt" );
258+ final DataHandle <? extends Location > destHandle = ctx .service (DataHandleService .class ).create (dest );
259+ destHandle .write (tableSource .getBytes ());
246260 return tableIO .open ("table.txt" );
247261 }
248262
249263 private String saveTable (final GenericTable table ,
250264 final IOPlugin <GenericTable > tableIO ) throws IOException
251265 {
252- final ByteArrayHandle bah = new ByteArrayHandle ();
253- ctx .service (LocationService .class ).mapFile ("table.txt" , bah );
266+ final Location source = new FileLocation ("table.txt" );
267+ // Remove file during tests
268+ new File (source .getURI ()).delete ();
269+ final DataHandle <? extends Location > sourceHandle = ctx .service (DataHandleService .class ).create (source );
254270 tableIO .save (table , "table.txt" );
255- return new String ( bah . getBytes (), 0 , ( int ) bah . length () );
271+ return sourceHandle . readString ( Integer . MAX_VALUE );
256272 }
257273
258274 private void setValues (final Object instance , final String [] fieldNames ,
0 commit comments