1 13 package info.magnolia.cms.beans.config; 14 15 import info.magnolia.cms.beans.config.FilterManager.FilterDefinition; 16 17 import java.util.ArrayList ; 18 import java.util.Collections ; 19 import java.util.List ; 20 21 import junit.framework.TestCase; 22 23 24 28 public class FilterManagerTest extends TestCase { 29 30 public void testSort() { 31 32 List filterDefinitions = new ArrayList (); 33 34 FilterDefinition definition = new FilterDefinition(); 35 definition.setClassName("a"); 36 definition.setPriority(200); 37 filterDefinitions.add(definition); 38 39 definition = new FilterDefinition(); 40 definition.setClassName("b"); 41 definition.setPriority(100); 42 filterDefinitions.add(definition); 43 44 definition = new FilterDefinition(); 45 definition.setClassName("c"); 46 definition.setPriority(300); 47 filterDefinitions.add(definition); 48 49 Collections.sort(filterDefinitions); 50 51 FilterDefinition[] defs = (FilterDefinition[]) filterDefinitions.toArray(new FilterDefinition[filterDefinitions 52 .size()]); 53 54 assertEquals("b", defs[0].getClassName()); 55 assertEquals("a", defs[1].getClassName()); 56 assertEquals("c", defs[2].getClassName()); 57 } 58 } 59 | Popular Tags |