KickJava   Java API By Example, From Geeks To Geeks.

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


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.4 $
13  */

14 public class BasicCompareFieldsConstraintTest extends TestCase {
15
16     private final static String JavaDoc BUILDER_NAME = "images";
17     private final static String JavaDoc STRING_FIELD_NAME = "owner";
18     private final static String JavaDoc INTEGER_FIELD_NAME = "number";
19     private final static String JavaDoc BUILDER_NAME2 = "news";
20     private final static String JavaDoc STRING_FIELD_NAME2 = "owner";
21     private final static String JavaDoc INTEGER_FIELD_NAME2 = "number";
22
23     /** Test instance. */
24     private BasicCompareFieldsConstraint instance = null;
25
26     /** MMBase instance. */
27     private MMBase mmbase = null;
28
29     /** String type Field instance. */
30     private BasicStepField stringField = null;
31
32     /** Integer type Field instance. */
33     private StepField integerField = null;
34
35     /** Builder example. */
36     private MMObjectBuilder builder = null;
37
38     /** FieldDefs example (string type). */
39     private FieldDefs stringFieldDefs = null;
40
41     /** FieldDefs example (integer type). */
42     private FieldDefs integerFieldDefs = null;
43
44     /** Second string type Field instance. */
45     private BasicStepField stringField2 = null;
46
47     /** Second builder example. */
48     private MMObjectBuilder builder2 = null;
49
50     /** Second string FieldDefs example. */
51     private FieldDefs stringFieldDefs2 = null;
52
53     /** Second integer FieldDefs example. */
54     private FieldDefs integerFieldDefs2 = null;
55
56     public BasicCompareFieldsConstraintTest(java.lang.String JavaDoc testName) {
57         super(testName);
58     }
59
60     public static void main(java.lang.String JavaDoc[] args) {
61         junit.textui.TestRunner.run(suite());
62     }
63
64     /**
65      * Sets up before each test.
66      */

67     public void setUp() throws Exception JavaDoc {
68         MMBaseContext.init();
69         mmbase = MMBase.getMMBase();
70         builder = mmbase.getBuilder(BUILDER_NAME);
71         Step step = new BasicStep(builder);
72         stringFieldDefs = builder.getField(STRING_FIELD_NAME);
73         stringField = new BasicStepField(step, stringFieldDefs);
74         integerFieldDefs = builder.getField(INTEGER_FIELD_NAME);
75         integerField = new BasicStepField(step, integerFieldDefs);
76         builder2 = mmbase.getBuilder(BUILDER_NAME2);
77         Step step2 = new BasicStep(builder2);
78         stringFieldDefs2 = builder2.getField(STRING_FIELD_NAME2);
79         stringField2 = new BasicStepField(step2, stringFieldDefs2);
80         integerFieldDefs2 = builder2.getField(INTEGER_FIELD_NAME2);
81         integerField = new BasicStepField(step2, integerFieldDefs2);
82         instance = new BasicCompareFieldsConstraint(stringField, stringField2);
83     }
84
85     /**
86      * Tears down after each test.
87      */

88     public void tearDown() throws Exception JavaDoc {}
89
90     /** Tests constructor. */
91     public void testConstructor() {
92         try {
93             // Null field2, should throw IllegalArgumentException.
94
new BasicCompareFieldsConstraint(stringField, null);
95             fail("Null field2, should throw IllegalArgumentException.");
96         } catch (IllegalArgumentException JavaDoc e) {}
97
98         try {
99             // Different field types, should throw IllegalArgumentException.
100
new BasicCompareFieldsConstraint(stringField, integerField);
101             fail("Different field types, should throw IllegalArgumentException.");
102         } catch (IllegalArgumentException JavaDoc e) {}
103         try {
104             // Different field types, should throw IllegalArgumentException.
105
new BasicCompareFieldsConstraint(integerField, stringField2);
106             fail("Different field types, should throw IllegalArgumentException.");
107         } catch (IllegalArgumentException JavaDoc e) {}
108
109     }
110
111     /** Test of getField2 method, of class org.mmbase.storage.search.implementation.BasicCompareFieldsConstraint. */
112     public void testGetField2() {
113         assertTrue(instance.getField2() == stringField2);
114     }
115
116     /** Test of getBasicSupportLevel method. */
117     public void testGetBasicSupportLevel() {
118         // Returns SUPPORT_OPTIMAL.
119
assertTrue(instance.getBasicSupportLevel() == SearchQueryHandler.SUPPORT_OPTIMAL);
120     }
121
122     /** Test of equals method, of class org.mmbase.storage.search.implementation.BasicCompareFieldsConstraint. */
123     public void testEquals() {
124         // TODO: implement test
125
}
126
127     /** Test of hashCode method, of class org.mmbase.storage.search.implementation.BasicCompareFieldsConstraint. */
128     public void testHashCode() {
129         // TODO: implement test
130
}
131     public static Test suite() {
132         TestSuite suite = new TestSuite(BasicCompareFieldsConstraintTest.class);
133
134         return suite;
135     }
136
137 }
138
Popular Tags