From 861ee3e37aed646badd9af2c0d2106a9122df847 Mon Sep 17 00:00:00 2001 From: hanna Date: Mon, 1 Nov 2010 21:31:44 +0000 Subject: [PATCH] Changing testing framework from junit -> testng, for its enhanced configurability. Initial test to see how Bamboo will respond. More detailed email to follow. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4609 348d0f76-0448-11de-a6fe-93d51630548a --- build.xml | 52 ++++---- ivy.xml | 3 +- .../ManagingReferenceOrderedView.java | 1 - .../datasources/providers/RodLocusView.java | 1 - .../FastaSequenceIndexBuilderUnitTest.java | 10 +- .../org/broadinstitute/sting/BaseTest.java | 5 +- .../org/broadinstitute/sting/WalkerTest.java | 6 +- .../alignment/AlignerIntegrationTest.java | 2 +- .../commandline/ParsingEngineUnitTest.java | 109 ++++++++-------- .../pipeline/PipelineUnitTest.java | 21 ++-- .../sting/gatk/WalkerManagerUnitTest.java | 15 +-- .../GATKArgumentCollectionUnitTest.java | 12 +- .../VariantContextIntegrationTest.java | 2 +- .../VariantJEXLContextUnitTest.java | 26 ++-- .../providers/AllLocusViewUnitTest.java | 9 +- .../providers/CoveredLocusViewUnitTest.java | 13 +- .../providers/LocusReferenceViewUnitTest.java | 14 +-- .../providers/LocusViewTemplate.java | 8 +- ...ReadBasedReferenceOrderedViewUnitTest.java | 20 +-- .../providers/ReadReferenceViewUnitTest.java | 14 +-- .../ReferenceOrderedViewUnitTest.java | 30 ++--- .../providers/ReferenceViewTemplate.java | 8 +- .../providers/ShardDataProviderUnitTest.java | 22 ++-- .../sample/SampleDataSourceUnitTest.java | 19 +-- .../datasources/sample/SampleUnitTest.java | 11 +- .../ReferenceOrderedDataPoolUnitTest.java | 70 ++++++----- .../SAMBAMDataSourceUnitTest.java | 14 +-- .../gatk/executive/ReduceTreeUnitTest.java | 74 +++++------ .../ReadGroupBlackListFilterUnitTest.java | 31 ++--- .../BoundedReadIteratorUnitTest.java | 17 +-- .../LocusIteratorByStateUnitTest.java | 26 ++-- .../StingSAMIteratorAdapterUnitTest.java | 14 +-- .../refdata/ReadMetaDataTrackerUnitTest.java | 48 +++---- .../refdata/ReferenceOrderedDataUnitTest.java | 9 +- .../builders/RMDTrackBuilderUnitTest.java | 13 +- .../utils/FlashBackIteratorUnitTest.java | 16 +-- .../TraverseDuplicatesUnitTest.java | 24 ++-- .../traversals/TraverseReadsUnitTest.java | 27 ++-- .../ClipReadsWalkersIntegrationTest.java | 4 +- .../walkers/PileupWalkerIntegrationTest.java | 2 +- .../walkers/PrintReadsWalkerUnitTest.java | 16 ++- .../walkers/VariantsToVCFIntegrationTest.java | 2 +- .../VariantAnnotatorIntegrationTest.java | 2 +- .../GenomicAnnotatorIntegrationTest.java | 2 +- .../walkers/beagle/BeagleIntegrationTest.java | 4 +- .../CallableLociWalkerIntegrationTest.java | 4 +- ...pareCallableLociWalkerIntegrationTest.java | 4 +- .../DepthOfCoverageB36IntegrationTest.java | 2 +- .../DepthOfCoverageIntegrationTest.java | 2 +- ...astaAlternateReferenceIntegrationTest.java | 2 +- .../VariantFiltrationIntegrationTest.java | 4 +- .../GenotypeLikelihoodsUnitTest.java | 17 +-- .../UnifiedGenotyperIntegrationTest.java | 2 +- .../UnifiedGenotyperPerformanceTest.java | 2 +- .../indels/IndelRealignerIntegrationTest.java | 4 +- .../indels/IndelRealignerPerformanceTest.java | 4 +- ...RealignerTargetCreatorIntegrationTest.java | 2 +- ...RealignerTargetCreatorPerformanceTest.java | 4 +- ...gatingAlternateAllelesIntegrationTest.java | 4 +- .../ReadBackedPhasingIntegrationTest.java | 4 +- .../DictionaryConsistencyIntegrationTest.java | 2 +- .../qc/ValidatingPileupIntegrationTest.java | 2 +- .../RecalibrationWalkersIntegrationTest.java | 2 +- .../RecalibrationWalkersPerformanceTest.java | 4 +- .../PickSequenomProbesIntegrationTest.java | 2 +- .../VariantEvalIntegrationTest.java | 10 +- ...ntRecalibrationWalkersIntegrationTest.java | 2 +- .../CombineVariantsIntegrationTest.java | 2 +- .../variantutils/CombineVariantsUnitTest.java | 15 +-- .../LiftoverVariantsIntegrationTest.java | 4 +- .../SelectVariantsIntegrationTest.java | 2 +- .../ValidateVariantsIntegrationTest.java | 4 +- .../ValidateRODForReadsIntegrationTest.java | 2 +- .../HLAcaller/HLACallerIntegrationTest.java | 4 +- .../DuplicatesWalkersIntegrationTest.java | 4 +- .../RodSystemValidationIntegrationTest.java | 2 +- .../sting/utils/BaseUtilsUnitTest.java | 9 +- .../sting/utils/GenomeLocParserUnitTest.java | 119 +++++++++--------- .../utils/GenomeLocSortedSetUnitTest.java | 30 +++-- .../sting/utils/GenomeLocUnitTest.java | 36 +++--- .../sting/utils/MathUtilsUnitTest.java | 15 ++- .../sting/utils/PathUtilsUnitTest.java | 9 +- .../utils/ReservoirDownsamplerUnitTest.java | 79 ++++++------ .../sting/utils/UtilsUnitTest.java | 14 +-- .../sting/utils/bed/BedParserUnitTest.java | 31 ++--- .../ExpandingArrayListUnitTest.java | 75 +++++------ .../genotype/DiploidGenotypeUnitTest.java | 5 +- .../genotype/LikelihoodObjectUnitTest.java | 12 +- .../utils/genotype/glf/GLFReaderUnitTest.java | 9 +- .../utils/genotype/glf/GLFRecordUnitTest.java | 15 +-- .../utils/genotype/glf/GLFWriterUnitTest.java | 20 +-- .../utils/genotype/vcf/VCFHeaderUnitTest.java | 7 +- .../utils/genotype/vcf/VCFWriterUnitTest.java | 18 +-- .../IntervalFileMergingIteratorUnitTest.java | 17 +-- .../interval/IntervalIntegrationTest.java | 2 +- .../utils/interval/IntervalUtilsTest.java | 21 ++-- .../NwayIntervalMergingIteratorUnitTest.java | 11 +- ...est.java => ReadBackedPileupUnitTest.java} | 47 +++---- .../report/AnalysisModuleScannerUnitTest.java | 7 +- .../report/ReportMarshallerUnitTest.java | 2 +- .../report/templates/TextTableUnitTest.java | 9 +- ...rtificialPatternedSAMIteratorUnitTest.java | 10 +- .../sam/ArtificialSAMFileWriterUnitTest.java | 14 +-- .../ArtificialSAMQueryIteratorUnitTest.java | 17 ++- .../utils/sam/ArtificialSAMUtilsUnitTest.java | 18 +-- .../threading/ThreadPoolMonitorUnitTest.java | 4 +- .../IntervalScatterFunctionUnitTest.scala | 12 +- .../sting/queue/util/IOUtilsUnitTest.scala | 5 +- 108 files changed, 876 insertions(+), 795 deletions(-) rename java/test/org/broadinstitute/sting/utils/pileup/{ReadBackedPileupTest.java => ReadBackedPileupUnitTest.java} (74%) diff --git a/build.xml b/build.xml index fa4e84eef..f964f1133 100644 --- a/build.xml +++ b/build.xml @@ -21,10 +21,10 @@ - + - @@ -57,7 +57,7 @@ - + @@ -413,7 +413,7 @@ - + @@ -425,7 +425,7 @@ - + @@ -486,27 +486,33 @@ - - - + + + - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/ivy.xml b/ivy.xml index f4a8f1d8c..f47949227 100644 --- a/ivy.xml +++ b/ivy.xml @@ -11,7 +11,8 @@ - + + diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/providers/ManagingReferenceOrderedView.java b/java/src/org/broadinstitute/sting/gatk/datasources/providers/ManagingReferenceOrderedView.java index 1d9371315..654f0999f 100755 --- a/java/src/org/broadinstitute/sting/gatk/datasources/providers/ManagingReferenceOrderedView.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/providers/ManagingReferenceOrderedView.java @@ -62,7 +62,6 @@ public class ManagingReferenceOrderedView implements ReferenceOrderedView { public void close() { for( ReferenceOrderedDataState state: states ) state.dataSource.close( state.iterator ); - states.clear(); // Clear out the existing data so that post-close() accesses to this data will fail-fast. states = null; diff --git a/java/src/org/broadinstitute/sting/gatk/datasources/providers/RodLocusView.java b/java/src/org/broadinstitute/sting/gatk/datasources/providers/RodLocusView.java index 775b36561..186a7d335 100644 --- a/java/src/org/broadinstitute/sting/gatk/datasources/providers/RodLocusView.java +++ b/java/src/org/broadinstitute/sting/gatk/datasources/providers/RodLocusView.java @@ -208,7 +208,6 @@ public class RodLocusView extends LocusView implements ReferenceOrderedView { public void close() { for( ReferenceOrderedDataState state: states ) state.dataSource.close( state.iterator ); - states.clear(); rodQueue = null; tracker = null; diff --git a/java/test/net/sf/picard/reference/FastaSequenceIndexBuilderUnitTest.java b/java/test/net/sf/picard/reference/FastaSequenceIndexBuilderUnitTest.java index 904de15d0..e45d2395d 100644 --- a/java/test/net/sf/picard/reference/FastaSequenceIndexBuilderUnitTest.java +++ b/java/test/net/sf/picard/reference/FastaSequenceIndexBuilderUnitTest.java @@ -25,11 +25,11 @@ package net.sf.picard.reference; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceDataSourceProgressListener; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -44,7 +44,7 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest { private File fastaFile; private FastaSequenceIndex controlIndex; - @Before + @BeforeMethod public void doForEachTest() throws FileNotFoundException { controlIndex = new FastaSequenceIndex(); } @@ -116,4 +116,4 @@ public class FastaSequenceIndexBuilderUnitTest extends BaseTest { Assert.assertTrue(index.equals(controlIndex)); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/BaseTest.java b/java/test/org/broadinstitute/sting/BaseTest.java index 374ac0157..44e5d0680 100755 --- a/java/test/org/broadinstitute/sting/BaseTest.java +++ b/java/test/org/broadinstitute/sting/BaseTest.java @@ -3,7 +3,7 @@ package org.broadinstitute.sting; import org.apache.log4j.*; import org.apache.log4j.spi.LoggingEvent; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import org.junit.*; +import org.testng.annotations.BeforeClass; import java.io.*; import java.math.BigInteger; @@ -56,8 +56,7 @@ public abstract class BaseTest { /** before the class starts up */ - @BeforeClass - public static void baseStartup() { + public BaseTest() { if (!alreadySetup) { alreadySetup = true; diff --git a/java/test/org/broadinstitute/sting/WalkerTest.java b/java/test/org/broadinstitute/sting/WalkerTest.java index 39e8370dd..80562b77a 100755 --- a/java/test/org/broadinstitute/sting/WalkerTest.java +++ b/java/test/org/broadinstitute/sting/WalkerTest.java @@ -25,7 +25,6 @@ package org.broadinstitute.sting; -import junit.framework.Assert; import org.broad.tribble.Tribble; import org.broad.tribble.index.IndexFactory; import org.broad.tribble.vcf.VCFCodec; @@ -36,7 +35,8 @@ import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.exceptions.StingException; -import org.junit.Test; +import org.testng.Assert; +import org.testng.annotations.Test; import org.apache.commons.io.FileUtils; import java.io.File; @@ -133,7 +133,7 @@ public class WalkerTest extends BaseTest { // todo -- add support for simple inline display of the first N differences for text file } - Assert.assertEquals(name + " Mismatching MD5s", expectedMD5, filemd5sum); + Assert.assertEquals(filemd5sum,expectedMD5,name + " Mismatching MD5s"); System.out.println(String.format(" => %s PASSED", name)); } diff --git a/java/test/org/broadinstitute/sting/alignment/AlignerIntegrationTest.java b/java/test/org/broadinstitute/sting/alignment/AlignerIntegrationTest.java index bda42e212..7a81d47b3 100644 --- a/java/test/org/broadinstitute/sting/alignment/AlignerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/alignment/AlignerIntegrationTest.java @@ -1,6 +1,6 @@ package org.broadinstitute.sting.alignment; -import org.junit.Test; +import org.testng.annotations.Test; import org.broadinstitute.sting.WalkerTest; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/commandline/ParsingEngineUnitTest.java b/java/test/org/broadinstitute/sting/commandline/ParsingEngineUnitTest.java index ad114c63d..74d881fe9 100755 --- a/java/test/org/broadinstitute/sting/commandline/ParsingEngineUnitTest.java +++ b/java/test/org/broadinstitute/sting/commandline/ParsingEngineUnitTest.java @@ -25,13 +25,12 @@ package org.broadinstitute.sting.commandline; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import org.junit.Test; -import org.junit.Before; -import org.junit.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import java.util.Collections; import java.util.List; import java.util.EnumSet; /** @@ -40,7 +39,7 @@ import java.util.EnumSet; public class ParsingEngineUnitTest extends BaseTest { private ParsingEngine parsingEngine; - @Before + @BeforeMethod public void setUp() { parsingEngine = new ParsingEngine(null); } @@ -61,7 +60,7 @@ public class ParsingEngineUnitTest extends BaseTest { InputFileArgProvider argProvider = new InputFileArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", "na12878.bam", argProvider.inputFile ); + Assert.assertEquals(argProvider.inputFile,"na12878.bam","Argument is not correctly initialized"); } @Test @@ -75,7 +74,7 @@ public class ParsingEngineUnitTest extends BaseTest { MultiCharShortNameArgProvider argProvider = new MultiCharShortNameArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", "out.txt", argProvider.outputFile ); + Assert.assertEquals(argProvider.outputFile,"out.txt","Argument is not correctly initialized"); } @@ -95,7 +94,7 @@ public class ParsingEngineUnitTest extends BaseTest { InputFileArgProvider argProvider = new InputFileArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", "na12878.bam", argProvider.inputFile ); + Assert.assertEquals(argProvider.inputFile,"na12878.bam","Argument is not correctly initialized"); } @Test @@ -109,7 +108,7 @@ public class ParsingEngineUnitTest extends BaseTest { InputFileArgProvider argProvider = new InputFileArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", "na12878.bam", argProvider.inputFile ); + Assert.assertEquals(argProvider.inputFile,"na12878.bam","Argument is not correctly initialized"); } @Test @@ -123,7 +122,7 @@ public class ParsingEngineUnitTest extends BaseTest { PrimitiveArgProvider argProvider = new PrimitiveArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", 5, argProvider.foo ); + Assert.assertEquals(argProvider.foo, 5, "Argument is not correctly initialized"); } private class PrimitiveArgProvider { @@ -142,7 +141,7 @@ public class ParsingEngineUnitTest extends BaseTest { AllLociArgProvider argProvider = new AllLociArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertTrue("Argument is not correctly initialized", argProvider.allLoci ); + Assert.assertTrue(argProvider.allLoci,"Argument is not correctly initialized"); } private class AllLociArgProvider { @@ -161,9 +160,9 @@ public class ParsingEngineUnitTest extends BaseTest { MultiValueArgProvider argProvider = new MultiValueArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument array is of incorrect length", 2, argProvider.inputFile.length); - Assert.assertEquals("1st filename is incorrect", "foo.txt", argProvider.inputFile[0] ); - Assert.assertEquals("2nd filename is incorrect", "bar.txt", argProvider.inputFile[1] ); + Assert.assertEquals(argProvider.inputFile.length, 2, "Argument array is of incorrect length"); + Assert.assertEquals(argProvider.inputFile[0],"foo.txt","1st filename is incorrect"); + Assert.assertEquals(argProvider.inputFile[1],"bar.txt","2nd filename is incorrect"); } private class MultiValueArgProvider { @@ -182,7 +181,7 @@ public class ParsingEngineUnitTest extends BaseTest { EnumArgProvider argProvider = new EnumArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Enum value is not correct", TestEnum.TWO, argProvider.testEnum); + Assert.assertEquals(argProvider.testEnum, TestEnum.TWO, "Enum value is not correct"); } @Test @@ -196,7 +195,7 @@ public class ParsingEngineUnitTest extends BaseTest { EnumArgProvider argProvider = new EnumArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Enum value is not correct", TestEnum.ONE, argProvider.testEnum); + Assert.assertEquals(argProvider.testEnum, TestEnum.ONE, "Enum value is not correct"); } @Test @@ -210,7 +209,7 @@ public class ParsingEngineUnitTest extends BaseTest { EnumArgProvider argProvider = new EnumArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Enum value is not correct", TestEnum.THREE, argProvider.testEnum); + Assert.assertEquals(argProvider.testEnum, TestEnum.THREE, "Enum value is not correct"); } public enum TestEnum { ONE, TWO, THREE } @@ -231,13 +230,13 @@ public class ParsingEngineUnitTest extends BaseTest { IntegerListArgProvider argProvider = new IntegerListArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertNotNull("Argument array is null",argProvider.integers); - Assert.assertEquals("Argument array is of incorrect length", 5, argProvider.integers.size()); - Assert.assertEquals("1st integer is incorrect", 2, argProvider.integers.get(0).intValue() ); - Assert.assertEquals("2nd integer is incorrect", 4, argProvider.integers.get(1).intValue() ); - Assert.assertEquals("3rd integer is incorrect", 6, argProvider.integers.get(2).intValue() ); - Assert.assertEquals("4th integer is incorrect", 8, argProvider.integers.get(3).intValue() ); - Assert.assertEquals("5th integer is incorrect",10, argProvider.integers.get(4).intValue() ); + Assert.assertNotNull(argProvider.integers, "Argument array is null"); + Assert.assertEquals(argProvider.integers.size(), 5, "Argument array is of incorrect length"); + Assert.assertEquals(argProvider.integers.get(0).intValue(), 2, "1st integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(1).intValue(), 4, "2nd integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(2).intValue(), 6, "3rd integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(3).intValue(), 8, "4th integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(4).intValue(), 10, "5th integer is incorrect"); } private class IntegerListArgProvider { @@ -256,13 +255,13 @@ public class ParsingEngineUnitTest extends BaseTest { UntypedListArgProvider argProvider = new UntypedListArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertNotNull("Argument array is null",argProvider.integers); - Assert.assertEquals("Argument array is of incorrect length", 5, argProvider.integers.size()); - Assert.assertEquals("1st integer is incorrect", "2", argProvider.integers.get(0) ); - Assert.assertEquals("2nd integer is incorrect", "4", argProvider.integers.get(1) ); - Assert.assertEquals("3rd integer is incorrect", "6", argProvider.integers.get(2) ); - Assert.assertEquals("4th integer is incorrect", "8", argProvider.integers.get(3) ); - Assert.assertEquals("5th integer is incorrect","10", argProvider.integers.get(4) ); + Assert.assertNotNull(argProvider.integers, "Argument array is null"); + Assert.assertEquals(argProvider.integers.size(), 5, "Argument array is of incorrect length"); + Assert.assertEquals(argProvider.integers.get(0), "2", "1st integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(1), "4", "2nd integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(2), "6", "3rd integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(3), "8", "4th integer is incorrect"); + Assert.assertEquals(argProvider.integers.get(4), "10", "5th integer is incorrect"); } private class UntypedListArgProvider { @@ -270,7 +269,7 @@ public class ParsingEngineUnitTest extends BaseTest { public List integers; } - @Test(expected=MissingArgumentException.class) + @Test(expectedExceptions=MissingArgumentException.class) public void requiredArgTest() { final String[] commandLine = new String[0]; @@ -296,7 +295,7 @@ public class ParsingEngineUnitTest extends BaseTest { DefaultValueArgProvider argProvider = new DefaultValueArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Default value is not correctly initialized", 42, argProvider.value.intValue() ); + Assert.assertEquals(argProvider.value.intValue(), 42, "Default value is not correctly initialized"); // Then try to override it. commandLine = new String[] { "--value", "27" }; @@ -306,7 +305,7 @@ public class ParsingEngineUnitTest extends BaseTest { parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Default value is not correctly initialized", 27, argProvider.value.intValue() ); + Assert.assertEquals(argProvider.value.intValue(), 27, "Default value is not correctly initialized"); } private class DefaultValueArgProvider { @@ -325,7 +324,7 @@ public class ParsingEngineUnitTest extends BaseTest { RequiredArgProvider argProvider = new RequiredArgProvider(); parsingEngine.loadArgumentsIntoObject(argProvider ); - Assert.assertNull("Value should have remain unset",argProvider.value); + Assert.assertNull(argProvider.value, "Value should have remain unset"); } @Test @@ -339,7 +338,7 @@ public class ParsingEngineUnitTest extends BaseTest { UnrequiredArgProvider argProvider = new UnrequiredArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertNull( "Value was unrequired and unspecified; contents should be null", argProvider.value ); + Assert.assertNull(argProvider.value, "Value was unrequired and unspecified; contents should be null"); } private class UnrequiredArgProvider { @@ -347,7 +346,7 @@ public class ParsingEngineUnitTest extends BaseTest { public Integer value; } - @Test(expected=InvalidArgumentException.class) + @Test(expectedExceptions=InvalidArgumentException.class) public void invalidArgTest() { final String[] commandLine = new String[] { "--foo" }; @@ -356,7 +355,7 @@ public class ParsingEngineUnitTest extends BaseTest { parsingEngine.validate(); } - @Test(expected= ReviewedStingException.class) + @Test(expectedExceptions= ReviewedStingException.class) public void duplicateLongNameTest() { parsingEngine.addArgumentSource( DuplicateLongNameProvider.class ); } @@ -369,7 +368,7 @@ public class ParsingEngineUnitTest extends BaseTest { public Integer bar; } - @Test(expected= ReviewedStingException.class) + @Test(expectedExceptions= ReviewedStingException.class) public void duplicateShortNameTest() { parsingEngine.addArgumentSource( DuplicateShortNameProvider.class ); } @@ -383,7 +382,7 @@ public class ParsingEngineUnitTest extends BaseTest { public Integer bar; } - @Test(expected=UnmatchedArgumentException.class) + @Test(expectedExceptions=UnmatchedArgumentException.class) public void missingArgumentNameTest() { final String[] commandLine = new String[] {"foo.txt"}; @@ -396,7 +395,7 @@ public class ParsingEngineUnitTest extends BaseTest { } - @Test(expected=UnmatchedArgumentException.class) + @Test(expectedExceptions=UnmatchedArgumentException.class) public void extraValueTest() { final String[] commandLine = new String[] {"-I", "foo.txt", "bar.txt"}; @@ -405,7 +404,7 @@ public class ParsingEngineUnitTest extends BaseTest { parsingEngine.validate(); } - @Test(expected=MissingArgumentException.class) + @Test(expectedExceptions=MissingArgumentException.class) public void multipleInvalidArgTest() { final String[] commandLine = new String[] {"-N1", "-N2", "-N3"}; @@ -414,7 +413,7 @@ public class ParsingEngineUnitTest extends BaseTest { parsingEngine.validate(); } - @Test(expected=TooManyValuesForArgumentException.class) + @Test(expectedExceptions=TooManyValuesForArgumentException.class) public void invalidArgCountTest() { final String[] commandLine = new String[] {"--value","1","--value","2","--value","3"}; @@ -434,7 +433,7 @@ public class ParsingEngineUnitTest extends BaseTest { PackageProtectedArgProvider argProvider = new PackageProtectedArgProvider(); parsingEngine.loadArgumentsIntoObject(argProvider); - Assert.assertEquals("Argument is not correctly initialized", 1, argProvider.foo.intValue() ); + Assert.assertEquals(argProvider.foo.intValue(), 1, "Argument is not correctly initialized"); } private class PackageProtectedArgProvider { @@ -453,7 +452,7 @@ public class ParsingEngineUnitTest extends BaseTest { DerivedArgProvider argProvider = new DerivedArgProvider(); parsingEngine.loadArgumentsIntoObject(argProvider); - Assert.assertEquals("Argument is not correctly initialized", 5, argProvider.bar.intValue() ); + Assert.assertEquals(argProvider.bar.intValue(), 5, "Argument is not correctly initialized"); } private class DerivedArgProvider extends BaseArgProvider { @@ -471,7 +470,7 @@ public class ParsingEngineUnitTest extends BaseTest { DefinitionMatcher matcher = ArgumentDefinitions.FullNameDefinitionMatcher; ArgumentDefinition definition = parsingEngine.argumentDefinitions.findArgumentDefinition("myarg", matcher); - Assert.assertNotNull("Invalid default argument name assigned", definition ); + Assert.assertNotNull(definition, "Invalid default argument name assigned"); } private class CamelCaseArgProvider { @@ -479,7 +478,7 @@ public class ParsingEngineUnitTest extends BaseTest { Integer myArg; } - @Test(expected=UnmatchedArgumentException.class) + @Test(expectedExceptions=UnmatchedArgumentException.class) public void booleanWithParameterTest() { final String[] commandLine = new String[] {"--mybool", "true"}; @@ -504,7 +503,7 @@ public class ParsingEngineUnitTest extends BaseTest { AnalysisTypeArgProvider argProvider = new AnalysisTypeArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", "Pileup", argProvider.Analysis_Name ); + Assert.assertEquals(argProvider.Analysis_Name,"Pileup","Argument is not correctly initialized"); } private class AnalysisTypeArgProvider { @@ -512,7 +511,7 @@ public class ParsingEngineUnitTest extends BaseTest { public String Analysis_Name = null; } - @Test(expected=TooManyValuesForArgumentException.class) + @Test(expectedExceptions=TooManyValuesForArgumentException.class) public void invalidParseForAnalysisTypeTest() { final String[] commandLine = new String[] {"--analysis_type", "Pileup", "-T", "CountReads" }; @@ -521,7 +520,7 @@ public class ParsingEngineUnitTest extends BaseTest { parsingEngine.validate( EnumSet.of(ParsingEngine.ValidationType.MissingRequiredArgument) ); } - @Test(expected=ArgumentsAreMutuallyExclusiveException.class) + @Test(expectedExceptions=ArgumentsAreMutuallyExclusiveException.class) public void mutuallyExclusiveArgumentsTest() { // Passing only foo should work fine... String[] commandLine = new String[] {"--foo","5"}; @@ -533,7 +532,7 @@ public class ParsingEngineUnitTest extends BaseTest { MutuallyExclusiveArgProvider argProvider = new MutuallyExclusiveArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", 5, argProvider.foo.intValue() ); + Assert.assertEquals(argProvider.foo.intValue(), 5, "Argument is not correctly initialized"); // But when foo and bar come together, danger! commandLine = new String[] {"--foo","5","--bar","6"}; @@ -550,7 +549,7 @@ public class ParsingEngineUnitTest extends BaseTest { Integer bar; } - @Test(expected=InvalidArgumentValueException.class) + @Test(expectedExceptions=InvalidArgumentValueException.class) public void argumentValidationTest() { // Passing only foo should work fine... String[] commandLine = new String[] {"--value","521"}; @@ -562,7 +561,7 @@ public class ParsingEngineUnitTest extends BaseTest { ValidatingArgProvider argProvider = new ValidatingArgProvider(); parsingEngine.loadArgumentsIntoObject( argProvider ); - Assert.assertEquals("Argument is not correctly initialized", 521, argProvider.value.intValue() ); + Assert.assertEquals(argProvider.value.intValue(), 521, "Argument is not correctly initialized"); // Try some invalid arguments commandLine = new String[] {"--value","foo"}; @@ -586,7 +585,7 @@ public class ParsingEngineUnitTest extends BaseTest { ArgumentCollectionProvider argProvider = new ArgumentCollectionProvider(); parsingEngine.loadArgumentsIntoObject(argProvider); - Assert.assertEquals("Argument is not correctly initialized", 5, argProvider.rap.value.intValue() ); + Assert.assertEquals(argProvider.rap.value.intValue(), 5, "Argument is not correctly initialized"); } private class ArgumentCollectionProvider { @@ -594,7 +593,7 @@ public class ParsingEngineUnitTest extends BaseTest { RequiredArgProvider rap = new RequiredArgProvider(); } - @Test(expected= ReviewedStingException.class) + @Test(expectedExceptions= ReviewedStingException.class) public void multipleArgumentCollectionTest() { parsingEngine.addArgumentSource( MultipleArgumentCollectionProvider.class ); } diff --git a/java/test/org/broadinstitute/sting/datasources/pipeline/PipelineUnitTest.java b/java/test/org/broadinstitute/sting/datasources/pipeline/PipelineUnitTest.java index 7a32bcea5..6411ab93b 100644 --- a/java/test/org/broadinstitute/sting/datasources/pipeline/PipelineUnitTest.java +++ b/java/test/org/broadinstitute/sting/datasources/pipeline/PipelineUnitTest.java @@ -24,9 +24,10 @@ package org.broadinstitute.sting.datasources.pipeline; +import org.testng.Assert; import org.broadinstitute.sting.utils.yaml.YamlUtils; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.io.File; import java.util.Map; @@ -53,29 +54,29 @@ public class PipelineUnitTest { YamlUtils.dump(pipeline, file); Pipeline pipelineLoad = YamlUtils.load(Pipeline.class, file); - Assert.assertEquals(pipeline.getProject().getName(), pipelineLoad.getProject().getName()); + Assert.assertEquals(pipelineLoad.getProject().getName(), pipeline.getProject().getName()); Assert.assertEquals(pipeline.getProject().getReferenceFile(), pipelineLoad.getProject().getReferenceFile()); Assert.assertEquals(pipeline.getProject().getIntervalList(), pipelineLoad.getProject().getIntervalList()); Assert.assertEquals(pipeline.getProject().getDbsnpFile(), pipelineLoad.getProject().getDbsnpFile()); - Assert.assertEquals(pipeline.getProject().getTags().size(), pipelineLoad.getProject().getTags().size()); + Assert.assertEquals(pipelineLoad.getProject().getTags().size(), pipeline.getProject().getTags().size()); for (Map.Entry entry : pipeline.getProject().getTags().entrySet()) - Assert.assertEquals(entry.getValue(), pipeline.getProject().getTags().get(entry.getKey())); + Assert.assertEquals(pipeline.getProject().getTags().get(entry.getKey()), entry.getValue()); - Assert.assertEquals(pipeline.getSamples().size(), pipelineLoad.getSamples().size()); + Assert.assertEquals(pipelineLoad.getSamples().size(), pipeline.getSamples().size()); for (int i = 0; i < pipeline.getSamples().size(); i++) { PipelineSample pipelineSample = pipeline.getSamples().get(i); PipelineSample pipelineLoadSample = pipelineLoad.getSamples().get(i); - Assert.assertEquals(pipelineSample.getId(), pipelineLoadSample.getId()); + Assert.assertEquals(pipelineLoadSample.getId(), pipelineSample.getId()); - Assert.assertEquals(pipelineSample.getBamFiles().size(), pipelineLoadSample.getBamFiles().size()); + Assert.assertEquals(pipelineLoadSample.getBamFiles().size(), pipelineSample.getBamFiles().size()); for (Map.Entry entry : pipelineSample.getBamFiles().entrySet()) Assert.assertEquals(entry.getValue(), pipelineSample.getBamFiles().get(entry.getKey())); - Assert.assertEquals(pipelineSample.getTags().size(), pipelineLoadSample.getTags().size()); + Assert.assertEquals(pipelineLoadSample.getTags().size(), pipelineSample.getTags().size()); for (Map.Entry entry : pipelineSample.getTags().entrySet()) - Assert.assertEquals(entry.getValue(), pipelineSample.getTags().get(entry.getKey())); + Assert.assertEquals(pipelineSample.getTags().get(entry.getKey()), entry.getValue()); } } } diff --git a/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java b/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java index d8d946cde..cd43927a4 100644 --- a/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/WalkerManagerUnitTest.java @@ -24,15 +24,16 @@ package org.broadinstitute.sting.gatk; +import org.testng.Assert; import org.broadinstitute.sting.commandline.Hidden; import org.broadinstitute.sting.gatk.walkers.Requires; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.qc.CountLociWalker; import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * Tests basic functionality of the walker manager. @@ -41,7 +42,7 @@ public class WalkerManagerUnitTest { private static WalkerManager walkerManager; @BeforeClass - public static void setUp() { + public void setUp() { walkerManager = new WalkerManager(); } @@ -51,12 +52,12 @@ public class WalkerManagerUnitTest { Assert.assertEquals(CountLociWalker.class,countLociWalker.getClass()); } - @Test(expected=UserException.class) + @Test(expectedExceptions=UserException.class) public void testAbsentWalker() { walkerManager.createByName("Missing"); } - @Test(expected=DynamicClassResolutionException.class) + @Test(expectedExceptions=DynamicClassResolutionException.class) public void testUninstantiableWalker() { walkerManager.createByName("Uninstantiable"); } @@ -69,4 +70,4 @@ class UninstantiableWalker extends Walker { private UninstantiableWalker() {} public Long reduceInit() { return 0L; } public Long reduce(Integer value, Long accum) { return 0L; } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollectionUnitTest.java b/java/test/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollectionUnitTest.java index ff436ae44..6f1a7e332 100755 --- a/java/test/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollectionUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/arguments/GATKArgumentCollectionUnitTest.java @@ -1,10 +1,10 @@ package org.broadinstitute.sting.gatk.arguments; import org.broadinstitute.sting.BaseTest; -import org.junit.After; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.fail; import java.io.File; import java.util.*; @@ -54,13 +54,13 @@ public class GATKArgumentCollectionUnitTest extends BaseTest { private String xmlFileLoc = "testfile.xml"; /** setup our test */ - @Before + @BeforeMethod public void setup() { collect = new GATKArgumentCollection(); } /** destroy the temp file */ - @After + @AfterMethod public void takedown() { File f = new File(xmlFileLoc); if (f.exists()) { diff --git a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java index 3f8324afa..34f1c0298 100755 --- a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java @@ -2,7 +2,7 @@ package org.broadinstitute.sting.gatk.contexts.variantcontext; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.HashMap; import java.util.Map; diff --git a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantJEXLContextUnitTest.java b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantJEXLContextUnitTest.java index 7372f5eae..146c11231 100644 --- a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantJEXLContextUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantJEXLContextUnitTest.java @@ -26,14 +26,15 @@ package org.broadinstitute.sting.gatk.contexts.variantcontext; import net.sf.samtools.SAMFileHeader; import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.VariantContext; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.List; @@ -59,7 +60,7 @@ public class VariantJEXLContextUnitTest extends BaseTest { Allele del, delRef, ATC, ATCref; // A [ref] / T at 10 - GenomeLoc snpLoc = GenomeLocParser.createGenomeLoc("chr1", 10, 10); + GenomeLoc snpLoc; // - / ATC [ref] from 20-23 private static int startingChr = 1; @@ -69,7 +70,7 @@ public class VariantJEXLContextUnitTest extends BaseTest { static SAMFileHeader header; @BeforeClass - public static void beforeClass() { + public void beforeClass() { header = ArtificialSAMUtils.createArtificialSamHeader(( endingChr - startingChr ) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); try { @@ -77,9 +78,10 @@ public class VariantJEXLContextUnitTest extends BaseTest { } catch (Exception e) { Assert.fail("Unable to create expression" + e.getMessage()); } + snpLoc = GenomeLocParser.createGenomeLoc("chr1", 10, 10); } - @Before + @BeforeMethod public void before() { del = Allele.create("-"); delRef = Allele.create("-", true); @@ -100,34 +102,34 @@ public class VariantJEXLContextUnitTest extends BaseTest { // make sure the context has a value Assert.assertTrue(!map.isEmpty()); - Assert.assertEquals(1,map.size()); + Assert.assertEquals(map.size(), 1); // eval our known expression Assert.assertTrue(!map.get(exp)); } - @Test(expected=UnsupportedOperationException.class) + @Test(expectedExceptions=UnsupportedOperationException.class) public void testContainsValue() { Map map = getVarContext(); map.containsValue(exp); } - @Test(expected=UnsupportedOperationException.class) + @Test(expectedExceptions=UnsupportedOperationException.class) public void testRemove() { Map map = getVarContext(); map.remove(exp); } - @Test(expected=UnsupportedOperationException.class) + @Test(expectedExceptions=UnsupportedOperationException.class) public void testEntrySet() { Map map = getVarContext(); map.entrySet(); } - @Test(expected=UnsupportedOperationException.class) + @Test(expectedExceptions=UnsupportedOperationException.class) public void testClear() { Map map = getVarContext(); diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/AllLocusViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/AllLocusViewUnitTest.java index 0eb83e0da..4665f11af 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/AllLocusViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/AllLocusViewUnitTest.java @@ -1,6 +1,7 @@ package org.broadinstitute.sting.gatk.datasources.providers; -import org.junit.Assert; + +import org.testng.Assert; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; @@ -48,17 +49,17 @@ public class AllLocusViewUnitTest extends LocusViewTemplate { for( long i = bounds.getStart(); i <= bounds.getStop(); i++ ) { GenomeLoc site = GenomeLocParser.createGenomeLoc("chr1",i); AlignmentContext locusContext = allLocusView.next(); - Assert.assertEquals("Locus context location is incorrect", site, locusContext.getLocation() ); + Assert.assertEquals(locusContext.getLocation(), site, "Locus context location is incorrect"); int expectedReadsAtSite = 0; for( SAMRecord read: reads ) { if(GenomeLocParser.createGenomeLoc(read).containsP(locusContext.getLocation())) { - Assert.assertTrue("Target locus context does not contain reads", locusContext.getReads().contains(read) ); + Assert.assertTrue(locusContext.getReads().contains(read),"Target locus context does not contain reads"); expectedReadsAtSite++; } } - Assert.assertEquals("Found wrong number of reads at site", expectedReadsAtSite, locusContext.getReads().size()); + Assert.assertEquals(locusContext.getReads().size(), expectedReadsAtSite, "Found wrong number of reads at site"); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/CoveredLocusViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/CoveredLocusViewUnitTest.java index 3cf2d5c53..625fc22d9 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/CoveredLocusViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/CoveredLocusViewUnitTest.java @@ -1,6 +1,7 @@ package org.broadinstitute.sting.gatk.datasources.providers; -import org.junit.Assert; + +import org.testng.Assert; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; @@ -60,18 +61,18 @@ public class CoveredLocusViewUnitTest extends LocusViewTemplate { if( expectedReadsAtSite < 1 ) continue; - Assert.assertTrue("Incorrect number of loci in view",coveredLocusView.hasNext()); + Assert.assertTrue(coveredLocusView.hasNext(),"Incorrect number of loci in view"); AlignmentContext locusContext = coveredLocusView.next(); - Assert.assertEquals("Target locus context location is incorrect", site, locusContext.getLocation() ); - Assert.assertEquals("Found wrong number of reads at site", expectedReadsAtSite, locusContext.getReads().size()); + Assert.assertEquals(locusContext.getLocation(), site, "Target locus context location is incorrect"); + Assert.assertEquals(locusContext.getReads().size(), expectedReadsAtSite, "Found wrong number of reads at site"); for( SAMRecord read: reads ) { if(GenomeLocParser.createGenomeLoc(read).containsP(locusContext.getLocation())) - Assert.assertTrue("Target locus context does not contain reads", locusContext.getReads().contains(read) ); + Assert.assertTrue(locusContext.getReads().contains(read),"Target locus context does not contain reads"); } } - Assert.assertFalse("Iterator is not bounded at boundaries of shard", coveredLocusView.hasNext()); + Assert.assertFalse(coveredLocusView.hasNext(),"Iterator is not bounded at boundaries of shard"); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewUnitTest.java index eafbf1dd5..26efb0e13 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusReferenceViewUnitTest.java @@ -1,7 +1,8 @@ package org.broadinstitute.sting.gatk.datasources.providers; -import org.junit.Test; -import org.junit.Assert; +import org.testng.Assert; +import org.testng.annotations.Test; + import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.gatk.datasources.shards.Shard; @@ -44,7 +45,7 @@ public class LocusReferenceViewUnitTest extends ReferenceViewTemplate { // // /** Multiple-base pair queries should generate exceptions. */ -// @Test(expected = InvalidPositionException.class) +// @Test(expectedExceptions=InvalidPositionException.class) // public void testSingleBPFailure() { // Shard shard = new LocusShard(GenomeLocParser.createGenomeLoc(0, 1, 50)); // @@ -62,7 +63,7 @@ public class LocusReferenceViewUnitTest extends ReferenceViewTemplate { byte[] results = view.getReferenceBases(GenomeLocParser.createGenomeLoc(0, sequenceFile.getSequence("chrM").length() - 10, sequenceFile.getSequence("chrM").length() + 9)); System.out.printf("results are %s%n", new String(results)); - Assert.assertEquals(20, results.length); + Assert.assertEquals(results.length, 20); for (int x = 0; x < results.length; x++) { if (x <= 10) Assert.assertTrue(results[x] != 'X'); else Assert.assertTrue(results[x] == 'X'); @@ -106,9 +107,8 @@ public class LocusReferenceViewUnitTest extends ReferenceViewTemplate { char expected = Character.toUpperCase(StringUtil.bytesToString(expectedAsSeq.getBases()).charAt(0)); char actual = view.getReferenceContext(locus).getBaseAsChar(); - Assert.assertEquals(String.format("Value of base at position %s in shard %s does not match expected", locus.toString(), shard.getGenomeLocs()), - expected, - actual); + Assert.assertEquals(actual, expected, String.format("Value of base at position %s in shard %s does not match expected", locus.toString(), shard.getGenomeLocs()) + ); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusViewTemplate.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusViewTemplate.java index 260217566..078978586 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusViewTemplate.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/LocusViewTemplate.java @@ -16,8 +16,9 @@ import org.broadinstitute.sting.gatk.iterators.StingSAMIterator; import org.broadinstitute.sting.gatk.iterators.LocusIteratorByState; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.BeforeClass; -import org.junit.Test; +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.FileNotFoundException; import java.util.*; @@ -40,7 +41,8 @@ public abstract class LocusViewTemplate extends BaseTest { protected static ReferenceSequenceFile sequenceSourceFile = null; @BeforeClass - public static void setupGenomeLoc() throws FileNotFoundException { + public void setupGenomeLoc() throws FileNotFoundException { + GenomeLocParserTestUtils.clearSequenceDictionary(); sequenceSourceFile = fakeReferenceSequenceFile(); GenomeLocParser.setupRefContigOrdering(sequenceSourceFile); } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewUnitTest.java index 5dc52fcba..fe58e166a 100644 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewUnitTest.java @@ -25,6 +25,7 @@ package org.broadinstitute.sting.gatk.datasources.providers; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.ReadMetaDataTrackerUnitTest; @@ -34,10 +35,11 @@ import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.*; @@ -58,12 +60,12 @@ public class ReadBasedReferenceOrderedViewUnitTest extends BaseTest { private static SAMFileHeader header; @BeforeClass - public static void beforeClass() { + public void beforeClass() { header = ArtificialSAMUtils.createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } - @Before + @BeforeMethod public void beforeEach() { } @@ -83,9 +85,9 @@ public class ReadBasedReferenceOrderedViewUnitTest extends BaseTest { ReadMetaDataTracker tracker = view.getReferenceOrderedDataForRead(rec); Map> map = tracker.getReadOffsetMapping(); for (Long i : map.keySet()) { - Assert.assertEquals(1, map.get(i).size()); + Assert.assertEquals(map.get(i).size(), 1); } - Assert.assertEquals(10, map.keySet().size()); + Assert.assertEquals(map.keySet().size(), 10); } } @@ -180,4 +182,4 @@ class FakeRODRecordList extends AbstractList implements RODRecordLi public int compareTo(RODRecordList rodRecordList) { return this.list.get(0).getLocation().compareTo(rodRecordList.getLocation()); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadReferenceViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadReferenceViewUnitTest.java index 888529f67..bc9b685cf 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadReferenceViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadReferenceViewUnitTest.java @@ -1,11 +1,11 @@ package org.broadinstitute.sting.gatk.datasources.providers; +import org.testng.Assert; import org.broadinstitute.sting.utils.GenomeLoc; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import net.sf.samtools.*; -import net.sf.samtools.util.StringUtil; import net.sf.picard.reference.ReferenceSequence; /* @@ -79,8 +79,8 @@ public class ReadReferenceViewUnitTest extends ReferenceViewTemplate { byte[] expected = expectedAsSeq.getBases(); byte[] actual = view.getReferenceBases(rec); - Assert.assertEquals(expected.length, (readLength - overlap)); - Assert.assertEquals(actual.length, readLength); + Assert.assertEquals((readLength - overlap), expected.length); + Assert.assertEquals(readLength, actual.length); int xRange = 0; for (; xRange < (readLength - overlap); xRange++) { Assert.assertTrue(actual[xRange] != 'X'); @@ -105,9 +105,7 @@ public class ReadReferenceViewUnitTest extends ReferenceViewTemplate { byte[] expected = expectedAsSeq.getBases(); byte[] actual = view.getReferenceBases(read); - Assert.assertArrayEquals(String.format("Base array at in shard %s does not match expected",loc.toString()), - expected, - actual); + org.testng.Assert.assertEquals(actual,expected,String.format("Base array at in shard %s does not match expected",loc.toString())); } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java index 6b4ba7db6..87aeffbc5 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceOrderedViewUnitTest.java @@ -1,19 +1,19 @@ package org.broadinstitute.sting.gatk.datasources.providers; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.datasources.shards.Shard; import org.broadinstitute.sting.gatk.datasources.shards.MockLocusShard; import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData; import org.broadinstitute.sting.gatk.refdata.features.table.TableCodec; import org.broadinstitute.sting.gatk.refdata.features.table.TableFeature; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack; import org.broadinstitute.sting.gatk.refdata.tracks.builders.RMDTrackBuilder; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -50,7 +50,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { RMDTrackBuilder builder = new RMDTrackBuilder(); @BeforeClass - public static void init() throws FileNotFoundException { + public void init() throws FileNotFoundException { // sequence seq = new IndexedFastaSequenceFile(new File(hg18Reference)); GenomeLocParser.setupRefContigOrdering(seq); @@ -66,7 +66,7 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { ReferenceOrderedView view = new ManagingReferenceOrderedView( provider ); RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(GenomeLocParser.createGenomeLoc("chrM",10)); - Assert.assertEquals("The tracker should not have produced any data", 0, tracker.getAllRods().size()); + Assert.assertEquals(tracker.getAllRods().size(), 0, "The tracker should not have produced any data"); } /** @@ -86,9 +86,9 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(GenomeLocParser.createGenomeLoc("chrM",20)); TableFeature datum = tracker.lookup("tableTest",TableFeature.class); - Assert.assertEquals("datum parameter for COL1 is incorrect", "C", datum.get("COL1")); - Assert.assertEquals("datum parameter for COL2 is incorrect", "D", datum.get("COL2")); - Assert.assertEquals("datum parameter for COL3 is incorrect", "E", datum.get("COL3")); + Assert.assertEquals(datum.get("COL1"),"C","datum parameter for COL1 is incorrect"); + Assert.assertEquals(datum.get("COL2"),"D","datum parameter for COL2 is incorrect"); + Assert.assertEquals(datum.get("COL3"),"E","datum parameter for COL3 is incorrect"); } /** @@ -113,14 +113,14 @@ public class ReferenceOrderedViewUnitTest extends BaseTest { RefMetaDataTracker tracker = view.getReferenceOrderedDataAtLocus(GenomeLocParser.createGenomeLoc("chrM",20)); TableFeature datum1 = tracker.lookup("tableTest1",TableFeature.class); - Assert.assertEquals("datum1 parameter for COL1 is incorrect", "C", datum1.get("COL1")); - Assert.assertEquals("datum1 parameter for COL2 is incorrect", "D", datum1.get("COL2")); - Assert.assertEquals("datum1 parameter for COL3 is incorrect", "E", datum1.get("COL3")); + Assert.assertEquals(datum1.get("COL1"),"C","datum1 parameter for COL1 is incorrect"); + Assert.assertEquals(datum1.get("COL2"),"D","datum1 parameter for COL2 is incorrect"); + Assert.assertEquals(datum1.get("COL3"),"E","datum1 parameter for COL3 is incorrect"); TableFeature datum2 = tracker.lookup("tableTest2", TableFeature.class); - Assert.assertEquals("datum2 parameter for COL1 is incorrect", "C", datum2.get("COL1")); - Assert.assertEquals("datum2 parameter for COL2 is incorrect", "D", datum2.get("COL2")); - Assert.assertEquals("datum2 parameter for COL3 is incorrect", "E", datum2.get("COL3")); + Assert.assertEquals(datum2.get("COL1"),"C","datum2 parameter for COL1 is incorrect"); + Assert.assertEquals(datum2.get("COL2"),"D","datum2 parameter for COL2 is incorrect"); + Assert.assertEquals(datum2.get("COL3"),"E","datum2 parameter for COL3 is incorrect"); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceViewTemplate.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceViewTemplate.java index a8de32a2e..0bb142ef7 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceViewTemplate.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReferenceViewTemplate.java @@ -5,8 +5,9 @@ import net.sf.picard.reference.IndexedFastaSequenceFile; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.BeforeClass; -import org.junit.Test; +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -41,7 +42,8 @@ public abstract class ReferenceViewTemplate extends BaseTest { * Initialize the fasta. */ @BeforeClass - public static void initialize() throws FileNotFoundException { + public void initialize() throws FileNotFoundException { + GenomeLocParserTestUtils.clearSequenceDictionary(); sequenceFile = new IndexedFastaSequenceFile( new File(hg18Reference) ); GenomeLocParser.setupRefContigOrdering(sequenceFile); } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ShardDataProviderUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ShardDataProviderUnitTest.java index 691849959..88e2ddfd0 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ShardDataProviderUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ShardDataProviderUnitTest.java @@ -1,9 +1,11 @@ package org.broadinstitute.sting.gatk.datasources.providers; +import org.testng.Assert; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import org.junit.Before; -import org.junit.Assert; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; + + +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; import java.util.Collection; @@ -32,7 +34,7 @@ public class ShardDataProviderUnitTest extends BaseTest { */ private ShardDataProvider provider = null; - @Before + @BeforeMethod public void createProvider() { provider = new LocusShardDataProvider( null,null,null,null,null,null ); } @@ -43,10 +45,10 @@ public class ShardDataProviderUnitTest extends BaseTest { @Test public void testClose() { TestView testView = new TestView( provider ); - Assert.assertFalse("View is currently closed but should be open", testView.closed); + Assert.assertFalse(testView.closed,"View is currently closed but should be open"); provider.close(); - Assert.assertTrue("View is currently open but should be closed", testView.closed); + Assert.assertTrue(testView.closed,"View is currently open but should be closed"); } /** @@ -56,17 +58,17 @@ public class ShardDataProviderUnitTest extends BaseTest { public void testMultipleClose() { Collection testViews = Arrays.asList(new TestView(provider),new TestView(provider)); for( TestView testView: testViews ) - Assert.assertFalse("View is currently closed but should be open", testView.closed); + Assert.assertFalse(testView.closed,"View is currently closed but should be open"); provider.close(); for( TestView testView: testViews ) - Assert.assertTrue("View is currently open but should be closed", testView.closed); + Assert.assertTrue(testView.closed,"View is currently open but should be closed"); } /** * Try adding a view which conflicts with some other view that's already been registered. */ - @Test(expected= ReviewedStingException.class) + @Test(expectedExceptions= ReviewedStingException.class) public void testAddViewWithExistingConflict() { View initial = new ConflictingTestView( provider ); View conflictsWithInitial = new TestView( provider ); @@ -75,7 +77,7 @@ public class ShardDataProviderUnitTest extends BaseTest { /** * Try adding a view which has a conflict with a previously registered view. */ - @Test(expected= ReviewedStingException.class) + @Test(expectedExceptions= ReviewedStingException.class) public void testAddViewWithNewConflict() { View conflictsWithInitial = new TestView( provider ); View initial = new ConflictingTestView( provider ); diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleDataSourceUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleDataSourceUnitTest.java index befbce602..1bf71c326 100644 --- a/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleDataSourceUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleDataSourceUnitTest.java @@ -4,10 +4,11 @@ import net.sf.samtools.SAMFileHeader; import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.exceptions.StingException; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.io.File; import java.util.*; @@ -50,14 +51,14 @@ public class SampleDataSourceUnitTest extends BaseTest { } // but that file should fail if it has an extra character in it... - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void loadInvalidSampleExtraCharText() { File sampleFile = new File(sampleFilesDir + "invalidSyntaxExtraChar.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); } // ...or a typo... - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void loadInvalidSampleTypoText() { File sampleFile = new File(sampleFilesDir + "invalidSyntaxTypo.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); @@ -65,14 +66,14 @@ public class SampleDataSourceUnitTest extends BaseTest { } // ...or an extra unrecognized array - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void loadInvalidSampleExtraArrayText() { File sampleFile = new File(sampleFilesDir + "invalidSyntaxExtraArray.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); } // make sure aliases work - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void sampleAliasText() { File sampleFile = new File(sampleFilesDir + "basicSampleFileWithAlias.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); @@ -82,14 +83,14 @@ public class SampleDataSourceUnitTest extends BaseTest { } // error is thrown if property is included that's not in properties array - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void unallowedPropertySampleTest() { File sampleFile = new File(sampleFilesDir + "basicSampleFileUnallowedProperty.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); } // same as above, with relationship - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void unallowedRelationshipSampleTest() { File sampleFile = new File(sampleFilesDir + "basicSampleFileUnallowedRelationship.yaml"); SampleDataSource s = new SampleDataSource(header, makeFileList(sampleFile)); @@ -109,7 +110,7 @@ public class SampleDataSourceUnitTest extends BaseTest { } // two sample files, with contradictory properties - @Test(expected = StingException.class) + @Test(expectedExceptions=StingException.class) public void twoContradictorySampleFilesTest() { File sampleFile = new File(sampleFilesDir + "basicSampleFile.yaml"); File secondFile = new File(sampleFilesDir + "basicSampleFileInvalidExt.yaml"); diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleUnitTest.java index 9daa55a96..67e84cdd8 100644 --- a/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/sample/SampleUnitTest.java @@ -1,9 +1,10 @@ package org.broadinstitute.sting.gatk.datasources.sample; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * Created by IntelliJ IDEA. @@ -19,7 +20,7 @@ public class SampleUnitTest extends BaseTest { static Sample sampleC; @BeforeClass - public static void init() { + public void init() { sampleA = new Sample("sampleA"); sampleA.setProperty("uniqueProperty", "uniqueValue"); sampleA1 = new Sample("sampleA"); @@ -60,4 +61,4 @@ public class SampleUnitTest extends BaseTest { Assert.assertFalse(sampleA.isMale()); // sample A doesn't have a gender, so this should be false } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java index fb3d3b66e..c0149580d 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/ReferenceOrderedDataPoolUnitTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.datasources.simpleDataSources; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedData; import org.broadinstitute.sting.gatk.refdata.features.table.TableCodec; import org.broadinstitute.sting.gatk.refdata.features.table.TableFeature; import org.broadinstitute.sting.gatk.refdata.tracks.RMDTrack; @@ -9,15 +9,15 @@ import org.broadinstitute.sting.gatk.refdata.tracks.builders.RMDTrackBuilder; import org.broadinstitute.sting.gatk.refdata.utils.LocationAwareSeekableRODIterator; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import static org.testng.Assert.assertTrue; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; -import static org.junit.Assert.assertTrue; import net.sf.picard.reference.IndexedFastaSequenceFile; /** * User: hanna @@ -40,17 +40,21 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { private RMDTrack rod = null; - private final GenomeLoc testSite1 = GenomeLocParser.createGenomeLoc("chrM",10); - private final GenomeLoc testSite2 = GenomeLocParser.createGenomeLoc("chrM",20); - private final GenomeLoc testSite3 = GenomeLocParser.createGenomeLoc("chrM",30); + private GenomeLoc testSite1; + private GenomeLoc testSite2; + private GenomeLoc testSite3; @BeforeClass - public static void init() throws FileNotFoundException { + public void init() throws FileNotFoundException { File sequenceFile = new File(hg18Reference); GenomeLocParser.setupRefContigOrdering(new IndexedFastaSequenceFile(sequenceFile)); + + testSite1 = GenomeLocParser.createGenomeLoc("chrM",10); + testSite2 = GenomeLocParser.createGenomeLoc("chrM",20); + testSite3 = GenomeLocParser.createGenomeLoc("chrM",30); } - @Before + @BeforeMethod public void setUp() { File file = new File(testDir + "TabularDataTest.dat"); RMDTrackBuilder builder = new RMDTrackBuilder(); @@ -62,8 +66,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { ResourcePool iteratorPool = new ReferenceOrderedDataPool(rod, false); LocationAwareSeekableRODIterator iterator = (LocationAwareSeekableRODIterator)iteratorPool.iterator( new MappedStreamSegment(testSite1) ); - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 0, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect"); TableFeature datum = (TableFeature)iterator.next().get(0).getUnderlyingObject(); @@ -74,8 +78,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { iteratorPool.release(iterator); - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 1, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 1, "Number of available iterators in the pool is incorrect"); } @Test @@ -86,8 +90,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { // Create a new iterator at position 2. LocationAwareSeekableRODIterator iterator2 = iteratorPool.iterator( new MappedStreamSegment(testSite2) ); - Assert.assertEquals("Number of iterators in the pool is incorrect", 2, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 0, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect"); // Test out-of-order access: first iterator2, then iterator1. // Ugh...first call to a region needs to be a seek. @@ -119,13 +123,13 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { // Cleanup, and make sure the number of iterators dies appropriately. iteratorPool.release(iterator1); - Assert.assertEquals("Number of iterators in the pool is incorrect", 2, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 1, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 1, "Number of available iterators in the pool is incorrect"); iteratorPool.release(iterator2); - Assert.assertEquals("Number of iterators in the pool is incorrect", 2, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 2, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 2, "Number of available iterators in the pool is incorrect"); } @Test @@ -133,8 +137,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { ReferenceOrderedDataPool iteratorPool = new ReferenceOrderedDataPool(rod, false); LocationAwareSeekableRODIterator iterator = iteratorPool.iterator( new MappedStreamSegment(testSite1) ); - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 0, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect"); TableFeature datum = (TableFeature)iterator.next().get(0).getUnderlyingObject(); assertTrue(datum.getLocation().equals(testSite1)); @@ -148,8 +152,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { iterator = iteratorPool.iterator( new MappedStreamSegment(testSite3) ); // Make sure that the previously acquired iterator was reused. - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 0, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect"); datum = (TableFeature)iterator.seekForward(testSite3).get(0).getUnderlyingObject(); assertTrue(datum.getLocation().equals(testSite3)); @@ -159,8 +163,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { iteratorPool.release(iterator); - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 1, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 1, "Number of available iterators in the pool is incorrect"); } @Test @@ -168,8 +172,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { ReferenceOrderedDataPool iteratorPool = new ReferenceOrderedDataPool(rod, false); LocationAwareSeekableRODIterator iterator = iteratorPool.iterator( new MappedStreamSegment(testSite3) ); - Assert.assertEquals("Number of iterators in the pool is incorrect", 1, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 0, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 1, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 0, "Number of available iterators in the pool is incorrect"); TableFeature datum = (TableFeature)iterator.seekForward(testSite3).get(0).getUnderlyingObject(); assertTrue(datum.getLocation().equals(testSite3)); @@ -183,8 +187,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { iterator = iteratorPool.iterator(new MappedStreamSegment(testSite1) ); // Make sure that the previously acquired iterator was reused. - Assert.assertEquals("Number of iterators in the pool is incorrect", 2, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 1, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 1, "Number of available iterators in the pool is incorrect"); datum = (TableFeature)iterator.next().get(0).getUnderlyingObject(); assertTrue(datum.getLocation().equals(testSite1)); @@ -194,8 +198,8 @@ public class ReferenceOrderedDataPoolUnitTest extends BaseTest { iteratorPool.release(iterator); - Assert.assertEquals("Number of iterators in the pool is incorrect", 2, iteratorPool.numIterators()); - Assert.assertEquals("Number of available iterators in the pool is incorrect", 2, iteratorPool.numAvailableIterators()); + Assert.assertEquals(iteratorPool.numIterators(), 2, "Number of iterators in the pool is incorrect"); + Assert.assertEquals(iteratorPool.numAvailableIterators(), 2, "Number of available iterators in the pool is incorrect"); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMBAMDataSourceUnitTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMBAMDataSourceUnitTest.java index cd520c1aa..96f21e698 100755 --- a/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMBAMDataSourceUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/simpleDataSources/SAMBAMDataSourceUnitTest.java @@ -1,6 +1,6 @@ package org.broadinstitute.sting.gatk.datasources.simpleDataSources; -import static junit.framework.Assert.fail; +import static org.testng.Assert.fail; import net.sf.picard.reference.IndexedFastaSequenceFile; import net.sf.samtools.SAMRecord; import org.broadinstitute.sting.BaseTest; @@ -8,13 +8,13 @@ import org.broadinstitute.sting.gatk.datasources.shards.Shard; import org.broadinstitute.sting.gatk.datasources.shards.ShardStrategy; import org.broadinstitute.sting.gatk.datasources.shards.ShardStrategyFactory; import org.broadinstitute.sting.gatk.iterators.StingSAMIterator; -import org.broadinstitute.sting.gatk.ReadProperties; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -58,7 +58,7 @@ public class SAMBAMDataSourceUnitTest extends BaseTest { *

* Called before every test case method. */ - @Before + @BeforeMethod public void doForEachTest() throws FileNotFoundException { readers = new ArrayList(); @@ -72,7 +72,7 @@ public class SAMBAMDataSourceUnitTest extends BaseTest { *

* Called after every test case method. */ - @After + @AfterMethod public void undoForEachTest() { seq = null; readers.clear(); diff --git a/java/test/org/broadinstitute/sting/gatk/executive/ReduceTreeUnitTest.java b/java/test/org/broadinstitute/sting/gatk/executive/ReduceTreeUnitTest.java index 17d494c0e..18bb8199a 100755 --- a/java/test/org/broadinstitute/sting/gatk/executive/ReduceTreeUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/executive/ReduceTreeUnitTest.java @@ -1,10 +1,11 @@ package org.broadinstitute.sting.gatk.executive; -import org.junit.Assert; -import org.junit.Test; -import org.junit.Before; -import org.junit.After; -import org.junit.Ignore; + +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; + import org.broadinstitute.sting.BaseTest; import java.util.concurrent.Callable; @@ -42,12 +43,12 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc */ private List> reduces = new ArrayList>(); - @Before + @BeforeMethod public void createTree() { reduceTree = new ReduceTree( this ); } - @After + @AfterMethod public void destroyTree() { reduceTree = null; reduces.clear(); @@ -57,7 +58,7 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc public void testNoValueReduce() throws InterruptedException, ExecutionException { reduceTree.complete(); - Assert.assertEquals("Single-value reduce failed", null, reduceTree.getResult()); + Assert.assertEquals(reduceTree.getResult(), null, "Single-value reduce failed"); } @Test @@ -65,10 +66,10 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc throws InterruptedException, ExecutionException { reduceTree.addEntry( getReduceTestEntry(1) ); reduceTree.complete(); - Assert.assertEquals("Single-value reduce failed", 1, reduceTree.getResult().get()); + Assert.assertEquals(reduceTree.getResult().get(), 1, "Single-value reduce failed"); } - @Test(expected=IllegalStateException.class) + @Test(expectedExceptions=IllegalStateException.class) public void testIncompleteReduce() throws InterruptedException, ExecutionException { reduceTree.addEntry( getReduceTestEntry(1) ); @@ -87,11 +88,11 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc expected.add( 2 ); // Test the result - Assert.assertEquals("Dual-value reduce failed", expected, reduceTree.getResult().get()); + Assert.assertEquals(reduceTree.getResult().get(), expected, "Dual-value reduce failed"); // Test the intermediate steps - Assert.assertEquals("Size of incoming tree reduces incorrect", 1, reduces.size() ); - Assert.assertEquals("Incoming tree reduce incorrect", expected, reduces.get(0) ); + Assert.assertEquals(reduces.size(), 1, "Size of incoming tree reduces incorrect"); + Assert.assertEquals(reduces.get(0), expected, "Incoming tree reduce incorrect"); } @Test @@ -107,26 +108,26 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc reduceTree.addEntry( getReduceTestEntry(1) ); - Assert.assertEquals("Reduce queue should be empty after entering a single element", 0, reduces.size()); + Assert.assertEquals(reduces.size(), 0, "Reduce queue should be empty after entering a single element"); reduceTree.addEntry( getReduceTestEntry(2) ); - Assert.assertEquals("Reduce queue should have one element after two entries", 1, reduces.size()); - Assert.assertEquals("Reduce queue element is incorrect after two entries", firstExpected, reduces.get(0)); + Assert.assertEquals(reduces.size(), 1, "Reduce queue should have one element after two entries"); + Assert.assertEquals(reduces.get(0), firstExpected, "Reduce queue element is incorrect after two entries"); reduceTree.addEntry( getReduceTestEntry(3) ); - Assert.assertEquals("Reduce queue should have one element after three entries", 1, reduces.size()); - Assert.assertEquals("Reduce queue element is incorrect after three entries", firstExpected, reduces.get(0)); + Assert.assertEquals(reduces.size(), 1, "Reduce queue should have one element after three entries"); + Assert.assertEquals(reduces.get(0), firstExpected, "Reduce queue element is incorrect after three entries"); reduceTree.complete(); // Test the result - Assert.assertEquals("Three value reduce failed", finalExpected, reduceTree.getResult().get()); + Assert.assertEquals(reduceTree.getResult().get(), finalExpected, "Three value reduce failed"); - Assert.assertEquals("Reduce queue should have two elements after three entries (complete)", 2, reduces.size()); - Assert.assertEquals("Reduce queue element is incorrect after three entries", firstExpected, reduces.get(0)); - Assert.assertEquals("Reduce queue element is incorrect after three entries", finalExpected, reduces.get(1)); + Assert.assertEquals(reduces.size(), 2, "Reduce queue should have two elements after three entries (complete)"); + Assert.assertEquals(reduces.get(0), firstExpected, "Reduce queue element is incorrect after three entries"); + Assert.assertEquals(reduces.get(1), finalExpected, "Reduce queue element is incorrect after three entries"); } @Test @@ -146,35 +147,35 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc reduceTree.addEntry( getReduceTestEntry(1) ); - Assert.assertEquals("Reduce queue should be empty after entering a single element", 0, reduces.size()); + Assert.assertEquals(reduces.size(), 0, "Reduce queue should be empty after entering a single element"); reduceTree.addEntry( getReduceTestEntry(2) ); - Assert.assertEquals("Reduce queue should have one element after two entries", 1, reduces.size()); - Assert.assertEquals("Reduce queue element is incorrect after two entries", lhsExpected, reduces.get(0)); + Assert.assertEquals(reduces.size(), 1, "Reduce queue should have one element after two entries"); + Assert.assertEquals(reduces.get(0), lhsExpected, "Reduce queue element is incorrect after two entries"); reduceTree.addEntry( getReduceTestEntry(3) ); - Assert.assertEquals("Reduce queue should have one element after three entries", 1, reduces.size()); - Assert.assertEquals("Reduce queue element is incorrect after three entries", lhsExpected, reduces.get(0)); + Assert.assertEquals(reduces.size(), 1, "Reduce queue should have one element after three entries"); + Assert.assertEquals(reduces.get(0), lhsExpected, "Reduce queue element is incorrect after three entries"); reduceTree.addEntry( getReduceTestEntry(4) ); - Assert.assertEquals("Reduce queue should have three elements after four entries", 3, reduces.size()); - Assert.assertEquals("Reduce queue element 0 is incorrect after three entries", lhsExpected, reduces.get(0)); - Assert.assertEquals("Reduce queue element 1 is incorrect after three entries", rhsExpected, reduces.get(1)); - Assert.assertEquals("Reduce queue element 2 is incorrect after three entries", finalExpected, reduces.get(2)); + Assert.assertEquals(reduces.size(), 3, "Reduce queue should have three elements after four entries"); + Assert.assertEquals(reduces.get(0), lhsExpected, "Reduce queue element 0 is incorrect after three entries"); + Assert.assertEquals(reduces.get(1), rhsExpected, "Reduce queue element 1 is incorrect after three entries"); + Assert.assertEquals(reduces.get(2), finalExpected, "Reduce queue element 2 is incorrect after three entries"); reduceTree.complete(); // Test the result - Assert.assertEquals("Four-valued reduce failed",finalExpected,reduceTree.getResult().get()); + Assert.assertEquals(reduceTree.getResult().get(), finalExpected, "Four-valued reduce failed"); // Test the working tree - Assert.assertEquals("Didn't see correct number of reduces", 3, reduces.size()); - Assert.assertEquals("lhs of four value reduce failed", lhsExpected, reduces.get(0)); - Assert.assertEquals("rhs of four value reduce failed", rhsExpected, reduces.get(1)); - Assert.assertEquals("final value four value reduce failed", finalExpected, reduces.get(2)); + Assert.assertEquals(reduces.size(), 3, "Didn't see correct number of reduces"); + Assert.assertEquals(reduces.get(0), lhsExpected, "lhs of four value reduce failed"); + Assert.assertEquals(reduces.get(1), rhsExpected, "rhs of four value reduce failed"); + Assert.assertEquals(reduces.get(2), finalExpected, "final value four value reduce failed"); } @@ -214,7 +215,6 @@ public class ReduceTreeUnitTest extends BaseTest implements ReduceTree.TreeReduc return getReduceTestEntry( reduce ); } - @Ignore private class ReduceTestEntry implements Callable { private Object data; diff --git a/java/test/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilterUnitTest.java b/java/test/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilterUnitTest.java index 0b86466dd..ffad08047 100644 --- a/java/test/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilterUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/filters/ReadGroupBlackListFilterUnitTest.java @@ -1,12 +1,13 @@ package org.broadinstitute.sting.gatk.filters; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMReadGroupRecord; @@ -24,7 +25,7 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { private static SAMFileHeader header; @BeforeClass - public static void beforeClass() { + public void beforeClass() { header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); List readGroupIDs = new ArrayList(); @@ -46,18 +47,18 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testBadFilter() { List badFilters = Collections.singletonList("bad"); new ReadGroupBlackListFilter(badFilters); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testBadFilterTag() { List badFilters = Collections.singletonList("bad:filter"); new ReadGroupBlackListFilter(badFilters); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testBadFilterFile() { List badFilters = Collections.singletonList("/foo/bar/rgbl.txt"); new ReadGroupBlackListFilter(badFilters); @@ -131,8 +132,8 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { int filteredExpected = recordsPerGroup * 2; int unfilteredExpected = recordsPerGroup * (READ_GROUP_COUNT - 2); - Assert.assertEquals("Filtered", filteredExpected, filtered); - Assert.assertEquals("Uniltered", unfilteredExpected, unfiltered); + Assert.assertEquals(filtered, filteredExpected, "Filtered"); + Assert.assertEquals(unfiltered, unfilteredExpected, "Uniltered"); } @Test @@ -170,8 +171,8 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { int filteredExpected = 6; int unfilteredExpected = 9; - Assert.assertEquals("Filtered", filteredExpected, filtered); - Assert.assertEquals("Uniltered", unfilteredExpected, unfiltered); + Assert.assertEquals(filtered, filteredExpected, "Filtered"); + Assert.assertEquals(unfiltered, unfilteredExpected, "Uniltered"); } @Test @@ -209,8 +210,8 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { int filteredExpected = recordsPerGroup * 2; int unfilteredExpected = recordsPerGroup * (READ_GROUP_COUNT - 2); - Assert.assertEquals("Filtered", filteredExpected, filtered); - Assert.assertEquals("Uniltered", unfilteredExpected, unfiltered); + Assert.assertEquals(filtered, filteredExpected, "Filtered"); + Assert.assertEquals(unfiltered, unfilteredExpected, "Uniltered"); } @Test @@ -248,7 +249,7 @@ public class ReadGroupBlackListFilterUnitTest extends BaseTest { int filteredExpected = recordsPerGroup * 2; int unfilteredExpected = recordsPerGroup * (READ_GROUP_COUNT - 2); - Assert.assertEquals("Filtered", filteredExpected, filtered); - Assert.assertEquals("Uniltered", unfilteredExpected, unfiltered); + Assert.assertEquals(filtered, filteredExpected, "Filtered"); + Assert.assertEquals(unfiltered, unfilteredExpected, "Uniltered"); } } diff --git a/java/test/org/broadinstitute/sting/gatk/iterators/BoundedReadIteratorUnitTest.java b/java/test/org/broadinstitute/sting/gatk/iterators/BoundedReadIteratorUnitTest.java index d999f52c3..e81c80b96 100755 --- a/java/test/org/broadinstitute/sting/gatk/iterators/BoundedReadIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/iterators/BoundedReadIteratorUnitTest.java @@ -1,19 +1,20 @@ package org.broadinstitute.sting.gatk.iterators; -import static junit.framework.Assert.fail; +import static org.testng.Assert.fail; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; import net.sf.picard.reference.ReferenceSequenceFile; import net.sf.picard.reference.IndexedFastaSequenceFile; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.gatk.ReadProperties; +import org.testng.Assert; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -68,7 +69,7 @@ public class BoundedReadIteratorUnitTest extends BaseTest { *

* Called before every test case method. */ - @Before + @BeforeMethod public void doForEachTest() throws FileNotFoundException { fl = new ArrayList(); @@ -92,7 +93,7 @@ public class BoundedReadIteratorUnitTest extends BaseTest { count++; } - Assert.assertEquals(expected,count); + Assert.assertEquals(count, expected); } } @@ -120,4 +121,4 @@ class testIterator implements StingSAMIterator { public Iterator iterator() { return this; } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/iterators/LocusIteratorByStateUnitTest.java b/java/test/org/broadinstitute/sting/gatk/iterators/LocusIteratorByStateUnitTest.java index 723d40207..f01c4869c 100644 --- a/java/test/org/broadinstitute/sting/gatk/iterators/LocusIteratorByStateUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/iterators/LocusIteratorByStateUnitTest.java @@ -1,11 +1,11 @@ package org.broadinstitute.sting.gatk.iterators; -import junit.framework.Assert; import net.sf.picard.filter.SamRecordFilter; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMFileReader; import net.sf.samtools.SAMRecord; import net.sf.samtools.util.CloseableIterator; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.ReadProperties; import org.broadinstitute.sting.gatk.arguments.ValidationExclusion; @@ -15,8 +15,8 @@ import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup; import org.broadinstitute.sting.utils.classloader.JVMUtils; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.BeforeClass; -import org.junit.Test; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.*; @@ -30,7 +30,7 @@ public class LocusIteratorByStateUnitTest extends BaseTest { private LocusIteratorByState li; @BeforeClass - public static void beforeClass() { + public void beforeClass() { header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } @@ -70,13 +70,13 @@ public class LocusIteratorByStateUnitTest extends BaseTest { continue; ReadBackedExtendedEventPileup pileup = context.getExtendedEventPileup().getBaseFilteredPileup(10); - Assert.assertEquals("Extended event pileup at wrong location",5,pileup.getLocation().getStart()); - Assert.assertEquals("Pileup size is incorrect",3,pileup.size()); + Assert.assertEquals(pileup.getLocation().getStart(), 5, "Extended event pileup at wrong location"); + Assert.assertEquals(pileup.size(), 3, "Pileup size is incorrect"); foundExtendedEventPileup = true; } - Assert.assertTrue("Extended event pileup not found",foundExtendedEventPileup); + Assert.assertTrue(foundExtendedEventPileup,"Extended event pileup not found"); } /** @@ -121,15 +121,15 @@ public class LocusIteratorByStateUnitTest extends BaseTest { if(!context.hasExtendedEventPileup()) continue; - Assert.assertEquals("Extended event pileup at wrong location",10,context.getLocation().getStart()); - Assert.assertEquals("Pileup size is incorrect",2,context.size()); - Assert.assertEquals("Read in pileup is incorrect",during,context.getExtendedEventPileup().getReads().get(0)); - Assert.assertEquals("Read in pileup is incorrect",after,context.getExtendedEventPileup().getReads().get(1)); + Assert.assertEquals(context.getLocation().getStart(), 10, "Extended event pileup at wrong location"); + Assert.assertEquals(context.size(), 2, "Pileup size is incorrect"); + Assert.assertEquals(context.getExtendedEventPileup().getReads().get(0), during, "Read in pileup is incorrect"); + Assert.assertEquals(context.getExtendedEventPileup().getReads().get(1), after, "Read in pileup is incorrect"); foundExtendedEventPileup = true; } - Assert.assertTrue("Extended event pileup not found",foundExtendedEventPileup); + Assert.assertTrue(foundExtendedEventPileup,"Extended event pileup not found"); } private static ReadProperties createTestReadProperties() { @@ -174,4 +174,4 @@ class FakeCloseableIterator implements CloseableIterator { public void remove() { throw new UnsupportedOperationException("Don't remove!"); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/iterators/StingSAMIteratorAdapterUnitTest.java b/java/test/org/broadinstitute/sting/gatk/iterators/StingSAMIteratorAdapterUnitTest.java index 5a9a42cdb..5f8e78cba 100755 --- a/java/test/org/broadinstitute/sting/gatk/iterators/StingSAMIteratorAdapterUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/iterators/StingSAMIteratorAdapterUnitTest.java @@ -3,8 +3,8 @@ package org.broadinstitute.sting.gatk.iterators; import net.sf.samtools.SAMRecord; import net.sf.samtools.util.CloseableIterator; import org.broadinstitute.sting.BaseTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; import java.util.Iterator; @@ -105,9 +105,9 @@ public class StingSAMIteratorAdapterUnitTest extends BaseTest { //logger.warn("cnt = " + countCheck); } - assertEquals(COUNT, countCheck); + assertEquals(countCheck, COUNT); - assertEquals(COUNT, countCheck); + assertEquals(countCheck, COUNT); } @Test @@ -124,7 +124,7 @@ public class StingSAMIteratorAdapterUnitTest extends BaseTest { ++countCheck; } - assertEquals(COUNT, countCheck); + assertEquals(countCheck, COUNT); } @Test @@ -142,10 +142,10 @@ public class StingSAMIteratorAdapterUnitTest extends BaseTest { ++countCheck; } - assertEquals(COUNT, countCheck); + assertEquals(countCheck, COUNT); // check to see that the count get's set to -1 samIt.close(); - assertEquals(-1, it.count); + assertEquals(it.count, -1); } } diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerUnitTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerUnitTest.java index e74c550cc..1450a975f 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerUnitTest.java @@ -25,16 +25,18 @@ package org.broadinstitute.sting.gatk.refdata; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.datasources.providers.RODMetaDataContainer; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.*; @@ -55,12 +57,12 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { private Set nameSet; @BeforeClass - public static void beforeClass() { + public void beforeClass() { header = ArtificialSAMUtils.createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } - @Before + @BeforeMethod public void beforeEach() { nameSet = new TreeSet(); nameSet.add("default"); @@ -75,9 +77,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { int count = 0; for (Long x : tracker.getReadOffsetMapping().keySet()) { count++; - Assert.assertEquals(2, tracker.getReadOffsetMapping().get(x).size()); + Assert.assertEquals(tracker.getReadOffsetMapping().get(x).size(), 2); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @Test @@ -89,9 +91,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { int count = 0; for (Long x : tracker.getReadOffsetMapping().keySet()) { count++; - Assert.assertEquals(1, tracker.getReadOffsetMapping().get(x).size()); + Assert.assertEquals(tracker.getReadOffsetMapping().get(x).size(), 1); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @Test @@ -104,9 +106,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { Map> map = tracker.getReadOffsetMapping("default"); for (Long x : map.keySet()) { count++; - Assert.assertEquals(1, map.get(x).size()); + Assert.assertEquals(map.get(x).size(), 1); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @Test @@ -118,9 +120,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { Map> map = tracker.getReadOffsetMapping(FakeRODatum.class); for (Long x : map.keySet()) { count++; - Assert.assertEquals(2, map.get(x).size()); + Assert.assertEquals(map.get(x).size(), 2); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } // @Test this test can be uncommented to determine the speed impacts of any changes to the RODs for reads system @@ -137,9 +139,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { Map> map = tracker.getReadOffsetMapping(FakeRODatum.class); for (Long x : map.keySet()) { count++; - Assert.assertEquals(y + 2, map.get(x).size()); + Assert.assertEquals(map.get(x).size(), y + 2); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } System.err.println(y + " = " + (System.currentTimeMillis() - firstTime)); } @@ -156,9 +158,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { Map> map = tracker.getReadOffsetMapping(Fake2RODatum.class); for (long x : map.keySet()) { count++; - Assert.assertEquals(1, map.get(x).size()); + Assert.assertEquals(map.get(x).size(), 1); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @Test @@ -169,9 +171,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { int count = 0; for (Long x : tracker.getReadOffsetMapping().keySet()) { count++; - Assert.assertEquals(1, tracker.getReadOffsetMapping().get(x).size()); + Assert.assertEquals(tracker.getReadOffsetMapping().get(x).size(), 1); } - Assert.assertEquals(2, count); + Assert.assertEquals(count, 2); } @Test @@ -182,9 +184,9 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { int count = 0; for (Long x : tracker.getContigOffsetMapping().keySet()) { count++; - Assert.assertEquals(1, tracker.getContigOffsetMapping().get(x).size()); + Assert.assertEquals(tracker.getContigOffsetMapping().get(x).size(), 1); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @@ -269,4 +271,4 @@ public class ReadMetaDataTrackerUnitTest extends BaseTest { return (int)this.location.getStop(); } } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedDataUnitTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedDataUnitTest.java index aacb9a9aa..fa20ea913 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedDataUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedDataUnitTest.java @@ -1,8 +1,9 @@ package org.broadinstitute.sting.gatk.refdata; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ public class ReferenceOrderedDataUnitTest extends BaseTest { String file = validationDataLocation + "testRODFileImpl.csv"; List lst = new ArrayList(); ReferenceOrderedData.extractRodsFromFile(lst,file); - Assert.assertEquals(6,lst.size()); + Assert.assertEquals(lst.size(), 6); int index = 0; for (String entry: lst) { String first = entry.subSequence(0,entry.indexOf(",")).toString(); @@ -37,7 +38,7 @@ public class ReferenceOrderedDataUnitTest extends BaseTest { List lst = new ArrayList(); ReferenceOrderedData.extractRodsFromFile(lst,file); ReferenceOrderedData.extractRodsFromFile(lst,file2); - Assert.assertEquals(12,lst.size()); + Assert.assertEquals(lst.size(), 12); int index = 0; for (String entry: lst) { String first = entry.subSequence(0,entry.indexOf(",")).toString(); diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilderUnitTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilderUnitTest.java index f44a3f9af..f95a3b193 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilderUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/tracks/builders/RMDTrackBuilderUnitTest.java @@ -26,16 +26,17 @@ package org.broadinstitute.sting.gatk.refdata.tracks.builders; import net.sf.picard.reference.IndexedFastaSequenceFile; import net.sf.samtools.SAMSequenceDictionary; -import net.sf.samtools.SAMSequenceRecord; import org.broad.tribble.Tribble; import org.broad.tribble.index.Index; import org.broad.tribble.vcf.VCFCodec; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.file.FSLockWithShared; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import java.io.*; import java.nio.channels.FileChannel; @@ -53,7 +54,7 @@ public class RMDTrackBuilderUnitTest extends BaseTest { private RMDTrackBuilder builder; private IndexedFastaSequenceFile seq; - @Before + @BeforeMethod public void setup() { builder = new RMDTrackBuilder(); seq = new IndexedFastaSequenceFile(new File(b36KGReference)); @@ -160,7 +161,7 @@ public class RMDTrackBuilderUnitTest extends BaseTest { } // make sure that we removed and updated the index - Assert.assertTrue("Fail: index file was modified", Tribble.indexFile(vcfFile).lastModified() == indexTimeStamp); + Assert.assertTrue(Tribble.indexFile(vcfFile).lastModified() == indexTimeStamp,"Fail: index file was modified"); } /** diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/utils/FlashBackIteratorUnitTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/utils/FlashBackIteratorUnitTest.java index 14c57ab7f..8f6d16782 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/utils/FlashBackIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/utils/FlashBackIteratorUnitTest.java @@ -1,14 +1,16 @@ package org.broadinstitute.sting.gatk.refdata.utils; import net.sf.samtools.SAMFileHeader; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -31,7 +33,7 @@ public class FlashBackIteratorUnitTest extends BaseTest { private static final int STARTING_CHROMOSOME = 1; private static final int CHROMOSOME_SIZE = 1000; - @Before + @BeforeMethod public void setup() { GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } @@ -86,7 +88,7 @@ public class FlashBackIteratorUnitTest extends BaseTest { count++; iter.next(); } - Assert.assertEquals(10, count); + Assert.assertEquals(count, 10); } @@ -133,7 +135,7 @@ public class FlashBackIteratorUnitTest extends BaseTest { count++; iter.next(); } - Assert.assertEquals(6, count); // chr1:5, 6, 7, 8, 9, and 10 + Assert.assertEquals(count, 6); // chr1:5, 6, 7, 8, 9, and 10 } } @@ -309,4 +311,4 @@ class FakeRODRecordList extends AbstractList implements RODRecordLi public int compareTo(RODRecordList rodRecordList) { return this.list.get(0).getLocation().compareTo(rodRecordList.getLocation()); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/traversals/TraverseDuplicatesUnitTest.java b/java/test/org/broadinstitute/sting/gatk/traversals/TraverseDuplicatesUnitTest.java index 79d0fe059..b60e81026 100644 --- a/java/test/org/broadinstitute/sting/gatk/traversals/TraverseDuplicatesUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/traversals/TraverseDuplicatesUnitTest.java @@ -27,12 +27,14 @@ package org.broadinstitute.sting.gatk.traversals; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; @@ -52,7 +54,7 @@ public class TraverseDuplicatesUnitTest extends BaseTest { private SAMFileHeader header; - @Before + @BeforeMethod public void doBefore() { header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); @@ -67,8 +69,8 @@ public class TraverseDuplicatesUnitTest extends BaseTest { list.add(read); } Set> myPairings = obj.uniqueReadSets(list); - Assert.assertEquals(1, myPairings.size()); - Assert.assertEquals(10, myPairings.iterator().next().size()); // dup's + Assert.assertEquals(myPairings.size(), 1); + Assert.assertEquals(myPairings.iterator().next().size(), 10); // dup's } @Test @@ -81,7 +83,7 @@ public class TraverseDuplicatesUnitTest extends BaseTest { } Set> myPairing = obj.uniqueReadSets(list); - Assert.assertEquals(10, myPairing.size()); // unique + Assert.assertEquals(myPairing.size(), 10); // unique } @Test @@ -96,7 +98,7 @@ public class TraverseDuplicatesUnitTest extends BaseTest { list.add(ArtificialSAMUtils.createArtificialRead(header, String.valueOf(x), 0, x, 100)); Set> myPairing = obj.uniqueReadSets(list); - Assert.assertEquals(6, myPairing.size()); // unique + Assert.assertEquals(myPairing.size(), 6); // unique } @Test @@ -112,7 +114,7 @@ public class TraverseDuplicatesUnitTest extends BaseTest { } Set> myPairing = obj.uniqueReadSets(list); - Assert.assertEquals(1, myPairing.size()); // unique + Assert.assertEquals(myPairing.size(), 1); // unique } @Test @@ -128,7 +130,7 @@ public class TraverseDuplicatesUnitTest extends BaseTest { } Set> myPairing = obj.uniqueReadSets(list); - Assert.assertEquals(1, myPairing.size()); // unique + Assert.assertEquals(myPairing.size(), 1); // unique } @Test @@ -144,6 +146,6 @@ public class TraverseDuplicatesUnitTest extends BaseTest { } Set> myPairing = obj.uniqueReadSets(list); - Assert.assertEquals(10, myPairing.size()); // unique + Assert.assertEquals(myPairing.size(), 10); // unique } } diff --git a/java/test/org/broadinstitute/sting/gatk/traversals/TraverseReadsUnitTest.java b/java/test/org/broadinstitute/sting/gatk/traversals/TraverseReadsUnitTest.java index df8ec77f4..a44b9d44d 100755 --- a/java/test/org/broadinstitute/sting/gatk/traversals/TraverseReadsUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/traversals/TraverseReadsUnitTest.java @@ -3,7 +3,6 @@ package org.broadinstitute.sting.gatk.traversals; import net.sf.picard.reference.ReferenceSequenceFile; import net.sf.picard.reference.IndexedFastaSequenceFile; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.gatk.ReadProperties; import org.broadinstitute.sting.gatk.ReadMetrics; import org.broadinstitute.sting.gatk.datasources.providers.ShardDataProvider; import org.broadinstitute.sting.gatk.datasources.providers.ReadShardDataProvider; @@ -15,15 +14,18 @@ import org.broadinstitute.sting.gatk.datasources.simpleDataSources.SAMReaderID; import org.broadinstitute.sting.gatk.walkers.qc.CountReadsWalker; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.utils.GenomeLocParser; -import static org.junit.Assert.fail; -import org.junit.Before; -import org.junit.Test; + +import static org.testng.Assert.fail; + +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import java.util.Collections; @@ -65,12 +67,21 @@ public class TraverseReadsUnitTest extends BaseTest { private long readSize = 100000; private TraverseReads traversalEngine = null; + private IndexedFastaSequenceFile ref = null; + + @BeforeClass + public void doOnce() { + GenomeLocParserTestUtils.clearSequenceDictionary(); + ref = new IndexedFastaSequenceFile(refFile); + GenomeLocParser.setupRefContigOrdering(ref); + } + /** * This function does the setup of our parser, before each method call. *

* Called before every test case method. */ - @Before + @BeforeMethod public void doForEachTest() { output = new File("testOut.txt"); FileOutputStream out = null; @@ -95,10 +106,6 @@ public class TraverseReadsUnitTest extends BaseTest { /** Test out that we can shard the file and iterate over every read */ @Test public void testUnmappedReadCount() { - IndexedFastaSequenceFile ref = null; - ref = new IndexedFastaSequenceFile(refFile); - GenomeLocParser.setupRefContigOrdering(ref); - SAMDataSource dataSource = new SAMDataSource(bamList); ShardStrategy shardStrategy = ShardStrategyFactory.shatter(dataSource,ref,ShardStrategyFactory.SHATTER_STRATEGY.READS_EXPERIMENTAL, ref.getSequenceDictionary(), diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/ClipReadsWalkersIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/ClipReadsWalkersIntegrationTest.java index d062bd1b5..a129f8adf 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/ClipReadsWalkersIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/ClipReadsWalkersIntegrationTest.java @@ -25,7 +25,7 @@ package org.broadinstitute.sting.gatk.walkers; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.File; import java.util.Arrays; @@ -77,4 +77,4 @@ public class ClipReadsWalkersIntegrationTest extends WalkerTest { Arrays.asList("55c01ccc2e84481b22d3632cdb06c8ba", "22db22749f811d30216215e047461621")); executeTest("clipOriginalQuals", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/PileupWalkerIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/PileupWalkerIntegrationTest.java index 8ff48bc0e..b86e39f38 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/PileupWalkerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/PileupWalkerIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsWalkerUnitTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsWalkerUnitTest.java index c59730807..5990f1a06 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsWalkerUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/PrintReadsWalkerUnitTest.java @@ -1,19 +1,17 @@ package org.broadinstitute.sting.gatk.walkers; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.gatk.datasources.shards.Shard; -import org.broadinstitute.sting.gatk.datasources.providers.ShardDataProvider; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.sam.ArtificialReadsTraversal; import org.broadinstitute.sting.utils.sam.ArtificialSAMFileWriter; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMFileHeader; -import net.sf.samtools.SAMFileWriterFactory; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; /* @@ -60,7 +58,7 @@ public class PrintReadsWalkerUnitTest extends BaseTest { private ReferenceContext bases = null; //private ReferenceContext ref = new ReferenceContext() - @Before + @BeforeMethod public void before() { trav = new ArtificialReadsTraversal(); readTotal = ( ( trav.endingChr - trav.startingChr ) + 1 ) * trav.readsPerChr + trav.unMappedReads; @@ -74,7 +72,7 @@ public class PrintReadsWalkerUnitTest extends BaseTest { walker.out = writer; trav.traverse(walker, null, writer); - assertEquals(readTotal, writer.getRecords().size()); + assertEquals(writer.getRecords().size(), readTotal); } /** test that we're ok with a null read */ diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/VariantsToVCFIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/VariantsToVCFIntegrationTest.java index 2a40ea1fb..0124f45b8 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/VariantsToVCFIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/VariantsToVCFIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.List; import java.util.ArrayList; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java index a797287d2..146c1c817 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotatorIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotatorIntegrationTest.java index df9b90116..369624c6b 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotatorIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotatorIntegrationTest.java @@ -4,7 +4,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator.genomicannotator; import java.util.Arrays; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; public class GenomicAnnotatorIntegrationTest extends WalkerTest { diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/beagle/BeagleIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/beagle/BeagleIntegrationTest.java index 37173246f..71c1ba393 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/beagle/BeagleIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/beagle/BeagleIntegrationTest.java @@ -26,7 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.beagle; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -77,4 +77,4 @@ public class BeagleIntegrationTest extends WalkerTest { executeTest("testBeagleChangesSitesToRef",spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalkerIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalkerIntegrationTest.java index 8c9678983..1f3f8ebe6 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalkerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CallableLociWalkerIntegrationTest.java @@ -25,7 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.coverage; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -65,4 +65,4 @@ public class CallableLociWalkerIntegrationTest extends WalkerTest { Arrays.asList("86bd1a5f79356b3656412c4b1c60709a", "6fefb144a60b89c27293ce5ca6e10e6a")); executeTest("formatBed lots of arguments", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java index ee67aa312..4a32d6701 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/CompareCallableLociWalkerIntegrationTest.java @@ -25,7 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.coverage; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -38,4 +38,4 @@ public class CompareCallableLociWalkerIntegrationTest extends WalkerTest { WalkerTestSpec spec = new WalkerTestSpec(gatk_args, 1, Arrays.asList("70efebac55ff210bb022e9e22ed80a95")); executeTest("CompareCallableLoci Walker", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageB36IntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageB36IntegrationTest.java index 99d7efb95..8b3fc7324 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageB36IntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageB36IntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.coverage; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.File; import java.util.ArrayList; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageIntegrationTest.java index a314f9f82..69281fdad 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/coverage/DepthOfCoverageIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.coverage; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.File; import java.util.ArrayList; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceIntegrationTest.java index ae6bbdd2c..3b6819735 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.fasta; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java index 4d722f5ea..d655f86e1 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.filters; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -75,4 +75,4 @@ public class VariantFiltrationIntegrationTest extends WalkerTest { Arrays.asList("e8b80ce01f631c840336792cfbf35254")); executeTest("test genotype filter #2", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsUnitTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsUnitTest.java index be20c331e..19dec47a9 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsUnitTest.java @@ -1,9 +1,10 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; +import org.testng.Assert; import org.broadinstitute.sting.utils.genotype.DiploidGenotype; import org.broadinstitute.sting.BaseTest; -import org.junit.Test; -import org.junit.Assert; +import org.testng.annotations.Test; + import static java.lang.Math.log10; @@ -13,7 +14,7 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest { @Test public void testBasic() { logger.warn("Executing testIsBetween"); - Assert.assertEquals(DiploidGenotypePriors.HUMAN_HETEROZYGOSITY,1e-3, DELTA); + Assert.assertEquals(DELTA, DiploidGenotypePriors.HUMAN_HETEROZYGOSITY,1e-3); } @@ -30,13 +31,13 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest { testPriorsFromHet(0.5, 0.25, 0.5, 0.25); } - @Test (expected = RuntimeException.class) + @Test(expectedExceptions=RuntimeException.class) public void testPriorsFromHetFail1() { logger.warn("Executing testPriorsFromHetFail1"); testPriorsFromHet(1.0, 0, 0, 0); } - @Test (expected = RuntimeException.class) + @Test(expectedExceptions=RuntimeException.class) public void testPriorsFromHetFail2() { logger.warn("Executing testPriorsFromHetFail2"); testPriorsFromHet(-1.0, 0, 0, 0); @@ -76,7 +77,7 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest { val = log10(val); double e = array[g.ordinal()]; - Assert.assertEquals(String.format("%s should have p=%f but has p=%f", g, val, e), val, e, DELTA); + Assert.assertEquals(val, e, DELTA, String.format("%s should have p=%f but has p=%f", g, val, e)); } } @@ -103,7 +104,7 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest { for ( DiploidGenotype g : DiploidGenotype.values() ) { double val = Math.pow(10, priors.getPrior(g)); double e = array[g.ordinal()]; - Assert.assertEquals(String.format("%s should have p=%f but has p=%f", g, val, e), e, val, DELTA); + Assert.assertEquals(val, e, DELTA, String.format("%s should have p=%f but has p=%f", g, val, e)); } } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index 33fb39b66..f7bab001f 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.HashMap; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java index 5eba70f2b..4dc9f1ebb 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperPerformanceTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java index 712953e55..970c1a806 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -36,4 +36,4 @@ public class IndelRealignerIntegrationTest extends WalkerTest { Arrays.asList(md5s)); executeTest("test realigner known indels only", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java index 44ff3b0f9..948fa3e4a 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/indels/IndelRealignerPerformanceTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; @@ -39,4 +39,4 @@ public class IndelRealignerPerformanceTest extends WalkerTest { new ArrayList(0)); executeTest("testIndelRealignerWholeExome", spec2); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java index 7fd66f15d..11a4f7bd8 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java index 63b9ee969..0b6694fd9 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/indels/RealignerTargetCreatorPerformanceTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.indels; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; @@ -31,4 +31,4 @@ public class RealignerTargetCreatorPerformanceTest extends WalkerTest { new ArrayList(0)); executeTest("testRealignerTargetCreatorWholeExome", spec2); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeSegregatingAlternateAllelesIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeSegregatingAlternateAllelesIntegrationTest.java index 592fb2bd4..2ab6573d8 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeSegregatingAlternateAllelesIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/phasing/MergeSegregatingAlternateAllelesIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.phasing; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -48,4 +48,4 @@ public class MergeSegregatingAlternateAllelesIntegrationTest extends WalkerTest } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java index 1be363d32..27dfa353c 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.phasing; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -80,4 +80,4 @@ public class ReadBackedPhasingIntegrationTest extends WalkerTest { executeTest("MAX 10 het sites [TEST SIX]; require PQ >= 10; cacheWindow = 20000; has inconsistent sites", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/qc/DictionaryConsistencyIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/qc/DictionaryConsistencyIntegrationTest.java index 4945b09be..fc4e5ac66 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/qc/DictionaryConsistencyIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/qc/DictionaryConsistencyIntegrationTest.java @@ -27,7 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.qc; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.WalkerTest; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.Test; +import org.testng.annotations.Test; /** * diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupIntegrationTest.java index 34a6fb06b..093c871a1 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/qc/ValidatingPileupIntegrationTest.java @@ -1,6 +1,6 @@ package org.broadinstitute.sting.gatk.walkers.qc; -import org.junit.Test; +import org.testng.annotations.Test; import org.broadinstitute.sting.WalkerTest; import java.util.Collections; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersIntegrationTest.java index b84736829..c6b9e7abb 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersIntegrationTest.java @@ -2,7 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration; import org.broadinstitute.sting.WalkerTest; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.HashMap; import java.util.Map; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersPerformanceTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersPerformanceTest.java index 106a027bb..49dffc6f9 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersPerformanceTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/recalibration/RecalibrationWalkersPerformanceTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.recalibration; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.ArrayList; @@ -77,4 +77,4 @@ public class RecalibrationWalkersPerformanceTest extends WalkerTest { new ArrayList(0)); executeTest("testTableRecalibratorWholeExome", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/sequenom/PickSequenomProbesIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/sequenom/PickSequenomProbesIntegrationTest.java index e4e58a90f..ab1cf0812 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/sequenom/PickSequenomProbesIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/sequenom/PickSequenomProbesIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.sequenom; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalIntegrationTest.java index 929122885..c35e3e4c0 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.varianteval; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.HashMap; @@ -31,6 +31,7 @@ public class WalkerTestSpec spec = new WalkerTestSpec(withSelect(tests, "DP < 50", "DP50") + " " + extraArgs + " -o %s", 1, Arrays.asList("158ac8e6d32eb2ea1bbeebfa512965de")); executeTestParallel("testSelect1", spec); + //executeTest("testSelect1", spec); } } @@ -40,6 +41,7 @@ public class WalkerTestSpec spec = new WalkerTestSpec( withSelect(withSelect(root, "DP < 50", "DP50"), "set==\"Intersection\"", "intersection") + " " + extraArgs + " -o %s", 1, Arrays.asList("cee96f61ffa1d042fe0c63550c508ec9")); executeTestParallel("testSelect2", spec); + //executeTest("testSelect2", spec); } @Test @@ -50,6 +52,7 @@ public class 1, Arrays.asList("7e9ce1b26cdeaa50705f5de163847638")); executeTestParallel("testVEGenotypeConcordance" + vcfFile, spec); + //executeTest("testVEGenotypeConcordance" + vcfFile, spec); } } @@ -68,6 +71,7 @@ public class 1, // just one output file Arrays.asList(md5)); executeTestParallel("testVESimple", spec); + //executeTest("testVESimple", spec); } } } @@ -93,6 +97,7 @@ public class 1, // just one output file Arrays.asList(md5)); executeTestParallel("testVEComplex", spec); + //executeTest("testVEComplex", spec); } } } @@ -110,6 +115,7 @@ public class WalkerTestSpec spec = new WalkerTestSpec(vecmd, 1, Arrays.asList(md5)); executeTestParallel("testVEGenomicallyAnnotated", spec); + //executeTest("testVEGenomicallyAnnotated", spec); } @Test @@ -120,6 +126,7 @@ public class 2, Arrays.asList("6b97a019402b3984fead9a4e8b7c7c2a", "989bc30dea6c8a4cf771cd1b9fdab488")); executeTestParallel("testVEWriteVCF", spec); + //executeTest("testVEWriteVCF", spec); } } @@ -128,6 +135,7 @@ public class String extraArgs = "-T VariantEval -R "+b36KGReference+" -o %s -E GenotypeConcordance -B:evalYRI,VCF /humgen/gsa-hpprojects/GATK/data/Validation_Data/yri.trio.gatk.ug.very.few.lines.vcf -B:compYRI,VCF /humgen/gsa-hpprojects/GATK/data/Validation_Data/yri.trio.gatk.fake.genotypes.ac.test.vcf -reportType CSV"; WalkerTestSpec spec = new WalkerTestSpec(extraArgs,1,Arrays.asList("25a681855cb26e7380fbf1a93de0a41f")); executeTestParallel("testACDiscordanceAtAC1EvalAC2Comp",spec); + //executeTest("testACDiscordanceAtAC1EvalAC2Comp",spec); } private static String withSelect(String cmd, String select, String name) { diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrationWalkersIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrationWalkersIntegrationTest.java index 7a5ea4ab6..9e742a02d 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrationWalkersIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrationWalkersIntegrationTest.java @@ -2,7 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.variantrecalibration; import org.broadinstitute.sting.WalkerTest; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.*; import java.io.File; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java index ac3002fc9..9b6aae5e4 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsIntegrationTest.java @@ -25,7 +25,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.File; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java index 62835532f..d81a8d8fb 100644 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/CombineVariantsUnitTest.java @@ -3,10 +3,11 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broad.tribble.vcf.VCFCodec; import org.broad.tribble.vcf.VCFHeader; import org.broad.tribble.vcf.VCFHeaderLine; +import org.testng.Assert; import org.broadinstitute.sting.utils.genotype.vcf.VCFHeaderUnitTest; import org.broadinstitute.sting.utils.vcf.VCFUtils; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; @@ -65,7 +66,7 @@ public class CombineVariantsUnitTest { for (String str : headerStr) headerFields.add(str); VCFHeader head = (VCFHeader)codec.createHeader(headerFields,"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"); - Assert.assertEquals(headerStr.length /* for the # line */,head.getMetaData().size()); + Assert.assertEquals(head.getMetaData().size(), headerStr.length /* for the # line */); return head; } @@ -77,10 +78,10 @@ public class CombineVariantsUnitTest { headers.add(one); headers.add(two); Set lines = VCFUtils.smartMergeHeaders(headers, null); - Assert.assertEquals(VCFHeaderUnitTest.VCF4headerStrings.length,lines.size()); + Assert.assertEquals(lines.size(), VCFHeaderUnitTest.VCF4headerStrings.length); } - @Test(expected=IllegalStateException.class) + @Test(expectedExceptions=IllegalStateException.class) public void testHeadersInfoDifferentValues() { VCFHeader one = createHeader(VCFHeaderUnitTest.VCF4headerStrings); VCFHeader two = createHeader(VCF4headerStringsBrokenInfo); @@ -88,7 +89,7 @@ public class CombineVariantsUnitTest { headers.add(one); headers.add(two); Set lines = VCFUtils.smartMergeHeaders(headers, null); - Assert.assertEquals(VCFHeaderUnitTest.VCF4headerStrings.length,lines.size()); + Assert.assertEquals(lines.size(), VCFHeaderUnitTest.VCF4headerStrings.length); } @Test @@ -99,6 +100,6 @@ public class CombineVariantsUnitTest { headers.add(one); headers.add(two); Set lines = VCFUtils.smartMergeHeaders(headers, null); - Assert.assertEquals(VCFHeaderUnitTest.VCF4headerStrings.length,lines.size()); + Assert.assertEquals(lines.size(), VCFHeaderUnitTest.VCF4headerStrings.length); } } diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariantsIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariantsIntegrationTest.java index 2cd588003..737a5910c 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariantsIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/LiftoverVariantsIntegrationTest.java @@ -26,7 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -52,4 +52,4 @@ public class LiftoverVariantsIntegrationTest extends WalkerTest { Arrays.asList("22d4cd78d72da55f2423b9ab06f467b2")); executeTest("test hg18 to hg19, unsorted", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java index 6180eb99f..40b8ff8db 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java index b50fd09a4..61cd3c8fe 100755 --- a/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/ValidateVariantsIntegrationTest.java @@ -27,7 +27,7 @@ package org.broadinstitute.sting.gatk.walkers.variantutils; import org.broadinstitute.sting.WalkerTest; import org.broadinstitute.sting.utils.exceptions.UserException; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -113,4 +113,4 @@ public class ValidateVariantsIntegrationTest extends WalkerTest { executeTest("test bad alt allele", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/ValidateRODForReadsIntegrationTest.java b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/ValidateRODForReadsIntegrationTest.java index cf243c86e..c17b3ea26 100644 --- a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/ValidateRODForReadsIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/ValidateRODForReadsIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.oneoffprojects.walkers; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/HLAcaller/HLACallerIntegrationTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/HLAcaller/HLACallerIntegrationTest.java index 95b2ddcd0..9cacba212 100755 --- a/java/test/org/broadinstitute/sting/playground/gatk/walkers/HLAcaller/HLACallerIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/HLAcaller/HLACallerIntegrationTest.java @@ -26,7 +26,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.HLAcaller; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; @@ -58,4 +58,4 @@ public class HLACallerIntegrationTest extends WalkerTest { Arrays.asList("f9931b378bde213e71fca6ecaa24b48b")); executeTest("test HLACaller", spec); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/duplicates/DuplicatesWalkersIntegrationTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/duplicates/DuplicatesWalkersIntegrationTest.java index e98dd13bf..12bda2af8 100755 --- a/java/test/org/broadinstitute/sting/playground/gatk/walkers/duplicates/DuplicatesWalkersIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/duplicates/DuplicatesWalkersIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.duplicates; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.io.File; import java.util.Arrays; @@ -37,4 +37,4 @@ public class DuplicatesWalkersIntegrationTest extends WalkerTest { @Test public void testIntervalCombine() { testCombiner("testIntervalCombine", "-L chr1:6,527,154-6,528,292 -maxQ 50", "d41d8cd98f00b204e9800998ecf8427e", "4541f57820637039bc2f5a97bcaadfe4"); } @Test public void testIntervalCombineQ60() { testCombiner("testIntervalCombine", "-L chr1:6,527,154-6,528,292 -maxQ 60", "d41d8cd98f00b204e9800998ecf8427e", "8c0350c0a697e4083aab6ead3f404de4"); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/playground/gatk/walkers/validation/RodSystemValidationIntegrationTest.java b/java/test/org/broadinstitute/sting/playground/gatk/walkers/validation/RodSystemValidationIntegrationTest.java index 44654c828..a6ff3a438 100644 --- a/java/test/org/broadinstitute/sting/playground/gatk/walkers/validation/RodSystemValidationIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/playground/gatk/walkers/validation/RodSystemValidationIntegrationTest.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.playground.gatk.walkers.validation; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; diff --git a/java/test/org/broadinstitute/sting/utils/BaseUtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/BaseUtilsUnitTest.java index 821ad2c59..2f5aea951 100755 --- a/java/test/org/broadinstitute/sting/utils/BaseUtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/BaseUtilsUnitTest.java @@ -1,13 +1,14 @@ package org.broadinstitute.sting.utils; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Test; -import org.junit.BeforeClass; -import org.junit.Assert; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeClass; + public class BaseUtilsUnitTest extends BaseTest { @BeforeClass - public static void init() { } + public void init() { } @Test public void testMostFrequentBaseFraction() { diff --git a/java/test/org/broadinstitute/sting/utils/GenomeLocParserUnitTest.java b/java/test/org/broadinstitute/sting/utils/GenomeLocParserUnitTest.java index 293c37cdd..ccdb57a87 100644 --- a/java/test/org/broadinstitute/sting/utils/GenomeLocParserUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/GenomeLocParserUnitTest.java @@ -2,15 +2,15 @@ package org.broadinstitute.sting.utils; import net.sf.samtools.SAMFileHeader; +import net.sf.samtools.SAMSequenceDictionary; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.BeforeClass; -import org.junit.Test; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * @author aaron @@ -20,14 +20,21 @@ import org.junit.Test; * Test out the functionality of the new genome loc parser */ public class GenomeLocParserUnitTest extends BaseTest { - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testUnsetupException() { + SAMSequenceDictionary contigInfoCache = GenomeLocParser.contigInfo; GenomeLocParser.contigInfo = null; - GenomeLocParser.createGenomeLoc(0, 0, 0); + try { + GenomeLocParser.createGenomeLoc(0, 0, 0); + } + finally { + GenomeLocParser.contigInfo = contigInfoCache; + } } @BeforeClass - public static void init() { + public void init() { + GenomeLocParserTestUtils.clearSequenceDictionary(); SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 10); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); } @@ -43,15 +50,15 @@ public class GenomeLocParserUnitTest extends BaseTest { assertTrue(GenomeLocParser.hasKnownContigOrdering()); } - @Test(expected = RuntimeException.class) + @Test(expectedExceptions=RuntimeException.class) public void testGetContigIndex() { - assertEquals(-1, GenomeLocParser.getContigIndex("blah",true)); // should not be in the reference + assertEquals(GenomeLocParser.getContigIndex("blah",true), -1); // should not be in the reference } @Test public void testGetContigIndexValid() { SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 10); - assertEquals(0, GenomeLocParser.getContigIndex("chr1",true)); // should be in the reference + assertEquals(GenomeLocParser.getContigIndex("chr1",true), 0); // should be in the reference } @Test @@ -63,10 +70,10 @@ public class GenomeLocParserUnitTest extends BaseTest { @Test public void testGetContigInfoKnownContig() { SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 10); - assertEquals("chr1".compareTo(GenomeLocParser.getContigInfo("chr1").getSequenceName()), 0); // should be in the reference + assertEquals(0, "chr1".compareTo(GenomeLocParser.getContigInfo("chr1").getSequenceName())); // should be in the reference } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testParseBadString() { GenomeLocParser.parseGenomeLoc("Bad:0-1"); } @@ -74,106 +81,106 @@ public class GenomeLocParserUnitTest extends BaseTest { @Test public void testParseGoodString() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1-100"); - assertEquals(loc.getContigIndex(), 0); - assertEquals(100, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 100); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc1() { GenomeLoc loc = GenomeLocParser.createGenomeLoc("chr1", 1, 100); - assertEquals(loc.getContigIndex(), 0); - assertEquals(100, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 100); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc1point5() { // in honor of VAAL! GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1"); - assertEquals(loc.getContigIndex(), 0); - assertEquals(1, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 1); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc2() { GenomeLoc loc = GenomeLocParser.createGenomeLoc(0, 1, 100); - assertEquals(loc.getContigIndex(), 0); - assertEquals(100, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 100); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc3() { GenomeLoc loc = GenomeLocParser.createGenomeLoc(0, 1); - assertEquals(loc.getContigIndex(), 0); - assertEquals(1, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 1); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc4() { GenomeLoc loc = GenomeLocParser.createGenomeLoc("chr1", 1); - assertEquals(loc.getContigIndex(), 0); - assertEquals(1, loc.getStop()); - assertEquals(1, loc.getStart()); + assertEquals(0, loc.getContigIndex()); + assertEquals(loc.getStop(), 1); + assertEquals(loc.getStart(), 1); } @Test public void testCreateGenomeLoc5() { GenomeLoc loc = GenomeLocParser.createGenomeLoc(0, 1, 100); GenomeLoc copy = GenomeLocParser.createGenomeLoc(loc); - assertEquals(copy.getContigIndex(), 0); - assertEquals(100, copy.getStop()); - assertEquals(1, copy.getStart()); + assertEquals(0, copy.getContigIndex()); + assertEquals(copy.getStop(), 100); + assertEquals(copy.getStart(), 1); } @Test public void testGenomeLocPlusSign() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1+"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } @Test public void testGenomeLocParseOnlyChrome() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testGenomeLocParseOnlyBadChrome() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr12"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testGenomeLocBad() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1-"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testGenomeLocBad2() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1-500-0"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } - @Test(expected = ReviewedStingException.class) + @Test(expectedExceptions=ReviewedStingException.class) public void testGenomeLocBad3() { GenomeLoc loc = GenomeLocParser.parseGenomeLoc("chr1:1--0"); - assertEquals(0, loc.getContigIndex()); - assertEquals(10, loc.getStop()); // the size - assertEquals(1, loc.getStart()); + assertEquals(loc.getContigIndex(), 0); + assertEquals(loc.getStop(), 10); // the size + assertEquals(loc.getStart(), 1); } // test out the validating methods diff --git a/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java b/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java index f722e1a42..fc7099b7b 100755 --- a/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/GenomeLocSortedSetUnitTest.java @@ -4,10 +4,13 @@ import net.sf.samtools.SAMFileHeader; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import java.util.Iterator; import java.util.Arrays; @@ -45,10 +48,15 @@ public class GenomeLocSortedSetUnitTest extends BaseTest { private static final int STARTING_CHROMOSOME = 1; private static final int CHROMOSOME_SIZE = 1000; - @Before + @BeforeClass public void setup() { + GenomeLocParserTestUtils.clearSequenceDictionary(); GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()); - mSortedSet = new GenomeLocSortedSet(); + } + + @BeforeMethod + public void initializeSortedSet() { + mSortedSet = new GenomeLocSortedSet(); } @Test @@ -81,8 +89,8 @@ public class GenomeLocSortedSetUnitTest extends BaseTest { } - @Test(expected = ReviewedStingException.class) - public void testAddDupplicate() { + @Test(expectedExceptions=ReviewedStingException.class) + public void testAddDuplicate() { assertTrue(mSortedSet.size() == 0); GenomeLoc g = GenomeLocParser.createGenomeLoc(1, 0, 0); mSortedSet.add(g); @@ -186,9 +194,9 @@ public class GenomeLocSortedSetUnitTest extends BaseTest { // logger.debug("Exclude " + toExclude); // logger.debug("Remaining " + remaining); - assertEquals(20, mSortedSet.coveredSize()); - assertEquals(9, toExclude.coveredSize()); - assertEquals(11, remaining.coveredSize()); + assertEquals(mSortedSet.coveredSize(), 20); + assertEquals(toExclude.coveredSize(), 9); + assertEquals(remaining.coveredSize(), 11); Iterator it = remaining.iterator(); GenomeLoc p1 = it.next(); diff --git a/java/test/org/broadinstitute/sting/utils/GenomeLocUnitTest.java b/java/test/org/broadinstitute/sting/utils/GenomeLocUnitTest.java index 08c0d92a2..27e694bf4 100644 --- a/java/test/org/broadinstitute/sting/utils/GenomeLocUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/GenomeLocUnitTest.java @@ -4,9 +4,10 @@ package org.broadinstitute.sting.utils; // the imports for unit testing. -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; import java.io.File; @@ -22,8 +23,9 @@ public class GenomeLocUnitTest extends BaseTest { private static ReferenceSequenceFile seq; @BeforeClass - public static void init() throws FileNotFoundException { + public void init() throws FileNotFoundException { // sequence + GenomeLocParserTestUtils.clearSequenceDictionary(); seq = new IndexedFastaSequenceFile(new File(hg18Reference)); GenomeLocParser.setupRefContigOrdering(seq); } @@ -49,17 +51,17 @@ public class GenomeLocUnitTest extends BaseTest { public void testContigIndex() { logger.warn("Executing testContigIndex"); GenomeLoc locOne = GenomeLocParser.createGenomeLoc("chr1",1,1); - Assert.assertEquals(locOne.getContigIndex(), 1); - Assert.assertEquals(locOne.getContig(), "chr1"); + Assert.assertEquals(1, locOne.getContigIndex()); + Assert.assertEquals("chr1", locOne.getContig()); GenomeLoc locX = GenomeLocParser.createGenomeLoc("chrX",1,1); - Assert.assertEquals(locX.getContigIndex(), 23); - Assert.assertEquals(locX.getContig(), "chrX"); + Assert.assertEquals(23, locX.getContigIndex()); + Assert.assertEquals("chrX", locX.getContig()); GenomeLoc locNumber = GenomeLocParser.createGenomeLoc(1,1,1); - Assert.assertEquals(locNumber.getContigIndex(), 1); - Assert.assertEquals(locNumber.getContig(), "chr1"); - Assert.assertEquals(locOne.compareTo(locNumber), 0); + Assert.assertEquals(1, locNumber.getContigIndex()); + Assert.assertEquals("chr1", locNumber.getContig()); + Assert.assertEquals(0, locOne.compareTo(locNumber)); } @@ -69,16 +71,16 @@ public class GenomeLocUnitTest extends BaseTest { GenomeLoc twoOne = GenomeLocParser.createGenomeLoc("chr2", 1); GenomeLoc twoFive = GenomeLocParser.createGenomeLoc("chr2", 5); GenomeLoc twoOtherFive = GenomeLocParser.createGenomeLoc("chr2", 5); - Assert.assertEquals(0, twoFive.compareTo(twoOtherFive)); + Assert.assertEquals(twoFive.compareTo(twoOtherFive), 0); - Assert.assertEquals(-1, twoOne.compareTo(twoFive)); - Assert.assertEquals(1, twoFive.compareTo(twoOne)); + Assert.assertEquals(twoOne.compareTo(twoFive), -1); + Assert.assertEquals(twoFive.compareTo(twoOne), 1); GenomeLoc oneOne = GenomeLocParser.createGenomeLoc("chr1", 5); - Assert.assertEquals(-1, oneOne.compareTo(twoOne)); - Assert.assertEquals(1, twoOne.compareTo(oneOne)); + Assert.assertEquals(oneOne.compareTo(twoOne), -1); + Assert.assertEquals(twoOne.compareTo(oneOne), 1); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/utils/MathUtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/MathUtilsUnitTest.java index d74e09128..af652ff06 100755 --- a/java/test/org/broadinstitute/sting/utils/MathUtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/MathUtilsUnitTest.java @@ -25,14 +25,13 @@ package org.broadinstitute.sting.utils; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.utils.MathUtils; -import java.io.File; import java.util.List; import java.util.ArrayList; import java.util.Collections; @@ -42,7 +41,7 @@ import java.util.Collections; */ public class MathUtilsUnitTest extends BaseTest { @BeforeClass - public static void init() { } + public void init() { } /** * Tests that we get the right values from the binomial distribution @@ -134,9 +133,9 @@ public class MathUtilsUnitTest extends BaseTest { for ( int i = 0 ; i < numbers.length ; i++ ) r.add((double)numbers[i]); - Assert.assertEquals(r.observationCount(),(long)numbers.length); + Assert.assertEquals((long)numbers.length, r.observationCount()); Assert.assertTrue(r.mean()- 3224.625 < 2e-10 ); Assert.assertTrue(r.stddev()-9072.6515881128 < 2e-10); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/utils/PathUtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/PathUtilsUnitTest.java index 88eea4604..ad90ffbf6 100755 --- a/java/test/org/broadinstitute/sting/utils/PathUtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/PathUtilsUnitTest.java @@ -1,16 +1,17 @@ package org.broadinstitute.sting.utils; import org.broadinstitute.sting.BaseTest; +import org.testng.Assert; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + import java.io.File; public class PathUtilsUnitTest extends BaseTest { @BeforeClass - public static void init() { } + public void init() { } /** * Tests that we can successfully refresh a volume diff --git a/java/test/org/broadinstitute/sting/utils/ReservoirDownsamplerUnitTest.java b/java/test/org/broadinstitute/sting/utils/ReservoirDownsamplerUnitTest.java index 636bddbcb..76dd5d341 100644 --- a/java/test/org/broadinstitute/sting/utils/ReservoirDownsamplerUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/ReservoirDownsamplerUnitTest.java @@ -1,16 +1,13 @@ package org.broadinstitute.sting.utils; -import org.junit.Test; -import org.broadinstitute.sting.utils.sam.AlignmentStartComparator; +import org.testng.Assert; +import org.testng.annotations.Test; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.broadinstitute.sting.gatk.iterators.NullSAMIterator; import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMFileHeader; import java.util.*; -import junit.framework.Assert; - /** * Basic tests to prove the integrity of the reservoir downsampler. * At the moment, always run tests on SAM records as that's the task @@ -26,7 +23,7 @@ public class ReservoirDownsamplerUnitTest { @Test public void testEmptyIterator() { ReservoirDownsampler downsampler = new ReservoirDownsampler(1); - Assert.assertTrue("Downsampler is not empty but should be.",downsampler.isEmpty()); + Assert.assertTrue(downsampler.isEmpty(),"Downsampler is not empty but should be."); } @Test @@ -35,10 +32,10 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(1); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); Collection batchedReads = downsampler.getDownsampledContents(); - Assert.assertEquals("Downsampler is returning the wrong number of reads",1,batchedReads.size()); - Assert.assertSame("Downsampler is returning an incorrect read",reads.get(0),batchedReads.iterator().next()); + Assert.assertEquals(batchedReads.size(), 1, "Downsampler is returning the wrong number of reads"); + Assert.assertSame(batchedReads.iterator().next(), reads.get(0), "Downsampler is returning an incorrect read"); } @Test @@ -47,10 +44,10 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(5); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); Collection batchedReads = downsampler.getDownsampledContents(); - Assert.assertEquals("Downsampler is returning the wrong number of reads",1,batchedReads.size()); - Assert.assertSame("Downsampler is returning an incorrect read",reads.get(0),batchedReads.iterator().next()); + Assert.assertEquals(batchedReads.size(), 1, "Downsampler is returning the wrong number of reads"); + Assert.assertSame(batchedReads.iterator().next(), reads.get(0), "Downsampler is returning an incorrect read"); } @@ -63,13 +60,13 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(5); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); List batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",3,batchedReads.size()); + Assert.assertEquals(batchedReads.size(), 3, "Downsampler is returning the wrong number of reads"); - Assert.assertSame("Downsampler read 1 is incorrect",reads.get(0),batchedReads.get(0)); - Assert.assertSame("Downsampler read 2 is incorrect",reads.get(1),batchedReads.get(1)); - Assert.assertSame("Downsampler read 3 is incorrect",reads.get(2),batchedReads.get(2)); + Assert.assertSame(batchedReads.get(0), reads.get(0), "Downsampler read 1 is incorrect"); + Assert.assertSame(batchedReads.get(1), reads.get(1), "Downsampler read 2 is incorrect"); + Assert.assertSame(batchedReads.get(2), reads.get(2), "Downsampler read 3 is incorrect"); } @Test @@ -83,16 +80,16 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(5); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); List batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",5,batchedReads.size()); - Assert.assertSame("Downsampler is returning an incorrect read",reads.get(0),batchedReads.iterator().next()); + Assert.assertEquals(batchedReads.size(), 5, "Downsampler is returning the wrong number of reads"); + Assert.assertSame(batchedReads.iterator().next(), reads.get(0), "Downsampler is returning an incorrect read"); - Assert.assertSame("Downsampler read 1 is incorrect",reads.get(0),batchedReads.get(0)); - Assert.assertSame("Downsampler read 2 is incorrect",reads.get(1),batchedReads.get(1)); - Assert.assertSame("Downsampler read 3 is incorrect",reads.get(2),batchedReads.get(2)); - Assert.assertSame("Downsampler read 4 is incorrect",reads.get(3),batchedReads.get(3)); - Assert.assertSame("Downsampler read 5 is incorrect",reads.get(4),batchedReads.get(4)); + Assert.assertSame(batchedReads.get(0), reads.get(0), "Downsampler read 1 is incorrect"); + Assert.assertSame(batchedReads.get(1), reads.get(1), "Downsampler read 2 is incorrect"); + Assert.assertSame(batchedReads.get(2), reads.get(2), "Downsampler read 3 is incorrect"); + Assert.assertSame(batchedReads.get(3), reads.get(3), "Downsampler read 4 is incorrect"); + Assert.assertSame(batchedReads.get(4), reads.get(4), "Downsampler read 5 is incorrect"); } @Test @@ -104,9 +101,9 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(0); downsampler.addAll(reads); - Assert.assertTrue("Downsampler isn't empty but should be",downsampler.isEmpty()); + Assert.assertTrue(downsampler.isEmpty(),"Downsampler isn't empty but should be"); List batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",0,batchedReads.size()); + Assert.assertEquals(batchedReads.size(), 0, "Downsampler is returning the wrong number of reads"); } @Test @@ -120,10 +117,10 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(1); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); List batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",1,batchedReads.size()); - Assert.assertTrue("Downsampler is returning a bad read.",reads.contains(batchedReads.get(0))) ; + Assert.assertEquals(batchedReads.size(), 1, "Downsampler is returning the wrong number of reads"); + Assert.assertTrue(reads.contains(batchedReads.get(0)),"Downsampler is returning a bad read."); } @Test @@ -133,10 +130,10 @@ public class ReservoirDownsamplerUnitTest { ReservoirDownsampler downsampler = new ReservoirDownsampler(5); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); List batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",1,batchedReads.size()); - Assert.assertEquals("Downsampler is returning an incorrect read.",reads.get(0),batchedReads.get(0)); + Assert.assertEquals(batchedReads.size(), 1, "Downsampler is returning the wrong number of reads"); + Assert.assertEquals(batchedReads.get(0), reads.get(0), "Downsampler is returning an incorrect read."); reads.clear(); reads.add(ArtificialSAMUtils.createArtificialRead(header,"read2",0,2,76)); @@ -145,11 +142,11 @@ public class ReservoirDownsamplerUnitTest { downsampler.clear(); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",2,batchedReads.size()); - Assert.assertEquals("Downsampler is returning an incorrect read.",reads.get(0),batchedReads.get(0)); - Assert.assertEquals("Downsampler is returning an incorrect read.",reads.get(1),batchedReads.get(1)); + Assert.assertEquals(batchedReads.size(), 2, "Downsampler is returning the wrong number of reads"); + Assert.assertEquals(batchedReads.get(0), reads.get(0), "Downsampler is returning an incorrect read."); + Assert.assertEquals(batchedReads.get(1), reads.get(1), "Downsampler is returning an incorrect read."); reads.clear(); reads.add(ArtificialSAMUtils.createArtificialRead(header,"read4",0,3,76)); @@ -158,11 +155,11 @@ public class ReservoirDownsamplerUnitTest { downsampler.clear(); downsampler.addAll(reads); - Assert.assertFalse("Downsampler is empty but shouldn't be",downsampler.isEmpty()); + Assert.assertFalse(downsampler.isEmpty(),"Downsampler is empty but shouldn't be"); batchedReads = new ArrayList(downsampler.getDownsampledContents()); - Assert.assertEquals("Downsampler is returning the wrong number of reads",2,batchedReads.size()); - Assert.assertEquals("Downsampler is returning an incorrect read.",reads.get(0),batchedReads.get(0)); - Assert.assertEquals("Downsampler is returning an incorrect read.",reads.get(1),batchedReads.get(1)); + Assert.assertEquals(batchedReads.size(), 2, "Downsampler is returning the wrong number of reads"); + Assert.assertEquals(batchedReads.get(0), reads.get(0), "Downsampler is returning an incorrect read."); + Assert.assertEquals(batchedReads.get(1), reads.get(1), "Downsampler is returning an incorrect read."); } } diff --git a/java/test/org/broadinstitute/sting/utils/UtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/UtilsUnitTest.java index 19847ca15..d6bec2d71 100644 --- a/java/test/org/broadinstitute/sting/utils/UtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/UtilsUnitTest.java @@ -24,9 +24,9 @@ package org.broadinstitute.sting.utils; -import junit.framework.Assert; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.LinkedHashMap; import java.util.Map; @@ -43,21 +43,21 @@ public class UtilsUnitTest extends BaseTest { @Test public void testDupStringNoChars() { String duped = Utils.dupString('a',0); - Assert.assertEquals("dupString did not produce zero-length string", 0, duped.length()); + Assert.assertEquals(duped.length(), 0, "dupString did not produce zero-length string"); } @Test public void testDupStringOneChar() { String duped = Utils.dupString('b',1); - Assert.assertEquals("dupString did not produce single character string", 1, duped.length()); - Assert.assertEquals("dupString character was incorrect", 'b', duped.charAt(0)); + Assert.assertEquals(duped.length(), 1, "dupString did not produce single character string"); + Assert.assertEquals(duped.charAt(0), 'b', "dupString character was incorrect"); } @Test public void testDupStringMultiChar() { String duped = Utils.dupString('c',5); - Assert.assertEquals("dupString did not produce five character string", 5, duped.length()); - Assert.assertEquals("dupString string was incorrect", "ccccc", duped); + Assert.assertEquals(duped.length(), 5, "dupString did not produce five character string"); + Assert.assertEquals(duped,"ccccc","dupString string was incorrect"); } @Test diff --git a/java/test/org/broadinstitute/sting/utils/bed/BedParserUnitTest.java b/java/test/org/broadinstitute/sting/utils/bed/BedParserUnitTest.java index 2599eedaa..364c11351 100644 --- a/java/test/org/broadinstitute/sting/utils/bed/BedParserUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/bed/BedParserUnitTest.java @@ -1,11 +1,13 @@ package org.broadinstitute.sting.utils.bed; +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLoc; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + import java.io.File; import java.util.List; @@ -19,7 +21,8 @@ public class BedParserUnitTest extends BaseTest { private File bedFile = new File("testdata/sampleBedFile.bed"); @BeforeClass - public static void beforeTests() { + public void beforeTests() { + GenomeLocParserTestUtils.clearSequenceDictionary(); seq = new IndexedFastaSequenceFile(new File(b36KGReference)); GenomeLocParser.setupRefContigOrdering(seq); } @@ -28,29 +31,29 @@ public class BedParserUnitTest extends BaseTest { public void testLoadBedFile() { BedParser parser = new BedParser(bedFile); List location = parser.getLocations(); - Assert.assertEquals(4, location.size()); + Assert.assertEquals(location.size(), 4); } @Test public void testBedParsing() { BedParser parser = new BedParser(bedFile); List location = parser.getLocations(); - Assert.assertEquals(4, location.size()); + Assert.assertEquals(location.size(), 4); Assert.assertTrue(location.get(0).getContig().equals("20")); Assert.assertTrue(location.get(1).getContig().equals("20")); Assert.assertTrue(location.get(2).getContig().equals("22")); Assert.assertTrue(location.get(3).getContig().equals("22")); // now check the the start positions - Assert.assertEquals(1, location.get(0).getStart()); - Assert.assertEquals(1002, location.get(1).getStart()); - Assert.assertEquals(1001, location.get(2).getStart()); - Assert.assertEquals(2001, location.get(3).getStart()); + Assert.assertEquals(location.get(0).getStart(), 1); + Assert.assertEquals(location.get(1).getStart(), 1002); + Assert.assertEquals(location.get(2).getStart(), 1001); + Assert.assertEquals(location.get(3).getStart(), 2001); // now check the the stop positions - Assert.assertEquals(999, location.get(0).getStop()); - Assert.assertEquals(2000, location.get(1).getStop()); - Assert.assertEquals(5000, location.get(2).getStop()); - Assert.assertEquals(6000, location.get(3).getStop()); + Assert.assertEquals(location.get(0).getStop(), 999); + Assert.assertEquals(location.get(1).getStop(), 2000); + Assert.assertEquals(location.get(2).getStop(), 5000); + Assert.assertEquals(location.get(3).getStop(), 6000); } } diff --git a/java/test/org/broadinstitute/sting/utils/collections/ExpandingArrayListUnitTest.java b/java/test/org/broadinstitute/sting/utils/collections/ExpandingArrayListUnitTest.java index d84e8f504..f4320fccf 100755 --- a/java/test/org/broadinstitute/sting/utils/collections/ExpandingArrayListUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/collections/ExpandingArrayListUnitTest.java @@ -29,11 +29,12 @@ package org.broadinstitute.sting.utils.collections; // the imports for unit testing. -import org.junit.Assert; -import org.junit.Test; -import org.junit.Before; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; + import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.utils.collections.ExpandingArrayList; import java.util.Arrays; @@ -43,7 +44,7 @@ import java.util.Arrays; public class ExpandingArrayListUnitTest extends BaseTest { ExpandingArrayList empty, initCap10, hasOne, hasTen; - @Before + @BeforeMethod public void before() { empty = new ExpandingArrayList(); @@ -60,10 +61,10 @@ public class ExpandingArrayListUnitTest extends BaseTest { public void testBasicSizes() { logger.warn("Executing testBasicSizes"); - Assert.assertEquals(empty.size(), 0); - Assert.assertEquals(initCap10.size(), 0); - Assert.assertEquals(hasOne.size(), 1); - Assert.assertEquals(hasTen.size(), 10); + Assert.assertEquals(0, empty.size()); + Assert.assertEquals(0, initCap10.size()); + Assert.assertEquals(1, hasOne.size()); + Assert.assertEquals(10, hasTen.size()); } @Test @@ -71,7 +72,7 @@ public class ExpandingArrayListUnitTest extends BaseTest { logger.warn("Executing testTenElements"); for ( int i = 0; i < 10; i++ ) { - Assert.assertEquals((int)hasTen.get(i), i+1); + Assert.assertEquals(i+1, (int)hasTen.get(i)); } } @@ -80,12 +81,12 @@ public class ExpandingArrayListUnitTest extends BaseTest { logger.warn("Executing testSettingTenElements"); for ( int i = 0; i < 10; i++ ) { - Assert.assertEquals((int)hasTen.set(i, 2*i), i+1); + Assert.assertEquals(i+1, (int)hasTen.set(i, 2*i)); } - Assert.assertEquals(hasTen.size(), 10); + Assert.assertEquals(10, hasTen.size()); for ( int i = 0; i < 10; i++ ) { - Assert.assertEquals((int)hasTen.get(i), 2*i); + Assert.assertEquals(2*i, (int)hasTen.get(i)); } } @@ -93,74 +94,74 @@ public class ExpandingArrayListUnitTest extends BaseTest { public void testAdd() { logger.warn("Executing testAdd"); - Assert.assertEquals(empty.size(), 0); + Assert.assertEquals(0, empty.size()); empty.add(1); - Assert.assertEquals(empty.size(), 1); - Assert.assertEquals((int)empty.get(0), 1); + Assert.assertEquals(1, empty.size()); + Assert.assertEquals(1, (int)empty.get(0)); empty.add(2); - Assert.assertEquals(empty.size(), 2); - Assert.assertEquals((int)empty.get(1), 2); + Assert.assertEquals(2, empty.size()); + Assert.assertEquals(2, (int)empty.get(1)); } @Test public void testSet1() { logger.warn("Executing testSet1"); - Assert.assertEquals(empty.size(), 0); + Assert.assertEquals(0, empty.size()); empty.set(0, 1); - Assert.assertEquals(empty.size(), 1); - Assert.assertEquals((int)empty.get(0), 1); + Assert.assertEquals(1, empty.size()); + Assert.assertEquals(1, (int)empty.get(0)); empty.set(1, 2); - Assert.assertEquals(empty.size(), 2); - Assert.assertEquals((int)empty.get(1), 2); + Assert.assertEquals(2, empty.size()); + Assert.assertEquals(2, (int)empty.get(1)); // doesn't expand empty.set(0, 3); - Assert.assertEquals(empty.size(), 2); - Assert.assertEquals((int)empty.get(0), 3); + Assert.assertEquals(2, empty.size()); + Assert.assertEquals(3, (int)empty.get(0)); } @Test public void testSetExpanding() { logger.warn("Executing testSetExpanding"); - Assert.assertEquals(empty.size(), 0); + Assert.assertEquals(0, empty.size()); empty.set(3, 1); - Assert.assertEquals(empty.size(), 4); + Assert.assertEquals(4, empty.size()); Assert.assertEquals(empty.get(0), null); Assert.assertEquals(empty.get(1), null); Assert.assertEquals(empty.get(2), null); - Assert.assertEquals((int)empty.get(3), 1); + Assert.assertEquals(1, (int)empty.get(3)); } @Test public void testSetExpandingReset() { logger.warn("Executing testSetExpandingReset"); - Assert.assertEquals(empty.size(), 0); + Assert.assertEquals(0, empty.size()); empty.set(3, 3); empty.set(2, 2); empty.set(1, 1); empty.set(0, 0); - Assert.assertEquals(empty.size(), 4); + Assert.assertEquals(4, empty.size()); for ( int i = 0; i < 4; i++ ) - Assert.assertEquals((int)empty.get(i), i); + Assert.assertEquals(i, (int)empty.get(i)); } @Test public void testSetExpandingBig() { logger.warn("Executing testSetExpandingBig"); - Assert.assertEquals(empty.size(), 0); + Assert.assertEquals(0, empty.size()); empty.set(1000, 1000); - Assert.assertEquals(empty.size(), 1001); + Assert.assertEquals(1001, empty.size()); for ( int i = 0; i < 1000; i++ ) Assert.assertEquals(empty.get(i), null); - Assert.assertEquals((int)empty.get(1000), 1000); + Assert.assertEquals(1000, (int)empty.get(1000)); } - @Test (expected=IndexOutOfBoundsException.class ) + @Test (expectedExceptions=IndexOutOfBoundsException.class ) public void testSetBadGetNegative() { logger.warn("Executing testSetBadGetNegative"); empty.get(-1); @@ -171,7 +172,7 @@ public class ExpandingArrayListUnitTest extends BaseTest { logger.warn("Executing testSetBadGetPost"); empty.set(1, 1); Assert.assertEquals(empty.get(0), null); - Assert.assertEquals((int)empty.get(1), 1); + Assert.assertEquals(1, (int)empty.get(1)); Assert.assertEquals(empty.get(2), null); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/utils/genotype/DiploidGenotypeUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/DiploidGenotypeUnitTest.java index ccb5878f6..e4f8b12e3 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/DiploidGenotypeUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/DiploidGenotypeUnitTest.java @@ -1,8 +1,9 @@ package org.broadinstitute.sting.utils.genotype; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; /** diff --git a/java/test/org/broadinstitute/sting/utils/genotype/LikelihoodObjectUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/LikelihoodObjectUnitTest.java index 11e4387a4..260a0f2a6 100755 --- a/java/test/org/broadinstitute/sting/utils/genotype/LikelihoodObjectUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/LikelihoodObjectUnitTest.java @@ -1,11 +1,11 @@ package org.broadinstitute.sting.utils.genotype; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.utils.genotype.LikelihoodObject; -import static junit.framework.Assert.assertTrue; + +import static org.testng.Assert.assertTrue; /* @@ -44,7 +44,7 @@ public class LikelihoodObjectUnitTest extends BaseTest { private LikelihoodObject mLO = null; - @Before + @BeforeMethod public void before() { mLO = new LikelihoodObject(); } diff --git a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFReaderUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFReaderUnitTest.java index 7ddad8cac..f5575d956 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFReaderUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFReaderUnitTest.java @@ -1,8 +1,9 @@ package org.broadinstitute.sting.utils.genotype.glf; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.Assert; +import org.testng.annotations.Test; import java.io.File; import java.util.ArrayList; @@ -46,7 +47,7 @@ public class GLFReaderUnitTest extends BaseTest { System.err.println("Record count = " + recCount); e.printStackTrace(); } - Assert.assertEquals(finalRecordCount, recCount); - Assert.assertEquals(contigCount, contigs.size()); + Assert.assertEquals(recCount, finalRecordCount); + Assert.assertEquals(contigs.size(), contigCount); } } diff --git a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFRecordUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFRecordUnitTest.java index e4db48b4b..c4e9ba9cc 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFRecordUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFRecordUnitTest.java @@ -1,8 +1,9 @@ package org.broadinstitute.sting.utils.genotype.glf; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; /** @@ -24,11 +25,11 @@ public class GLFRecordUnitTest extends BaseTest { GLFRecord rec = new GLFSingleCall("1",'A',1,100,(short)200,likelihoods); Assert.assertTrue("1".equals(rec.contig)); - Assert.assertEquals('A',rec.getRefBase().toChar()); - Assert.assertEquals(1,rec.getPosition()); - Assert.assertEquals(10,rec.getMinimumLikelihood()); - Assert.assertEquals(200,rec.getRmsMapQ()); - Assert.assertEquals(100,rec.getReadDepth()); + Assert.assertEquals(rec.getRefBase().toChar(), 'A'); + Assert.assertEquals(rec.getPosition(), 1); + Assert.assertEquals(rec.getMinimumLikelihood(), 10); + Assert.assertEquals(rec.getRmsMapQ(), 200); + Assert.assertEquals(rec.getReadDepth(), 100); } diff --git a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFWriterUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFWriterUnitTest.java index f766b4bc5..cc8c61948 100755 --- a/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFWriterUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/glf/GLFWriterUnitTest.java @@ -1,13 +1,16 @@ package org.broadinstitute.sting.utils.genotype.glf; +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.genotype.LikelihoodObject; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeMethod; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.File; @@ -56,13 +59,14 @@ public class GLFWriterUnitTest extends BaseTest { protected static final String[] genotypes = {"AA", "AC", "AG", "AT", "CC", "CG", "CT", "GG", "GT", "TT"}; protected final static double SIGNIFICANCE = 5.1; - @Before + @BeforeMethod public void before() { } @BeforeClass - public static void beforeTests() { + public void beforeTests() { + GenomeLocParserTestUtils.clearSequenceDictionary(); IndexedFastaSequenceFile seq; seq = new IndexedFastaSequenceFile(new File(b36KGReference)); GenomeLocParser.setupRefContigOrdering(seq); @@ -156,6 +160,6 @@ public class GLFWriterUnitTest extends BaseTest { reader.next(); count++; } - Assert.assertEquals(count, 100); + Assert.assertEquals(100, count); } -} \ No newline at end of file +} diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderUnitTest.java index 68a554446..561ced1cb 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFHeaderUnitTest.java @@ -1,9 +1,10 @@ package org.broadinstitute.sting.utils.genotype.vcf; import org.broad.tribble.vcf.*; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.io.File; import java.io.IOException; @@ -26,7 +27,7 @@ public class VCFHeaderUnitTest extends BaseTest { for (String str : headerStr) headerFields.add(str); VCFHeader header = (VCFHeader)codec.createHeader(headerFields,"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO"); - Assert.assertEquals(headerStr.length /* for the # line */,header.getMetaData().size()); + Assert.assertEquals(header.getMetaData().size(), headerStr.length /* for the # line */); return header; } diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java index 88ed22bdb..b0602e6f6 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFWriterUnitTest.java @@ -6,14 +6,15 @@ import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.*; +import org.broadinstitute.sting.utils.GenomeLocParserTestUtils; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; -import org.broadinstitute.sting.gatk.refdata.tracks.builders.RMDTrackBuilder; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.Assert; -import org.junit.Test; -import org.junit.BeforeClass; + +import org.testng.annotations.Test; +import org.testng.annotations.BeforeClass; import java.io.File; import java.io.FileInputStream; @@ -37,7 +38,8 @@ public class VCFWriterUnitTest extends BaseTest { private File fakeVCFFile = new File("FAKEVCFFILEFORTESTING.vcf"); @BeforeClass - public static void beforeTests() { + public void beforeTests() { + GenomeLocParserTestUtils.clearSequenceDictionary(); IndexedFastaSequenceFile seq = new IndexedFastaSequenceFile(new File(hg18Reference)); GenomeLocParser.setupRefContigOrdering(seq); } @@ -76,7 +78,7 @@ public class VCFWriterUnitTest extends BaseTest { VariantContext vc = (VariantContext)reader.decode(line); counter++; } - Assert.assertEquals(2,counter); + Assert.assertEquals(counter, 2); Tribble.indexFile(fakeVCFFile).delete(); fakeVCFFile.delete(); } @@ -143,12 +145,12 @@ public class VCFWriterUnitTest extends BaseTest { Assert.assertEquals(VCFHeader.HEADER_FIELDS.values()[index], field); index++; } - Assert.assertEquals(metaData.size(), header.getMetaData().size()); + Assert.assertEquals(header.getMetaData().size(), metaData.size()); index = 0; for (String key : header.getGenotypeSamples()) { Assert.assertTrue(additionalColumns.contains(key)); index++; } - Assert.assertEquals(additionalColumns.size(), index+1 /* for the header field we don't see */); + Assert.assertEquals(index+1, additionalColumns.size() /* for the header field we don't see */); } } diff --git a/java/test/org/broadinstitute/sting/utils/interval/IntervalFileMergingIteratorUnitTest.java b/java/test/org/broadinstitute/sting/utils/interval/IntervalFileMergingIteratorUnitTest.java index 8f7b9545a..e48e3e4c0 100644 --- a/java/test/org/broadinstitute/sting/utils/interval/IntervalFileMergingIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/interval/IntervalFileMergingIteratorUnitTest.java @@ -25,10 +25,11 @@ package org.broadinstitute.sting.utils.interval; +import org.testng.Assert; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLoc; @@ -55,7 +56,7 @@ public class IntervalFileMergingIteratorUnitTest extends BaseTest { private static List results2 = null; @BeforeClass - public static void init() { + public void init() { GenomeLocParser.setupRefContigOrdering(ReferenceSequenceFileFactory.getReferenceSequenceFile(refFile)); results1 = new ArrayList(); @@ -84,7 +85,7 @@ public class IntervalFileMergingIteratorUnitTest extends BaseTest { GenomeLoc l = it.next(); GenomeLoc l_expected = check_it.next(); //System.out.println("int: "+l+" expected: "+l_expected) ; - Assert.assertEquals("Unexpected location returned by the iterator: "+l,l,l_expected); + Assert.assertEquals(l_expected, l, "Unexpected location returned by the iterator: "+l); } } @@ -101,7 +102,7 @@ public class IntervalFileMergingIteratorUnitTest extends BaseTest { // System.out.println("int: "+l+" expected: "+l_expected) ; } } catch ( ReviewedStingException e) { - Assert.assertEquals( e.getMessage(), "Interval chr5:7414 in the interval file is out of order."); + Assert.assertEquals("Interval chr5:7414 in the interval file is out of order.", e.getMessage()); } } @@ -115,7 +116,7 @@ public class IntervalFileMergingIteratorUnitTest extends BaseTest { GenomeLoc l = it.next(); GenomeLoc l_expected = check_it.next(); // System.out.println("int: "+l+" expected: "+l_expected) ; - Assert.assertEquals("Unexpected location returned by the iterator: "+l,l,l_expected); + Assert.assertEquals(l_expected, l, "Unexpected location returned by the iterator: "+l); } } @@ -129,7 +130,7 @@ public class IntervalFileMergingIteratorUnitTest extends BaseTest { GenomeLoc l = it.next(); GenomeLoc l_expected = check_it.next(); // System.out.println("int: "+l+" expected: "+l_expected) ; - Assert.assertEquals("Unexpected location returned by the iterator: "+l,l,l_expected); + Assert.assertEquals(l_expected, l, "Unexpected location returned by the iterator: "+l); } } diff --git a/java/test/org/broadinstitute/sting/utils/interval/IntervalIntegrationTest.java b/java/test/org/broadinstitute/sting/utils/interval/IntervalIntegrationTest.java index d181f7ab5..bf085e69e 100644 --- a/java/test/org/broadinstitute/sting/utils/interval/IntervalIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/utils/interval/IntervalIntegrationTest.java @@ -25,7 +25,7 @@ package org.broadinstitute.sting.utils.interval; import org.broadinstitute.sting.WalkerTest; -import org.junit.Test; +import org.testng.annotations.Test; import java.util.Arrays; import java.util.Collections; diff --git a/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsTest.java b/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsTest.java index e4a3a3db5..a74cc54e7 100644 --- a/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsTest.java +++ b/java/test/org/broadinstitute/sting/utils/interval/IntervalUtilsTest.java @@ -3,11 +3,12 @@ package org.broadinstitute.sting.utils.interval; import net.sf.picard.reference.IndexedFastaSequenceFile; import net.sf.picard.reference.ReferenceSequenceFile; import org.broadinstitute.sting.BaseTest; +import org.testng.Assert; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.io.File; import java.io.FileNotFoundException; @@ -24,7 +25,7 @@ public class IntervalUtilsTest extends BaseTest { @BeforeClass - public static void init() throws FileNotFoundException { + public void init() throws FileNotFoundException { seq = new IndexedFastaSequenceFile(new File(hg18Reference)); GenomeLocParser.setupRefContigOrdering(seq); @@ -45,9 +46,9 @@ public class IntervalUtilsTest extends BaseTest { } List ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, listEveryTwoFromOne, IntervalSetRule.UNION); - Assert.assertEquals(100,ret.size()); + Assert.assertEquals(ret.size(), 100); ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, listEveryTwoFromOne, IntervalSetRule.INTERSECTION); - Assert.assertEquals(0,ret.size()); + Assert.assertEquals(ret.size(), 0); } @Test @@ -64,9 +65,9 @@ public class IntervalUtilsTest extends BaseTest { } List ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, allSites, IntervalSetRule.UNION); - Assert.assertEquals(150,ret.size()); + Assert.assertEquals(ret.size(), 150); ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, allSites, IntervalSetRule.INTERSECTION); - Assert.assertEquals(50,ret.size()); + Assert.assertEquals(ret.size(), 50); } @Test @@ -84,8 +85,8 @@ public class IntervalUtilsTest extends BaseTest { } List ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, allSites, IntervalSetRule.UNION); - Assert.assertEquals(40,ret.size()); + Assert.assertEquals(ret.size(), 40); ret = IntervalUtils.mergeListsBySetOperator(listEveryTwoFromTwo, allSites, IntervalSetRule.INTERSECTION); - Assert.assertEquals(20,ret.size()); + Assert.assertEquals(ret.size(), 20); } } diff --git a/java/test/org/broadinstitute/sting/utils/interval/NwayIntervalMergingIteratorUnitTest.java b/java/test/org/broadinstitute/sting/utils/interval/NwayIntervalMergingIteratorUnitTest.java index 13b614225..63d84f082 100644 --- a/java/test/org/broadinstitute/sting/utils/interval/NwayIntervalMergingIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/interval/NwayIntervalMergingIteratorUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 The Broad Institute + * Copyright (c) 2010, The Broad Institute * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -12,7 +12,6 @@ * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -28,10 +27,10 @@ package org.broadinstitute.sting.utils.interval; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.GenomeLoc; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; import net.sf.picard.reference.ReferenceSequenceFileFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; @@ -104,7 +103,7 @@ public class NwayIntervalMergingIteratorUnitTest extends BaseTest { GenomeLoc l = it.next(); GenomeLoc l_expected = e_it.next(); //System.out.println("int: "+l+" expected: "+l_expected) ; - Assert.assertEquals("Unexpected location returned by the iterator: "+l,l,l_expected); + Assert.assertEquals(l,l_expected,"Unexpected location returned by the iterator: "+l); } } diff --git a/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupTest.java b/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java similarity index 74% rename from java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupTest.java rename to java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java index df760865b..cc404e7ba 100644 --- a/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupTest.java +++ b/java/test/org/broadinstitute/sting/utils/pileup/ReadBackedPileupUnitTest.java @@ -27,9 +27,10 @@ package org.broadinstitute.sting.utils.pileup; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMReadGroupRecord; import net.sf.samtools.SAMRecord; +import org.testng.Assert; import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; import java.util.Arrays; import java.util.HashMap; @@ -39,7 +40,7 @@ import java.util.Map; /** * Test routines for read-backed pileup. */ -public class ReadBackedPileupTest { +public class ReadBackedPileupUnitTest { /** * Ensure that basic read group splitting works. */ @@ -73,18 +74,18 @@ public class ReadBackedPileupTest { ReadBackedPileup rg1Pileup = pileup.getPileupForReadGroup("rg1"); List rg1Reads = rg1Pileup.getReads(); - Assert.assertEquals("Wrong number of reads in read group rg1",4,rg1Reads.size()); - Assert.assertEquals("Read " + read1.getReadName() + " should be in rg1 but isn't",read1,rg1Reads.get(0)); - Assert.assertEquals("Read " + read3.getReadName() + " should be in rg1 but isn't",read3,rg1Reads.get(1)); - Assert.assertEquals("Read " + read6.getReadName() + " should be in rg1 but isn't",read6,rg1Reads.get(2)); - Assert.assertEquals("Read " + read7.getReadName() + " should be in rg1 but isn't",read7,rg1Reads.get(3)); + Assert.assertEquals(rg1Reads.size(), 4, "Wrong number of reads in read group rg1"); + Assert.assertEquals(rg1Reads.get(0), read1, "Read " + read1.getReadName() + " should be in rg1 but isn't"); + Assert.assertEquals(rg1Reads.get(1), read3, "Read " + read3.getReadName() + " should be in rg1 but isn't"); + Assert.assertEquals(rg1Reads.get(2), read6, "Read " + read6.getReadName() + " should be in rg1 but isn't"); + Assert.assertEquals(rg1Reads.get(3), read7, "Read " + read7.getReadName() + " should be in rg1 but isn't"); ReadBackedPileup rg2Pileup = pileup.getPileupForReadGroup("rg2"); List rg2Reads = rg2Pileup.getReads(); - Assert.assertEquals("Wrong number of reads in read group rg2",3,rg2Reads.size()); - Assert.assertEquals("Read " + read2.getReadName() + " should be in rg2 but isn't",read2,rg2Reads.get(0)); - Assert.assertEquals("Read " + read4.getReadName() + " should be in rg2 but isn't",read4,rg2Reads.get(1)); - Assert.assertEquals("Read " + read5.getReadName() + " should be in rg2 but isn't",read5,rg2Reads.get(2)); + Assert.assertEquals(rg2Reads.size(), 3, "Wrong number of reads in read group rg2"); + Assert.assertEquals(rg2Reads.get(0), read2, "Read " + read2.getReadName() + " should be in rg2 but isn't"); + Assert.assertEquals(rg2Reads.get(1), read4, "Read " + read4.getReadName() + " should be in rg2 but isn't"); + Assert.assertEquals(rg2Reads.get(2), read5, "Read " + read5.getReadName() + " should be in rg2 but isn't"); } /** @@ -104,13 +105,13 @@ public class ReadBackedPileupTest { ReadBackedPileup nullRgPileup = pileup.getPileupForReadGroup(null); List nullRgReads = nullRgPileup.getReads(); - Assert.assertEquals("Wrong number of reads in null read group",3,nullRgPileup.size()); - Assert.assertEquals("Read " + read1.getReadName() + " should be in null rg but isn't",read1,nullRgReads.get(0)); - Assert.assertEquals("Read " + read2.getReadName() + " should be in null rg but isn't",read2,nullRgReads.get(1)); - Assert.assertEquals("Read " + read3.getReadName() + " should be in null rg but isn't",read3,nullRgReads.get(2)); + Assert.assertEquals(nullRgPileup.size(), 3, "Wrong number of reads in null read group"); + Assert.assertEquals(nullRgReads.get(0), read1, "Read " + read1.getReadName() + " should be in null rg but isn't"); + Assert.assertEquals(nullRgReads.get(1), read2, "Read " + read2.getReadName() + " should be in null rg but isn't"); + Assert.assertEquals(nullRgReads.get(2), read3, "Read " + read3.getReadName() + " should be in null rg but isn't"); ReadBackedPileup rg1Pileup = pileup.getPileupForReadGroup("rg1"); - Assert.assertNull("Pileup for non-existent read group should return null",rg1Pileup); + Assert.assertNull(rg1Pileup, "Pileup for non-existent read group should return null"); } /** @@ -151,15 +152,15 @@ public class ReadBackedPileupTest { ReadBackedPileup rg1Pileup = compositePileup.getPileupForReadGroup("rg1"); List rg1Reads = rg1Pileup.getReads(); - Assert.assertEquals("Wrong number of reads in read group rg1",2,rg1Reads.size()); - Assert.assertEquals("Read " + read1.getReadName() + " should be in rg1 but isn't",read1,rg1Reads.get(0)); - Assert.assertEquals("Read " + read3.getReadName() + " should be in rg1 but isn't",read3,rg1Reads.get(1)); + Assert.assertEquals(rg1Reads.size(), 2, "Wrong number of reads in read group rg1"); + Assert.assertEquals(rg1Reads.get(0), read1, "Read " + read1.getReadName() + " should be in rg1 but isn't"); + Assert.assertEquals(rg1Reads.get(1), read3, "Read " + read3.getReadName() + " should be in rg1 but isn't"); ReadBackedPileup rg2Pileup = compositePileup.getPileupForReadGroup("rg2"); List rg2Reads = rg2Pileup.getReads(); - Assert.assertEquals("Wrong number of reads in read group rg2",2,rg1Reads.size()); - Assert.assertEquals("Read " + read2.getReadName() + " should be in rg2 but isn't",read2,rg2Reads.get(0)); - Assert.assertEquals("Read " + read4.getReadName() + " should be in rg2 but isn't",read4,rg2Reads.get(1)); + Assert.assertEquals(rg1Reads.size(), 2, "Wrong number of reads in read group rg2"); + Assert.assertEquals(rg2Reads.get(0), read2, "Read " + read2.getReadName() + " should be in rg2 but isn't"); + Assert.assertEquals(rg2Reads.get(1), read4, "Read " + read4.getReadName() + " should be in rg2 but isn't"); } } diff --git a/java/test/org/broadinstitute/sting/utils/report/AnalysisModuleScannerUnitTest.java b/java/test/org/broadinstitute/sting/utils/report/AnalysisModuleScannerUnitTest.java index b2b64fa97..23427d5b1 100644 --- a/java/test/org/broadinstitute/sting/utils/report/AnalysisModuleScannerUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/report/AnalysisModuleScannerUnitTest.java @@ -1,11 +1,12 @@ package org.broadinstitute.sting.utils.report; +import org.testng.Assert; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.utils.report.tags.Analysis; import org.broadinstitute.sting.utils.report.tags.DataPoint; import org.broadinstitute.sting.utils.report.tags.Param; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.annotations.Test; /** @@ -22,7 +23,7 @@ public class AnalysisModuleScannerUnitTest extends BaseTest { AnalysisModuleScanner scanner = new AnalysisModuleScanner(FakeAnalysis.class); // check we found one param, and check its description - Assert.assertEquals(3, scanner.getParameters().size()); + Assert.assertEquals(scanner.getParameters().size(), 3); Assert.assertTrue("basic description".equals(scanner.getParameters().values().iterator().next().description())); // check that the analysis name and description were set diff --git a/java/test/org/broadinstitute/sting/utils/report/ReportMarshallerUnitTest.java b/java/test/org/broadinstitute/sting/utils/report/ReportMarshallerUnitTest.java index 6cd329c1c..bd51d7282 100644 --- a/java/test/org/broadinstitute/sting/utils/report/ReportMarshallerUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/report/ReportMarshallerUnitTest.java @@ -24,7 +24,7 @@ package org.broadinstitute.sting.utils.report; import org.broadinstitute.sting.BaseTest; -import org.junit.Test; +import org.testng.annotations.Test; /** diff --git a/java/test/org/broadinstitute/sting/utils/report/templates/TextTableUnitTest.java b/java/test/org/broadinstitute/sting/utils/report/templates/TextTableUnitTest.java index f31781e21..7325ae4ab 100644 --- a/java/test/org/broadinstitute/sting/utils/report/templates/TextTableUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/report/templates/TextTableUnitTest.java @@ -1,7 +1,8 @@ package org.broadinstitute.sting.utils.report.templates; -import org.junit.Assert; -import org.junit.Test; + +import org.testng.Assert; +import org.testng.annotations.Test; import java.util.ArrayList; @@ -22,7 +23,7 @@ public class TextTableUnitTest { entriesSeen++; } else Assert.assertTrue(rows.get(x).get(y).equals("")); - Assert.assertEquals("Incorrect number of entries seen",1,entriesSeen); + Assert.assertEquals(entriesSeen, 1, "Incorrect number of entries seen"); } @Test @@ -40,6 +41,6 @@ public class TextTableUnitTest { } else Assert.assertTrue(rows.get(x).get(y).equals("")); - Assert.assertEquals("Incorrect number of entries seen",2,entriesSeen); + Assert.assertEquals(entriesSeen, 2, "Incorrect number of entries seen"); } } diff --git a/java/test/org/broadinstitute/sting/utils/sam/ArtificialPatternedSAMIteratorUnitTest.java b/java/test/org/broadinstitute/sting/utils/sam/ArtificialPatternedSAMIteratorUnitTest.java index 9ee4228ce..cc07367c4 100644 --- a/java/test/org/broadinstitute/sting/utils/sam/ArtificialPatternedSAMIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/sam/ArtificialPatternedSAMIteratorUnitTest.java @@ -1,10 +1,10 @@ package org.broadinstitute.sting.utils.sam; import org.broadinstitute.sting.BaseTest; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import net.sf.samtools.SAMFileHeader; import net.sf.samtools.SAMRecord; @@ -54,7 +54,7 @@ public class ArtificialPatternedSAMIteratorUnitTest extends BaseTest { private int DEFAULT_READ_LENGTH = ArtificialSAMUtils.DEFAULT_READ_LENGTH; SAMFileHeader header; - @Before + @BeforeMethod public void before() { header = ArtificialSAMUtils.createArtificialSamHeader(( endingChr - startingChr ) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); diff --git a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMFileWriterUnitTest.java b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMFileWriterUnitTest.java index ce5b36816..dab20b978 100644 --- a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMFileWriterUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMFileWriterUnitTest.java @@ -1,9 +1,9 @@ package org.broadinstitute.sting.utils.sam; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMFileHeader; @@ -53,7 +53,7 @@ public class ArtificialSAMFileWriterUnitTest extends BaseTest { private final int numChr = 2; private final int chrSize = 100; - @Before + @BeforeMethod public void before() { writer = new ArtificialSAMFileWriter(); header = ArtificialSAMUtils.createArtificialSamHeader(numChr, startChr, chrSize); @@ -65,7 +65,7 @@ public class ArtificialSAMFileWriterUnitTest extends BaseTest { SAMRecord rec = ArtificialSAMUtils.createArtificialRead(header, String.valueOf(x), 1, x, ArtificialSAMUtils.DEFAULT_READ_LENGTH); writer.addAlignment(rec); } - assertEquals(100, writer.getRecords().size()); + assertEquals(writer.getRecords().size(), 100); } @@ -78,7 +78,7 @@ public class ArtificialSAMFileWriterUnitTest extends BaseTest { SAMRecord rec = ArtificialSAMUtils.createArtificialRead(header, String.valueOf(x), 1, x, ArtificialSAMUtils.DEFAULT_READ_LENGTH); writer.addAlignment(rec); } - assertEquals(100, writer.getRecords().size()); + assertEquals(writer.getRecords().size(), 100); // check the names for (int x = 0; x < 100; x++) { diff --git a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMQueryIteratorUnitTest.java b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMQueryIteratorUnitTest.java index 38d39008d..3e4b6fe56 100644 --- a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMQueryIteratorUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMQueryIteratorUnitTest.java @@ -1,10 +1,9 @@ package org.broadinstitute.sting.utils.sam; import org.broadinstitute.sting.BaseTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; import net.sf.samtools.SAMRecord; -import static junit.framework.Assert.assertTrue; /* @@ -50,7 +49,7 @@ public class ArtificialSAMQueryIteratorUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(100, count); + assertEquals(count, 100); } @@ -63,7 +62,7 @@ public class ArtificialSAMQueryIteratorUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(1, count); + assertEquals(count, 1); } @@ -76,7 +75,7 @@ public class ArtificialSAMQueryIteratorUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(50, count); + assertEquals(count, 50); } @@ -89,7 +88,7 @@ public class ArtificialSAMQueryIteratorUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(1, count); + assertEquals(count, 1); } @@ -102,11 +101,11 @@ public class ArtificialSAMQueryIteratorUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(50, count); + assertEquals(count, 50); } - @Test(expected = IllegalArgumentException.class) + @Test(expectedExceptions=IllegalArgumentException.class) public void testUnknownChromosome() { ArtificialSAMQueryIterator iter = ArtificialSAMUtils.queryReadIterator(1, 2, 100); iter.queryOverlapping("chr621", 25, 74); diff --git a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMUtilsUnitTest.java b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMUtilsUnitTest.java index b16dc87f7..6af409f60 100644 --- a/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMUtilsUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/sam/ArtificialSAMUtilsUnitTest.java @@ -2,10 +2,10 @@ package org.broadinstitute.sting.utils.sam; import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.iterators.StingSAMIterator; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static junit.framework.Assert.assertTrue; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; +import org.testng.annotations.Test; import net.sf.samtools.SAMRecord; /** @@ -26,7 +26,7 @@ public class ArtificialSAMUtilsUnitTest extends BaseTest { SAMRecord rec = iter.next(); count++; } - assertEquals(100 * 100, count); + assertEquals(count, 100 * 100); } @Test @@ -39,7 +39,7 @@ public class ArtificialSAMUtilsUnitTest extends BaseTest { assertEquals(Integer.valueOf(Math.round(count / 10)), rec.getReferenceIndex()); count++; } - assertEquals(100 * 10, count); + assertEquals(count, 100 * 10); } @Test @@ -52,7 +52,7 @@ public class ArtificialSAMUtilsUnitTest extends BaseTest { assertEquals(Integer.valueOf(count), rec.getReferenceIndex()); count++; } - assertEquals(100 * 1, count); + assertEquals(count, 100 * 1); } @Test @@ -67,7 +67,7 @@ public class ArtificialSAMUtilsUnitTest extends BaseTest { assertTrue(rec.getReferenceIndex() >= 0); count++; } - assertEquals(count, 100 * 100); + assertEquals(100 * 100, count); // now we should have 1000 unmapped reads count = 0; @@ -76,7 +76,7 @@ public class ArtificialSAMUtilsUnitTest extends BaseTest { assertTrue(rec.getReferenceIndex() < 0); count++; } - assertEquals(1000, count); + assertEquals(count, 1000); } diff --git a/java/test/org/broadinstitute/sting/utils/threading/ThreadPoolMonitorUnitTest.java b/java/test/org/broadinstitute/sting/utils/threading/ThreadPoolMonitorUnitTest.java index 1db758d0e..444691e1f 100755 --- a/java/test/org/broadinstitute/sting/utils/threading/ThreadPoolMonitorUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/threading/ThreadPoolMonitorUnitTest.java @@ -1,6 +1,6 @@ package org.broadinstitute.sting.utils.threading; -import org.junit.Test; +import org.testng.annotations.Test; import org.broadinstitute.sting.BaseTest; import java.util.concurrent.ExecutorService; @@ -28,7 +28,7 @@ public class ThreadPoolMonitorUnitTest extends BaseTest { /** * Test to make sure the thread pool wait works properly. */ - @Test(timeout=2000) + @Test(timeOut=2000) public void testThreadPoolMonitor() { ThreadPoolMonitor monitor = new ThreadPoolMonitor(); synchronized(monitor) { diff --git a/scala/test/org/broadinstitute/sting/queue/extensions/gatk/IntervalScatterFunctionUnitTest.scala b/scala/test/org/broadinstitute/sting/queue/extensions/gatk/IntervalScatterFunctionUnitTest.scala index 25cc33157..42ac83aa4 100644 --- a/scala/test/org/broadinstitute/sting/queue/extensions/gatk/IntervalScatterFunctionUnitTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/extensions/gatk/IntervalScatterFunctionUnitTest.scala @@ -2,19 +2,21 @@ package org.broadinstitute.sting.queue.extensions.gatk import collection.JavaConversions._ import java.io.File -import org.junit.{Before, Assert, Test} +import org.testng.Assert import org.broadinstitute.sting.BaseTest import org.broadinstitute.sting.utils.interval.IntervalUtils -import org.broadinstitute.sting.utils.GenomeLocParser import org.broadinstitute.sting.queue.QException import net.sf.picard.reference.IndexedFastaSequenceFile +import org.testng.annotations.{Test, BeforeMethod} +import org.broadinstitute.sting.utils.{GenomeLocParserTestUtils, GenomeLocParser} class IntervalScatterFunctionUnitTest extends BaseTest { private def reference = new File(BaseTest.b36KGReference) private var header: IndexedFastaSequenceFile = _ - @Before + @BeforeMethod def setup() { + GenomeLocParserTestUtils.clearSequenceDictionary() header = new IndexedFastaSequenceFile(reference) GenomeLocParser.setupRefContigOrdering(header.getSequenceDictionary()) } @@ -74,7 +76,7 @@ class IntervalScatterFunctionUnitTest extends BaseTest { Assert.assertEquals(chr4, locs3.get(0)) } - @Test(expected=classOf[QException]) + @Test(expectedExceptions=Array(classOf[QException])) def testScatterMoreFiles = { val files = (1 to 3).toList.map(index => new File(testDir + "more." + index + ".intervals")) IntervalScatterFunction.scatter(reference, List("1", "2"), files, false) @@ -178,7 +180,7 @@ class IntervalScatterFunctionUnitTest extends BaseTest { Assert.assertEquals(chr4, locs3.get(1)) } - @Test(expected=classOf[QException]) + @Test(expectedExceptions=Array(classOf[QException])) def testScatterByContigMoreFiles = { val files = (1 to 3).toList.map(index => new File(testDir + "contig_more." + index + ".intervals")) IntervalScatterFunction.scatter(reference, List("1", "2"), files, true) diff --git a/scala/test/org/broadinstitute/sting/queue/util/IOUtilsUnitTest.scala b/scala/test/org/broadinstitute/sting/queue/util/IOUtilsUnitTest.scala index 99396954c..0a6058b5f 100644 --- a/scala/test/org/broadinstitute/sting/queue/util/IOUtilsUnitTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/util/IOUtilsUnitTest.scala @@ -1,9 +1,10 @@ package org.broadinstitute.sting.queue.util import org.broadinstitute.sting.BaseTest -import org.junit.{Assert, Test} import java.io.File import org.broadinstitute.sting.utils.exceptions.UserException +import org.testng.Assert +import org.testng.annotations.Test class IOUtilsUnitTest extends BaseTest { @Test @@ -17,7 +18,7 @@ class IOUtilsUnitTest extends BaseTest { } } - @Test(expected=classOf[UserException.BadTmpDir]) + @Test(expectedExceptions=Array(classOf[UserException.BadTmpDir])) def testBadTempDir = { val tmpDir = System.getProperty("java.io.tmpdir") try {