Skip to content

Commit

Permalink
Merge pull request #234 from kpepper/artemis_unit_testing
Browse files Browse the repository at this point in the history
Changed BamUtilsTest class to cope with connect exception.
  • Loading branch information
kpepper authored Feb 12, 2018
2 parents 3b3a534 + 858a6d9 commit 69d60e7
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions test/uk/ac/sanger/artemis/components/alignment/BamUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.Test;

import java.io.File;
import java.net.ConnectException;
import java.net.URL;

import htsjdk.samtools.BAMIndex;
Expand Down Expand Up @@ -253,11 +254,19 @@ public void testGetIndexFileForFtpBam() throws Exception
// Check getting the index file for a BAM file with an index for FTP
// Should create local copy.
//
File existingBamIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.bam");
assertNotNull(existingBamIndexFtpFile);
assertTrue(existingBamIndexFtpFile.exists());
assertTrue(existingBamIndexFtpFile.getName().endsWith(BAMIndex.BAMIndexSuffix));
assertTrue(existingBamIndexFtpFile.length()>0);
try
{
File existingBamIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.bam");
assertNotNull(existingBamIndexFtpFile);
assertTrue(existingBamIndexFtpFile.exists());
assertTrue(existingBamIndexFtpFile.getName().endsWith(BAMIndex.BAMIndexSuffix));
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
Expand All @@ -276,6 +285,11 @@ public void testCreateIndexFileForFtpCram() throws Exception
{
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);

Expand All @@ -289,10 +303,18 @@ public void testGetExistingIndexFileForFtpCram() throws Exception
// Check getting the index file for a CRAM file with an index for FTP
// Should create local copy.
//
File existingCramIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.cram");
assertNotNull(existingCramIndexFtpFile);
assertTrue(existingCramIndexFtpFile.exists());
assertTrue(existingCramIndexFtpFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX));
assertTrue(existingCramIndexFtpFile.length()>0);
try
{
File existingCramIndexFtpFile = BamUtils.getIndexFile("ftp://ftp.sanger.ac.uk/pub/project/pathogens/kp11/NV.cram");
assertNotNull(existingCramIndexFtpFile);
assertTrue(existingCramIndexFtpFile.exists());
assertTrue(existingCramIndexFtpFile.getName().endsWith(CRAIIndex.CRAI_INDEX_SUFFIX));
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 comments on commit 69d60e7

Please sign in to comment.