1 package org.mmbase.storage.search.implementation; 2 3 import junit.framework.*; 4 5 11 public class BasicLegacyConstraintTest extends TestCase { 12 13 private final static String [] TEST_CONSTRAINTS = new String [] { 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 testName) { 20 super(testName); 21 } 22 23 public static void main(java.lang.String [] args) { 24 junit.textui.TestRunner.run(suite()); 25 } 26 27 30 public void setUp() throws Exception { 31 instance = new BasicLegacyConstraint("a=1 and b=2"); 32 } 33 34 37 public void tearDown() throws Exception {} 38 39 40 public void testSetConstraint() { 41 try { 42 new BasicLegacyConstraint(null); 44 fail("Null constraint, should throw IllegalArgumentException."); 45 } catch (IllegalArgumentException e) {} 46 47 try { 48 new BasicLegacyConstraint(""); 50 fail("Null constraint, should throw IllegalArgumentException."); 51 } catch (IllegalArgumentException e) {} 52 53 BasicLegacyConstraint instance = new BasicLegacyConstraint("xxx"); 54 for (int i = 0; i < TEST_CONSTRAINTS.length; i++) { 55 String constraint = TEST_CONSTRAINTS[i]; 56 BasicLegacyConstraint result = instance.setConstraint(constraint); 57 assertTrue(instance.getConstraint().equals(constraint)); 58 assertTrue(result == instance); 59 } 60 } 61 62 63 public void testGetConstraint() { 64 testSetConstraint(); 66 } 67 68 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 83 public void testEquals() { 84 } 86 87 88 public void testHashCode() { 89 } 91 92 public static Test suite() { 93 TestSuite suite = new TestSuite(BasicLegacyConstraintTest.class); 94 95 return suite; 96 } 97 98 } 99 | Popular Tags |