Skip to content
Snippets Groups Projects
Commit 858a6d9a authored by “kpepper”'s avatar “kpepper”
Browse files

Changed BamUtilsTest class to cope with connect exception.

parent c6846581
Branches
Tags
No related merge requests found
...@@ -25,6 +25,7 @@ import static org.junit.Assert.*; ...@@ -25,6 +25,7 @@ import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import java.io.File; import java.io.File;
import java.net.ConnectException;
import java.net.URL; import java.net.URL;
import htsjdk.samtools.BAMIndex; import htsjdk.samtools.BAMIndex;
...@@ -253,12 +254,20 @@ public class BamUtilsTest { ...@@ -253,12 +254,20 @@ public class BamUtilsTest {
// Check getting the index file for a BAM file with an index for FTP // Check getting the index file for a BAM file with an index for FTP
// Should create local copy. // Should create local copy.
// //
try
{
File existingBamIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.bam"); File existingBamIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.bam");
assertNotNull(existingBamIndexFtpFile); assertNotNull(existingBamIndexFtpFile);
assertTrue(existingBamIndexFtpFile.exists()); assertTrue(existingBamIndexFtpFile.exists());
assertTrue(existingBamIndexFtpFile.getName().endsWith(BAMIndex.BAMIndexSuffix)); assertTrue(existingBamIndexFtpFile.getName().endsWith(BAMIndex.BAMIndexSuffix));
assertTrue(existingBamIndexFtpFile.length()>0); assertTrue(existingBamIndexFtpFile.length()>0);
} }
catch (ConnectException e)
{
System.err.println("testGetIndexFileForFtpBam() : WARNING: Unable to run this test as cannot connect to Sanger FTP server");
e.printStackTrace();
}
}
@Test @Test
public void testCreateIndexFileForFtpCram() throws Exception public void testCreateIndexFileForFtpCram() throws Exception
...@@ -276,6 +285,11 @@ public class BamUtilsTest { ...@@ -276,6 +285,11 @@ public class BamUtilsTest {
{ {
assertTrue(e.getMessage().contains("Failed to find an index file")); assertTrue(e.getMessage().contains("Failed to find an index file"));
} }
catch (ConnectException e)
{
System.err.println("testCreateIndexFileForFtpCram() : WARNING: Unable to run this test as cannot connect to Sanger FTP server");
e.printStackTrace();
}
assertNull(createdCramIndexFtpFile); assertNull(createdCramIndexFtpFile);
...@@ -289,10 +303,18 @@ public class BamUtilsTest { ...@@ -289,10 +303,18 @@ public class BamUtilsTest {
// Check getting the index file for a CRAM file with an index for FTP // Check getting the index file for a CRAM file with an index for FTP
// Should create local copy. // Should create local copy.
// //
try
{
File existingCramIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.cram"); File existingCramIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.cram");
assertNotNull(existingCramIndexFtpFile); assertNotNull(existingCramIndexFtpFile);
assertTrue(existingCramIndexFtpFile.exists()); assertTrue(existingCramIndexFtpFile.exists());
assertTrue(existingCramIndexFtpFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX)); assertTrue(existingCramIndexFtpFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX));
assertTrue(existingCramIndexFtpFile.length()>0); assertTrue(existingCramIndexFtpFile.length()>0);
} }
catch (ConnectException e)
{
System.err.println("testGetExistingIndexFileForFtpCram() : WARNING: Unable to run this test as cannot connect to Sanger FTP server");
e.printStackTrace();
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment