1 16 package org.apache.commons.collections.comparators; 17 18 import java.util.Comparator ; 19 import java.util.LinkedList ; 20 import java.util.List ; 21 22 import junit.framework.Test; 23 import junit.framework.TestSuite; 24 25 32 public abstract class TestNullComparator extends AbstractTestComparator { 33 34 public TestNullComparator(String testName) { 35 super(testName); 36 } 37 38 public static Test suite() { 39 TestSuite suite = new TestSuite(TestNullComparator.class.getName()); 40 suite.addTest(new TestSuite(TestNullComparator1.class)); 41 suite.addTest(new TestSuite(TestNullComparator2.class)); 42 return suite; 43 } 44 45 48 public static class TestNullComparator1 extends TestNullComparator { 49 50 public TestNullComparator1(String testName) { 51 super(testName); 52 } 53 54 public Comparator makeComparator() { 55 return new NullComparator(); 56 } 57 58 public List getComparableObjectsOrdered() { 59 List list = new LinkedList (); 60 list.add(new Integer (1)); 61 list.add(new Integer (2)); 62 list.add(new Integer (3)); 63 list.add(new Integer (4)); 64 list.add(new Integer (5)); 65 list.add(null); 66 return list; 67 } 68 69 public String getCanonicalComparatorName(Object object) { 70 return super.getCanonicalComparatorName(object) + "1"; 71 } 72 } 73 74 77 public static class TestNullComparator2 extends TestNullComparator { 78 79 public TestNullComparator2(String testName) { 80 super(testName); 81 } 82 83 public Comparator makeComparator() { 84 return new NullComparator(false); 85 } 86 87 public List getComparableObjectsOrdered() { 88 List list = new LinkedList (); 89 list.add(null); 90 list.add(new Integer (1)); 91 list.add(new Integer (2)); 92 list.add(new Integer (3)); 93 list.add(new Integer (4)); 94 list.add(new Integer (5)); 95 return list; 96 } 97 98 public String getCanonicalComparatorName(Object object) { 99 return super.getCanonicalComparatorName(object) + "2"; 100 } 101 } 102 } 103 | Popular Tags |