1 package org.mmbase.storage.search.implementation; 2 3 import junit.framework.*; 4 import org.mmbase.module.core.*; 5 import org.mmbase.module.corebuilders.InsRel; 6 import org.mmbase.storage.search.*; 7 import org.mmbase.module.core.MMObjectBuilder; 8 9 15 public class BasicRelationStepTest extends TestCase { 16 17 private final static String TEST_BUILDER1 = "images"; 18 private final static String TEST_BUILDER2 = "news"; 19 private final static String INSREL = "posrel"; 20 private final static String TEST_ALIAS = "test"; 21 private final static Integer TEST_ROLE = new Integer (123456); 22 23 24 private BasicRelationStep instance = null; 25 26 27 private Step previous = null; 28 29 30 private Step next = null; 31 32 33 private MMBase mmbase = null; 34 35 public BasicRelationStepTest(java.lang.String testName) { 36 super(testName); 37 } 38 39 public static void main(java.lang.String [] args) { 40 junit.textui.TestRunner.run(suite()); 41 System.exit(0); 42 } 43 44 47 public void setUp() throws Exception { 48 MMBaseContext.init(); 49 mmbase = MMBase.getMMBase(); 50 MMObjectBuilder builder1 = mmbase.getBuilder(TEST_BUILDER1); 51 MMObjectBuilder builder2 = mmbase.getBuilder(TEST_BUILDER2); 52 InsRel relation = (InsRel) mmbase.getBuilder(INSREL); 53 previous = new BasicStep(builder1); 54 next = new BasicStep(builder2); 55 instance = new BasicRelationStep(relation, previous, next); 56 } 57 58 61 public void tearDown() throws Exception {} 62 63 64 public void testSetCheckedDirectionality() { 65 assertTrue(!instance.getCheckedDirectionality()); 67 68 instance.setCheckedDirectionality(true); 69 assertTrue(instance.getCheckedDirectionality()); 70 71 BasicRelationStep result = instance.setCheckedDirectionality(false); 72 assertTrue(!instance.getCheckedDirectionality()); 73 assertTrue(result == instance); 74 } 75 76 77 public void testSetDirectionality() { 78 assertTrue(instance.getDirectionality() == RelationStep.DIRECTIONS_BOTH); 80 81 try { 83 instance.setDirectionality(-1); 84 fail("Invalid value, should throw IllegalArgumentException"); 85 } catch (IllegalArgumentException e) {} 86 87 instance.setDirectionality(RelationStep.DIRECTIONS_SOURCE); 88 assertTrue(instance.getDirectionality() == RelationStep.DIRECTIONS_SOURCE); 89 90 BasicRelationStep result 91 = instance.setDirectionality(RelationStep.DIRECTIONS_DESTINATION); 92 assertTrue(instance.getDirectionality() == RelationStep.DIRECTIONS_DESTINATION); 93 assertTrue(result == instance); 94 } 95 96 97 public void testGetCheckedDirectionality() { 98 testSetCheckedDirectionality(); 100 } 101 102 103 public void testGetDirectionality() { 104 testSetDirectionality(); 106 } 107 108 109 public void testSetRole() { 110 assertTrue(instance.getRole() == null); 112 113 instance.setRole(TEST_ROLE); 114 assertTrue(instance.getRole().equals(TEST_ROLE)); 115 116 BasicRelationStep result = instance.setRole(null); 117 assertTrue(instance.getRole() == null); 118 assertTrue(result == instance); 119 120 } 121 122 123 public void testGetRole() { 124 testSetRole(); 126 } 127 128 129 public void testGetPrevious() { 130 Step step1 = instance.getPrevious(); 131 assertTrue(step1 != null); 132 assertTrue(step1.equals(previous)); 133 } 134 135 136 public void testGetNext() { 137 Step step2 = instance.getNext(); 138 assertTrue(next != null); 139 assertTrue(step2.equals(next)); 140 } 141 142 143 public void testEquals() { 144 } 146 147 148 public void testHashCode() { 149 } 151 152 153 public static Test suite() { 154 TestSuite suite = new TestSuite(BasicRelationStepTest.class); 155 156 return suite; 157 } 158 159 } 160 | Popular Tags |