Skip to content

Commit

Permalink
fix some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Oct 17, 2020
1 parent b765f6b commit daf6be3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,15 @@ public class FastaIndexedSequenceTest {

@BeforeClass
public static void setup() throws IOException {
String path = "http://data.broadinstitute.org/igvdata/test/fasta/ci2_test.fa";
String path = "https://s3.amazonaws.com/igv.org.test/data/ci2_test.fa";
fastaSequence = new FastaIndexedSequence(path);
}

/**
* Compare a direct read of sequence from a file vs a read from and indexed fasta for the same interval.
*
* @throws Exception
*/
@Test
public void testReadSequence() throws Exception {

String chr02qSeqPath = "http://data.broadinstitute.org/igvdata/test/fasta/";

String chr = "chr02q";
int start = 3531385;
int end = 3531425;


// TAATTTTTACGTCTTATTTAAACACATATAATGAATAGGT;
Sequence igvSequence = new IGVSequence(chr02qSeqPath);
byte[] expectedBytes = igvSequence.getSequence(chr, start, end, true);
String expectedSequence = new String(expectedBytes);

byte[] bytes = fastaSequence.getSequence(chr, start, end, true);
String seq = new String(bytes);
assertEquals(expectedSequence, seq);
}

@Test
public void testReadEnd() throws Exception {

String path = "http://data.broadinstitute.org/igvdata/test/fasta/ci2_test.fa";
String path = "https://s3.amazonaws.com/igv.org.test/data/ci2_test.fa";

String chr = "chr02q";
int chrLen = 8059593;
Expand Down
6 changes: 0 additions & 6 deletions src/test/java/org/broad/igv/tdf/TDFRegressionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ public void test_IGV1417() {
assertEquals(1, reader.getVersion());
}

@Test
public void test_v3() {
String tdfFile = "http://data.broadinstitute.org/igvdata/test/tdf/NA12878.pilot2.454.bam.tdf";
TDFReader reader = TDFReader.getReader(tdfFile);
assertEquals(3, reader.getVersion());
}

String[] dm3posChromos = new String[]{"chr2RHet", "chr4", "chrU"};
String[] dm3emptyChromos = new String[]{"chrUextra"};
Expand Down
59 changes: 5 additions & 54 deletions src/test/java/org/broad/igv/util/IGVHttpClientUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@

package org.broad.igv.util;

import org.broad.igv.exceptions.HttpResponseException;
import org.broad.igv.prefs.Constants;
import org.broad.igv.prefs.IGVPreferences;
import org.broad.igv.prefs.PreferencesManager;
import org.junit.Ignore;
import org.junit.Test;

import java.io.IOException;
import java.net.URL;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
Expand All @@ -46,20 +40,19 @@

public class IGVHttpClientUtilsTest {

private static String hg18URL = "http://data.broadinstitute.org/igvdata/test/hg18.unittest.genome";
private static int hg18bytes = 3617644;
String url = "https://s3.amazonaws.com/igv.org.test/csi_test/chr10p.bam.csi";
int byteCount = 105063;

@Test
public void testGetContentLength() throws IOException {

String url = hg18URL;
assertEquals(hg18bytes, HttpUtils.getInstance().getContentLength(HttpUtils.createURL(url)));
assertEquals(byteCount, HttpUtils.getInstance().getContentLength(HttpUtils.createURL(url)));
}

@Test
public void testExists() throws IOException {
String url = hg18URL;
assertTrue("Resource unexpectedly does not exist", HttpUtils.getInstance().resourceAvailable(hg18URL));

assertTrue("Resource unexpectedly does not exist", HttpUtils.getInstance().resourceAvailable(url));

url = "http://nosuchserver/genomes/hg18.genome";
assertFalse("Resource unexpectedly found", HttpUtils.getInstance().resourceAvailable(url));
Expand All @@ -68,46 +61,4 @@ public void testExists() throws IOException {
assertFalse(HttpUtils.getInstance().resourceAvailable(url));
}

/**
* This test will only work if on the Broad intranet, as that's where the test proxy server is.
*
* @throws IOException
*/
@Ignore
@Test
public void testProxy() throws IOException {

final URL testURL = HttpUtils.createURL(hg18URL);

IGVPreferences mgr = PreferencesManager.getPreferences();
mgr.override(Constants.PROXY_HOST, "igvdev01.broadinstitute.org");
mgr.override(Constants.PROXY_PORT, "3128");
mgr.override(Constants.PROXY_USER, "proxytest");
String enc_pword = Utilities.base64Encode("test@123");
mgr.override(Constants.PROXY_PW, enc_pword);
mgr.override(Constants.USE_PROXY, "true");
mgr.override(Constants.PROXY_AUTHENTICATE, "true");
HttpUtils.getInstance().updateProxySettings();

long contentLength = 0;
try {
contentLength = HttpUtils.getInstance().getContentLength(testURL);
assertEquals(hg18bytes, contentLength);
} catch (IOException e) {
System.out.println("Proxy unreachable. Skipping proxy test");
return;
}

// Now try to get a file not on the squid "allowed" domains to verify requests are going through the proxy
// This should fail and return -1 for the content length
try {
contentLength = HttpUtils.getInstance().getContentLength(HttpUtils.createURL("http://www.boston.com"));
junit.framework.Assert.fail("Proxy test is apparently bypassing proxy");
} catch (HttpResponseException e) {
// This is expected
assertEquals(403, e.getStatusCode());
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class IGVSeekableBufferedStreamTest extends AbstractHeadlessTest{

// private final File BAM_INDEX_FILE = new File("testdata/net/sf/samtools/BAMFileIndexTest/index_test.bam.bai");
private final File BAM_FILE = new File(TestUtils.DATA_DIR + "/samtools/index_test.bam");
private final String BAM_URL_STRING = "http://data.broadinstitute.org/igvdata/test/data/bam/index_test.bam";
private final String BAM_URL_STRING = "https://s3.amazonaws.com/igv.org.test/data/index_test.bam";
private static File megabyteZerosFile = new File(TestUtils.DATA_DIR + "/samtools/megabyteZeros.dat");

static int expectedFileSize = 20000;
Expand Down

0 comments on commit daf6be3

Please sign in to comment.