diff --git a/java/test/org/broadinstitute/sting/WalkerTest.java b/java/test/org/broadinstitute/sting/WalkerTest.java index a718d2526..a51568cc3 100755 --- a/java/test/org/broadinstitute/sting/WalkerTest.java +++ b/java/test/org/broadinstitute/sting/WalkerTest.java @@ -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 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> executeTest(String name, File outputFileLocation, List md5s, List tmpFiles, String args, Class expectedException) { + qcMD5s(name, md5s); + if (outputFileLocation != null) args += " -o " + outputFileLocation.getAbsolutePath(); executeTest(name, args, expectedException); diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/WalkerTestIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/WalkerTestIntegrationTest.java new file mode 100755 index 000000000..2e6cbc324 --- /dev/null +++ b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/WalkerTestIntegrationTest.java @@ -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_"); + } +}