KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.mmbase.storage.search.implementation;
2
3 import junit.framework.*;
4
5 /**
6  * JUnit tests.
7  *
8  * @author Rob van Maris
9  * @version $Revision: 1.3 $
10  */

11 public class BasicLegacyConstraintTest extends TestCase {
12     
13     private final static String JavaDoc[] TEST_CONSTRAINTS = new String JavaDoc[] {
14         "a=1 and b=2", "kjdfd", "c between d and e"
15     };
16     
17     private BasicLegacyConstraint instance = null;
18     
19     public BasicLegacyConstraintTest(java.lang.String JavaDoc testName) {
20         super(testName);
21     }
22     
23     public static void main(java.lang.String JavaDoc[] args) {
24         junit.textui.TestRunner.run(suite());
25     }
26     
27     /**
28      * Sets up before each test.
29      */

30     public void setUp() throws Exception JavaDoc {
31         instance = new BasicLegacyConstraint("a=1 and b=2");
32     }
33     
34     /**
35      * Tears down after each test.
36      */

37     public void tearDown() throws Exception JavaDoc {}
38     
39     /** Test of setConstraint method, of class org.mmbase.storage.search.implementation.BasicLegacyConstraint. */
40     public void testSetConstraint() {
41         try {
42             // Null constraint, should throw InvalidArgumentException.
43
new BasicLegacyConstraint(null);
44             fail("Null constraint, should throw IllegalArgumentException.");
45         } catch (IllegalArgumentException JavaDoc e) {}
46         
47         try {
48             // Empty constraint, should throw InvalidArgumentException.
49
new BasicLegacyConstraint("");
50             fail("Null constraint, should throw IllegalArgumentException.");
51         } catch (IllegalArgumentException JavaDoc e) {}
52         
53         BasicLegacyConstraint instance = new BasicLegacyConstraint("xxx");
54         for (int i = 0; i < TEST_CONSTRAINTS.length; i++) {
55             String JavaDoc constraint = TEST_CONSTRAINTS[i];
56             BasicLegacyConstraint result = instance.setConstraint(constraint);
57             assertTrue(instance.getConstraint().equals(constraint));
58             assertTrue(result == instance);
59         }
60     }
61     
62     /** Test of getConstraint method, of class org.mmbase.storage.search.implementation.BasicLegacyConstraint. */
63     public void testGetConstraint() {
64         // Same as:
65
testSetConstraint();
66     }
67     
68     /** Test of toString method, of class org.mmbase.storage.search.implementation.BasicLegacyConstraint. */
69     public void testToString() {
70         assertTrue(instance.toString(),
71         instance.toString().equals("LegacyConstraint(inverse:"
72         + instance.isInverse() + ", constraint:"
73         + instance.getConstraint() + ")"));
74         
75         instance.setInverse(true);
76         assertTrue(instance.toString(),
77         instance.toString().equals("LegacyConstraint(inverse:"
78         + instance.isInverse() + ", constraint:"
79         + instance.getConstraint() + ")"));
80     }
81     
82     /** Test of equals method, of class org.mmbase.storage.search.implementation.BasicLegacyConstraint. */
83     public void testEquals() {
84         // TODO: implement test
85
}
86     
87     /** Test of hashCode method, of class org.mmbase.storage.search.implementation.BasicLegacyConstraint. */
88     public void testHashCode() {
89         // TODO: implement test
90
}
91     
92     public static Test suite() {
93         TestSuite suite = new TestSuite(BasicLegacyConstraintTest.class);
94         
95         return suite;
96     }
97     
98 }
99
Popular Tags