X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fanalysis%2FAnnotationSorterTest.java;h=1731302357d835e9b3a07cccad6267aef9e64a87;hb=8bbcfb93404decd6d660ca32b69a29f8a1f34e82;hp=239eb4c04974f73e3f13035fe81e0d845526621b;hpb=76139ef711627a3176736af47272ff55be62e720;p=jalview.git diff --git a/test/jalview/analysis/AnnotationSorterTest.java b/test/jalview/analysis/AnnotationSorterTest.java index 239eb4c..1731302 100644 --- a/test/jalview/analysis/AnnotationSorterTest.java +++ b/test/jalview/analysis/AnnotationSorterTest.java @@ -1,6 +1,7 @@ package jalview.analysis; -import static org.junit.Assert.assertEquals; +import static org.testng.AssertJUnit.assertEquals; + import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; @@ -11,8 +12,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.junit.Before; -import org.junit.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; public class AnnotationSorterTest { @@ -29,7 +30,7 @@ public class AnnotationSorterTest /* * Set up 6 sequences and 7 annotations. */ - @Before + @BeforeMethod(alwaysRun = true) public void setUp() { al = buildAlignment(NUM_SEQS); @@ -83,7 +84,7 @@ public class AnnotationSorterTest * sequence ref * */ - @Test + @Test(groups ={ "Functional" }) public void testSortBySequenceAndType_autocalcLast() { // @formatter:off @@ -110,7 +111,7 @@ public class AnnotationSorterTest /** * Variant with autocalculated annotations sorting to front */ - @Test + @Test(groups ={ "Functional" }) public void testSortBySequenceAndType_autocalcFirst() { // @formatter:off @@ -146,7 +147,7 @@ public class AnnotationSorterTest * sequence ref * */ - @Test + @Test(groups ={ "Functional" }) public void testSortByTypeAndSequence_autocalcLast() { // @formatter:off @@ -173,7 +174,7 @@ public class AnnotationSorterTest /** * Variant of test with autocalculated annotations sorted to front */ - @Test + @Test(groups ={ "Functional" }) public void testSortByTypeAndSequence_autocalcFirst() { // @formatter:off @@ -201,7 +202,7 @@ public class AnnotationSorterTest * Variant of test with autocalculated annotations sorted to front but * otherwise no change. */ - @Test + @Test(groups ={ "Functional" }) public void testNoSort_autocalcFirst() { // @formatter:off @@ -225,7 +226,7 @@ public class AnnotationSorterTest assertEquals("Structure", anns[6].label); } - @Test + @Test(groups ={ "Functional" }) public void testSort_timingPresorted() { testTiming_presorted(50, 100); @@ -241,23 +242,23 @@ public class AnnotationSorterTest */ private void testTiming_presorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); /* * Set the annotations presorted by label */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI randomSequenceRef = sequences[r.nextInt(sequences.length)]; - anns[i].sequenceRef = randomSequenceRef; - anns[i].label = "label" + i; + annotations[i].sequenceRef = randomSequenceRef; + annotations[i].label = "label" + i; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); long endTime = System.currentTimeMillis(); final long elapsed = endTime - startTime; System.out.println("Timing test for presorted " + numSeqs @@ -268,7 +269,7 @@ public class AnnotationSorterTest /** * Timing tests for sorting randomly sorted annotations for various sizes. */ - @Test + @Test(groups ={ "Functional" }) public void testSort_timingUnsorted() { testTiming_unsorted(50, 100); @@ -285,23 +286,23 @@ public class AnnotationSorterTest */ private void testTiming_unsorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); /* * Set the annotations in random order with respect to the sequences */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI randomSequenceRef = sequences[r.nextInt(sequences.length)]; - anns[i].sequenceRef = randomSequenceRef; - anns[i].label = "label" + i; + annotations[i].sequenceRef = randomSequenceRef; + annotations[i].label = "label" + i; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); long endTime = System.currentTimeMillis(); final long elapsed = endTime - startTime; System.out.println("Timing test for unsorted " + numSeqs @@ -312,7 +313,7 @@ public class AnnotationSorterTest /** * Timing test for sorting annotations with a limited range of types (labels). */ - @Test + @Test(groups ={ "Functional" }) public void testSort_timingSemisorted() { testTiming_semiSorted(50, 100); @@ -335,8 +336,8 @@ public class AnnotationSorterTest */ private void testTiming_semiSorted(final int numSeqs, final int numAnns) { - al = buildAlignment(numSeqs); - anns = buildAnnotations(numAnns); + Alignment alignment = buildAlignment(numSeqs); + AlignmentAnnotation[] annotations = buildAnnotations(numAnns); String[] labels = new String[] { "label1", "label2", "label3", "label4", "label5", "label6" }; @@ -345,16 +346,16 @@ public class AnnotationSorterTest * Set the annotations in sequence order with randomly assigned labels. */ Random r = new Random(); - final SequenceI[] sequences = al.getSequencesArray(); - for (int i = 0; i < anns.length; i++) + final SequenceI[] sequences = alignment.getSequencesArray(); + for (int i = 0; i < annotations.length; i++) { SequenceI sequenceRef = sequences[i % sequences.length]; - anns[i].sequenceRef = sequenceRef; - anns[i].label = labels[r.nextInt(labels.length)]; + annotations[i].sequenceRef = sequenceRef; + annotations[i].label = labels[r.nextInt(labels.length)]; } long startTime = System.currentTimeMillis(); - AnnotationSorter testee = new AnnotationSorter(al, false); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + AnnotationSorter testee = new AnnotationSorter(alignment, false); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); long endTime = System.currentTimeMillis(); long elapsed = endTime - startTime; System.out.println("Sort by label for semisorted " + numSeqs @@ -363,7 +364,7 @@ public class AnnotationSorterTest // now resort by sequence startTime = System.currentTimeMillis(); - testee.sort(anns, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); + testee.sort(annotations, SequenceAnnotationOrder.SEQUENCE_AND_LABEL); endTime = System.currentTimeMillis(); elapsed = endTime - startTime; System.out.println("Resort by sequence for semisorted " + numSeqs @@ -372,7 +373,7 @@ public class AnnotationSorterTest // now resort by label startTime = System.currentTimeMillis(); - testee.sort(anns, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); + testee.sort(annotations, SequenceAnnotationOrder.LABEL_AND_SEQUENCE); endTime = System.currentTimeMillis(); elapsed = endTime - startTime; System.out.println("Resort by label for semisorted " + numSeqs