KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > beans > config > FilterManagerTest


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.beans.config;
14
15 import info.magnolia.cms.beans.config.FilterManager.FilterDefinition;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.Collections JavaDoc;
19 import java.util.List JavaDoc;
20
21 import junit.framework.TestCase;
22
23
24 /**
25  * @author fgiust
26  * @version $Revision: 6341 $ ($Author: philipp $)
27  */

28 public class FilterManagerTest extends TestCase {
29
30     public void testSort() {
31
32         List JavaDoc filterDefinitions = new ArrayList JavaDoc();
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