WalkerTest now checks for valid md5s in the integrationtests themselves, so no more stray whitespace errors. Added a WalkerTestTest to ensure tha t bad MD5s are detected and an error thrown

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5865 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2011-05-24 14:34:55 +00:00
parent 0448ef28d3
commit e582a92af6
2 changed files with 52 additions and 0 deletions

View File

@ -25,6 +25,7 @@
package org.broadinstitute.sting;
import org.apache.commons.lang.StringUtils;
import org.broad.tribble.Tribble;
import org.broad.tribble.index.IndexFactory;
import org.broad.tribble.vcf.VCFCodec;
@ -204,6 +205,21 @@ public class WalkerTest extends BaseTest {
}
}
private void qcMD5s(String name, List<String> md5s) {
final String exampleMD5 = "709a1f482cce68992c637da3cff824a8";
for (String md5 : md5s) {
if ( md5 == null )
throw new IllegalArgumentException("Null MD5 found in test " + name);
if ( md5.equals("") ) // ok
;
if ( ! StringUtils.isAlphanumeric(md5) )
throw new IllegalArgumentException("MD5 contains non-alphanumeric characters test " + name + " md5=" + md5);
if ( md5.length() != exampleMD5.length() )
throw new IllegalArgumentException("Non-empty MD5 of unexpected number of characters test " + name + " md5=" + md5);
}
}
/**
* execute the test, given the following:
* @param name the name of the test
@ -214,6 +230,8 @@ public class WalkerTest extends BaseTest {
* @return a pair of file and string lists
*/
private Pair<List<File>, List<String>> executeTest(String name, File outputFileLocation, List<String> md5s, List<File> tmpFiles, String args, Class expectedException) {
qcMD5s(name, md5s);
if (outputFileLocation != null)
args += " -o " + outputFileLocation.getAbsolutePath();
executeTest(name, args, expectedException);

View File

@ -0,0 +1,34 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
import org.broadinstitute.sting.WalkerTest;
import org.testng.annotations.Test;
import java.util.Arrays;
public class WalkerTestIntegrationTest extends WalkerTest {
public void testBadMD5(String md5) {
WalkerTestSpec spec = new WalkerTestSpec("FAIL", Arrays.asList(md5));
executeTest("", spec);
}
@Test(expectedExceptions = RuntimeException.class)
public void testNullMD5() {
testBadMD5(null);
}
@Test(expectedExceptions = RuntimeException.class)
public void testBadLengthMD5() {
testBadMD5("asdfasdfa");
}
@Test(expectedExceptions = RuntimeException.class)
public void testSpacesMD5() {
testBadMD5("1de8e943fbf55246ebd19efa32f22a58 ");
}
@Test(expectedExceptions = RuntimeException.class)
public void testBadCharMD5() {
testBadMD5("1de8e943fbf55246ebd19efa32f22a5_");
}
}