JAL-1782 refactored test to ensure it passes in TestNG
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 6 Jul 2015 11:03:19 +0000 (12:03 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 6 Jul 2015 11:03:19 +0000 (12:03 +0100)
test/jalview/analysis/AnnotationSorterTest.java

index 8c3489b..6149048 100644 (file)
@@ -242,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
@@ -286,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
@@ -336,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" };
@@ -346,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
@@ -364,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
@@ -373,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