KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > storage > search > implementation > BasicSortOrderTest


1 package org.mmbase.storage.search.implementation;
2
3 import junit.framework.*;
4 import org.mmbase.module.core.*;
5 import org.mmbase.module.corebuilders.FieldDefs;
6 import org.mmbase.storage.search.*;
7
8 /**
9  * JUnit tests.
10  *
11  * @author Rob van Maris
12  * @version $Revision: 1.2 $
13  */

14 public class BasicSortOrderTest extends TestCase {
15
16     /** Test instance. */
17     private BasicSortOrder instance = null;
18
19     /** Associated field. */
20     private BasicStepField field = null;
21
22     /** MMBase instance. */
23     private MMBase mmbase = null;
24
25     public BasicSortOrderTest(java.lang.String JavaDoc testName) {
26         super(testName);
27     }
28
29     public static void main(java.lang.String JavaDoc[] args) {
30         junit.textui.TestRunner.run(suite());
31     }
32
33     /**
34      * Sets up before each test.
35      */

36     public void setUp() throws Exception JavaDoc {
37         MMBaseContext.init();
38         mmbase = MMBase.getMMBase();
39         MMObjectBuilder builder = mmbase.getBuilder("images");
40         FieldDefs fieldDefs = builder.getField("title");
41         Step step = new BasicStep(builder);
42         field = new BasicStepField(step, fieldDefs);
43         instance = new BasicSortOrder(field);
44     }
45
46     /**
47      * Tears down after each test.
48      */

49     public void tearDown() throws Exception JavaDoc {}
50
51     /** Test of setDirection method, of class org.mmbase.storage.search.implementation.BasicSortOrder. */
52     public void testSetDirection() {
53         // Default is SortOrder.ASCENDING.
54
assertTrue(instance.getDirection() == SortOrder.ORDER_ASCENDING);
55
56         // Invalid value, should throw IllegalArgumentException.
57
try {
58             instance.setDirection(-1);
59             fail("Invalid value, should throw IllegalArgumentException.");
60         } catch (IllegalArgumentException JavaDoc e) {}
61
62         BasicSortOrder result
63             = instance.setDirection(SortOrder.ORDER_DESCENDING);
64         assertTrue(instance.getDirection() == SortOrder.ORDER_DESCENDING);
65         assertTrue(result == instance);
66     }
67
68     /** Test of getField method, of class org.mmbase.storage.search.implementation.BasicSortOrder. */
69     public void testGetField() {
70         assertTrue(instance.getField() == field);
71     }
72
73     /** Test of getDirection method, of class org.mmbase.storage.search.implementation.BasicSortOrder. */
74     public void testGetDirection() {
75         // Same as:
76
testSetDirection();
77     }
78
79     /** Test of equals method, of class org.mmbase.storage.search.implementation.BasicSortOrder. */
80     public void testEquals() {
81         // TODO: implement test
82
}
83
84     /** Test of hashCode method, of class org.mmbase.storage.search.implementation.BasicSortOrder. */
85     public void testHashCode() {
86         // TODO: implement test
87
}
88
89
90     public static Test suite() {
91         TestSuite suite = new TestSuite(BasicSortOrderTest.class);
92
93         return suite;
94     }
95
96 }
97
Popular Tags