1 25 26 package org.snipsnap.test.snip.name; 27 28 import junit.framework.TestCase; 29 import junit.framework.Test; 30 import junit.framework.TestSuite; 31 32 import java.util.ArrayList ; 33 import java.util.List ; 34 import java.util.Collections ; 35 import java.util.Iterator ; 36 37 import org.snipsnap.snip.PostNameComparator; 38 39 public class PostNameComparatorTest extends TestCase { 40 public PostNameComparatorTest(String name) { 41 super(name); 42 } 43 44 public static Test suite() { 45 return new TestSuite(PostNameComparatorTest.class); 46 } 47 48 public void testSortOrder() { 49 List list = new ArrayList (); 50 list.add("2003-10-05/1"); 51 list.add("2003-10-05/11"); 52 list.add("2003-10-06/1"); 53 list.add("2003-10-05/2"); 54 55 Collections.sort(list, new PostNameComparator()); 56 57 Iterator iterator = list.iterator(); 58 String resultList = ""; 59 while (iterator.hasNext()) { 60 String name = (String ) iterator.next(); 61 resultList = resultList + name + " "; 62 } 63 assertEquals("Correct order", "2003-10-06/1 2003-10-05/11 2003-10-05/2 2003-10-05/1 ", resultList); 64 } 65 } | Popular Tags |