KickJava   Java API By Example, From Geeks To Geeks.

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


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 BasicAggregatedFieldTest extends TestCase {
15
16     private final static String JavaDoc IMAGES = "images";
17     private final static String JavaDoc TITLE = "title";
18
19     /** Test instance. */
20     private BasicAggregatedField instance;
21
22     /** Associated step. */
23     private BasicStep step;
24
25     /** MMBase instance. */
26     private MMBase mmbase = null;
27
28     /** Builder. */
29     private MMObjectBuilder images = null;
30
31     /** FieldDefs. */
32     private FieldDefs fieldDefs = null;
33
34     public BasicAggregatedFieldTest(java.lang.String JavaDoc testName) {
35         super(testName);
36     }
37
38     public static void main(java.lang.String JavaDoc[] args) {
39         junit.textui.TestRunner.run(suite());
40         System.exit(0);
41     }
42
43     /**
44      * Sets up before each test.
45      */

46     public void setUp() throws Exception JavaDoc {
47         MMBaseContext.init();
48         mmbase = MMBase.getMMBase();
49         images = mmbase.getBuilder(IMAGES);
50         fieldDefs = images.getField(TITLE);
51         step = new BasicStep(images);
52         instance = new BasicAggregatedField(step, fieldDefs,
53         AggregatedField.AGGREGATION_TYPE_MAX);
54     }
55
56     /**
57      * Tears down after each test.
58      */

59     public void tearDown() throws Exception JavaDoc {}
60
61     /** Test of setAggregationType method, of class org.mmbase.storage.search.implementation.BasicAggregatedField. */
62     public void testSetAggregationType() {
63         assertTrue(instance.getAggregationType()
64         == AggregatedField.AGGREGATION_TYPE_MAX);
65         BasicAggregatedField result =
66             instance.setAggregationType(
67                 AggregatedField.AGGREGATION_TYPE_GROUP_BY);
68         assertTrue(instance.getAggregationType()
69             == AggregatedField.AGGREGATION_TYPE_GROUP_BY);
70         assertTrue(result == instance);
71
72         try {
73             // Invalid aggregation type, should throw IllegalArgumentException.
74
instance.setAggregationType(0);
75             fail("Invalid aggregation type, should throw IllegalArgumentException.");
76             instance.setAggregationType(6);
77             fail("Invalid aggregation type, should throw IllegalArgumentException.");
78         } catch (IllegalArgumentException JavaDoc e) {}
79     }
80
81     /** Test of getAggregationType method, of class org.mmbase.storage.search.implementation.BasicAggregatedField. */
82     public void testGetAggregationType() {
83         // Same as:
84
testSetAggregationType();
85     }
86
87     /** Test of equals method, of class org.mmbase.storage.search.implementation.BasicAggregatedField. */
88     public void testEquals() {
89         // TODO: implement
90
}
91
92     /** Test of hashCode method, of class org.mmbase.storage.search.implementation.BasicAggregatedField. */
93     public void testHashCode() {
94         // TODO: implement
95
}
96
97     public static Test suite() {
98         TestSuite suite = new TestSuite(BasicAggregatedFieldTest.class);
99
100         return suite;
101     }
102
103 }
104
Popular Tags