1515 */
1616package org .syphr .mythtv .proto ;
1717
18- import java .io .BufferedInputStream ;
1918import java .io .BufferedOutputStream ;
2019import java .io .File ;
2120import java .io .FileOutputStream ;
2221import java .io .IOException ;
23- import java .io .InputStream ;
2422import java .io .OutputStream ;
2523import java .net .InetAddress ;
2624import java .net .URI ;
2725import java .net .URISyntaxException ;
2826import java .net .URL ;
2927import java .util .List ;
28+ import java .util .zip .CRC32 ;
29+ import java .util .zip .Checksum ;
3030
3131import junit .framework .Assert ;
3232
33- import org .apache .commons .io .FileUtils ;
34- import org .apache .commons .io .IOUtils ;
3533import org .junit .AfterClass ;
3634import org .junit .BeforeClass ;
3735import org .junit .Test ;
4644import org .syphr .mythtv .test .Utils ;
4745import org .syphr .prom .PropertiesManager ;
4846
47+ import com .google .common .io .Files ;
48+ import com .google .common .io .Resources ;
49+
4950public class QueryFileTransferTest
5051{
5152 private static final File LOCAL_TEMP = new File ("target/testing" );
@@ -74,10 +75,8 @@ public static void setUpBeforeClass() throws IOException, CommandException
7475 * Download a file directly for comparison later.
7576 */
7677 OutputStream directDownloadOut = new BufferedOutputStream (new FileOutputStream (EXPECTED_FILE ));
77- InputStream directDownloadIn = new BufferedInputStream (new URL (TEST_URL ).openStream ());
78- IOUtils .copy (directDownloadIn , directDownloadOut );
78+ Resources .copy (new URL (TEST_URL ), directDownloadOut );
7979 directDownloadOut .close ();
80- directDownloadIn .close ();
8180
8281 settings = Settings .createSettings ();
8382
@@ -93,7 +92,7 @@ public static void tearDownAfterClass() throws IOException
9392 commandProto .done ();
9493 commandSocketManager .disconnect ();
9594
96- FileUtils . deleteDirectory (LOCAL_TEMP );
95+ Files . deleteRecursively (LOCAL_TEMP );
9796 }
9897
9998 @ Test
@@ -130,8 +129,9 @@ public void testDownloadReadDeleteFile() throws IOException, URISyntaxException,
130129 fileProto .done ();
131130 fileSocketManager .disconnect ();
132131
133- Assert .assertEquals (FileUtils .checksumCRC32 (EXPECTED_FILE ),
134- FileUtils .checksumCRC32 (actualFile ));
132+ Checksum crc32 = new CRC32 ();
133+ Assert .assertEquals (Files .getChecksum (EXPECTED_FILE , crc32 ),
134+ Files .getChecksum (actualFile , crc32 ));
135135
136136 Assert .assertNotNull (commandProto .queryFileExists (dest , TEST_STORAGE_GROUP ));
137137 Assert .assertTrue (commandProto .deleteFile (dest , TEST_STORAGE_GROUP ));
0 commit comments