1 10 11 package org.mmbase.bridge; 12 13 import java.util.Iterator ; 14 import org.mmbase.tests.*; 15 16 22 public abstract class NodeTest extends BridgeTest { 23 protected Node node; 24 protected static String [] fieldTypes = {"byte", "double", "float", "int", "long", "string", "xml", "node", "datetime", "boolean"}; 27 public NodeTest(String name) { 28 super(name); 29 } 30 31 protected String getNodeManager() { 32 return "aa"; 33 } 34 35 abstract public void testGetValue(); 36 37 public void testGetValueCache() { 38 testGetValue(); 40 testGetByteValue(); 41 testGetDoubleValue(); 42 testGetFloatValue(); 43 testGetIntValue(); 44 testGetLongValue(); 45 testGetStringValue(); 46 testGetXMLValue(); 47 testGetNodeValue(); 48 testGetBooleanValue(); 49 testGetDateTimeValue(); 50 testGetListValue(); 51 } 52 53 abstract public void testGetByteValue(); 54 55 public void testGetByteValueCache() { 56 testGetByteValue(); 58 testGetValue(); 59 testGetDoubleValue(); 60 testGetFloatValue(); 61 testGetIntValue(); 62 testGetLongValue(); 63 testGetStringValue(); 64 testGetXMLValue(); 65 testGetNodeValue(); 66 testGetBooleanValue(); 67 testGetDateTimeValue(); 68 testGetListValue(); 69 } 70 71 abstract public void testGetDoubleValue(); 72 73 public void testGetDoubleValueCache() { 74 testGetDoubleValue(); 76 testGetValue(); 77 testGetByteValue(); 78 testGetFloatValue(); 79 testGetIntValue(); 80 testGetLongValue(); 81 testGetStringValue(); 82 testGetXMLValue(); 83 testGetNodeValue(); 84 testGetBooleanValue(); 85 testGetDateTimeValue(); 86 testGetListValue(); 87 } 88 89 abstract public void testGetFloatValue(); 90 91 public void testGetFloatValueCache() { 92 testGetFloatValue(); 94 testGetValue(); 95 testGetByteValue(); 96 testGetDoubleValue(); 97 testGetIntValue(); 98 testGetLongValue(); 99 testGetStringValue(); 100 testGetXMLValue(); 101 testGetNodeValue(); 102 } 103 104 abstract public void testGetIntValue(); 105 106 public void testGetIntValueCache() { 107 testGetIntValue(); 109 testGetValue(); 110 testGetByteValue(); 111 testGetDoubleValue(); 112 testGetFloatValue(); 113 testGetLongValue(); 114 testGetStringValue(); 115 testGetXMLValue(); 116 testGetNodeValue(); 117 testGetBooleanValue(); 118 testGetDateTimeValue(); 119 testGetListValue(); 120 } 121 122 abstract public void testGetLongValue(); 123 124 public void testGetLongValueCache() { 125 testGetLongValue(); 127 testGetValue(); 128 testGetByteValue(); 129 testGetDoubleValue(); 130 testGetFloatValue(); 131 testGetIntValue(); 132 testGetStringValue(); 133 testGetXMLValue(); 134 testGetNodeValue(); 135 testGetBooleanValue(); 136 testGetDateTimeValue(); 137 testGetListValue(); 138 } 139 140 abstract public void testGetStringValue(); 141 142 public void testGetStringValueCache() { 143 testGetStringValue(); 145 testGetValue(); 146 testGetByteValue(); 147 testGetDoubleValue(); 148 testGetFloatValue(); 149 testGetIntValue(); 150 testGetLongValue(); 151 testGetXMLValue(); 152 testGetNodeValue(); 153 testGetBooleanValue(); 154 testGetDateTimeValue(); 155 testGetListValue(); 156 } 157 158 abstract public void testGetXMLValue(); 159 160 public void testGetXMLValueCache() { 161 testGetXMLValue(); 163 testGetValue(); 164 testGetByteValue(); 165 testGetDoubleValue(); 166 testGetFloatValue(); 167 testGetIntValue(); 168 testGetLongValue(); 169 testGetStringValue(); 170 testGetNodeValue(); 171 testGetBooleanValue(); 172 testGetDateTimeValue(); 173 testGetListValue(); 174 } 175 176 abstract public void testGetNodeValue(); 177 178 public void testGetNodeValueCache() { 179 testGetNodeValue(); 181 testGetValue(); 182 testGetByteValue(); 183 testGetDoubleValue(); 184 testGetFloatValue(); 185 testGetIntValue(); 186 testGetLongValue(); 187 testGetStringValue(); 188 testGetXMLValue(); 189 testGetBooleanValue(); 190 testGetDateTimeValue(); 191 testGetListValue(); 192 } 193 194 abstract public void testGetBooleanValue(); 195 196 public void testGetBooleanValueCache() { 197 testGetBooleanValue(); 199 testGetValue(); 200 testGetByteValue(); 201 testGetDoubleValue(); 202 testGetFloatValue(); 203 testGetIntValue(); 204 testGetLongValue(); 205 testGetStringValue(); 206 testGetXMLValue(); 207 testGetNodeValue(); 208 testGetDateTimeValue(); 209 testGetListValue(); 210 } 211 212 abstract public void testGetDateTimeValue(); 213 214 public void testGetDateTimeValueCache() { 215 testGetDateTimeValue(); 217 testGetValue(); 218 testGetByteValue(); 219 testGetDoubleValue(); 220 testGetFloatValue(); 221 testGetIntValue(); 222 testGetLongValue(); 223 testGetStringValue(); 224 testGetXMLValue(); 225 testGetNodeValue(); 226 testGetBooleanValue(); 227 testGetListValue(); 228 } 229 230 abstract public void testGetListValue(); 231 232 public void testGetListValueCache() { 233 testGetListValue(); 235 testGetValue(); 236 testGetByteValue(); 237 testGetDoubleValue(); 238 testGetFloatValue(); 239 testGetIntValue(); 240 testGetLongValue(); 241 testGetStringValue(); 242 testGetXMLValue(); 243 testGetNodeValue(); 244 testGetBooleanValue(); 245 testGetDateTimeValue(); 246 } 247 248 public void testSetSNumber() { 249 try { 250 node.setIntValue("snumber", 100); 251 fail("Should raise a BridgeException"); 252 } catch (BridgeException e) { 253 } 254 } 255 256 public void testSetDNumber() { 257 try { 258 node.setIntValue("dnumber", 100); 259 fail("Should raise a BridgeException"); 260 } catch (BridgeException e) { 261 } 262 } 263 264 public void testSetRNumber() { 265 try { 266 node.setIntValue("rnumber", 100); 267 fail("Should raise a BridgeException"); 268 } catch (BridgeException e) { 269 } 270 } 271 272 273 public void testSetOType() { 274 try { 275 node.setIntValue("otype", 100); 276 fail("Should raise a BridgeException"); 277 } catch (BridgeException e) { 278 } 279 } 280 281 public void testCreateAlias() { 282 node.createAlias("node_alias"); 283 node.commit(); 284 boolean found = false; 286 Iterator i = node.getAliases().iterator(); 287 while (i.hasNext()) { 288 String alias = (String )i.next(); 289 if ("node_alias".equals(alias)) found = true; 290 } 291 assertTrue(found); 292 } 293 294 protected String getOtherContext(Node n) { 295 String context = n.getContext(); 296 StringIterator possibleContexts = n.getPossibleContexts().stringIterator(); 297 while (possibleContexts.hasNext()) { 298 String listContext = possibleContexts.nextString(); 299 if (! context.equals(listContext)){ 300 return listContext; 301 } 302 } 303 return context; 304 } 305 306 307 public void testSetContext() { 308 309 String context = node.getContext(); 310 String otherContext = getOtherContext(node); 311 312 if (otherContext.equals(context)) { 313 otherContext = context + "other"; 314 System.err.println("Could not find other context than " + context + ", setting to '" + otherContext + "'"); 315 } 316 317 node.setContext(otherContext); 319 assertEquals("Context did not change '" + otherContext + "' != '" + node.getContext() + "'", otherContext, node.getContext()); 321 assertEquals(node.getContext(), node.getValue("owner")); 322 node.commit(); 323 324 assertEquals("Context did not change '" + otherContext + "' != '" + node.getContext() + "'", otherContext, node.getContext()); 325 assertEquals(node.getContext(), node.getValue("owner")); 326 } 327 328 public void testSetOwner() { 329 String context = node.getContext(); 330 String otherContext = getOtherContext(node); 331 332 if (otherContext.equals(context)) { 333 otherContext = context + "other"; 334 System.err.println("Could not find other context than " + context + ", setting to '" + otherContext + "'"); 335 } 336 337 node.setValue("owner", otherContext); 339 assertEquals("Context did not change '" + otherContext + "' != '" + node.getContext() + "'", otherContext, node.getContext()); 341 assertEquals(node.getContext(), node.getValue("owner")); 342 343 node.commit(); 344 345 assertEquals("Context did not change '" + otherContext + "' != '" + node.getContext() + "'", otherContext, node.getContext()); 346 assertEquals(node.getContext(), node.getValue("owner")); 347 348 349 } 350 351 public void testFieldGUI() { 352 try { 353 node.getStringValue("gui()"); 354 node.getValue("gui()"); 355 } catch (Throwable e) { 356 fail("Should not raise exception but gave: " + e.getMessage() + org.mmbase.util.logging.Logging.stackTrace(e, 20)); 357 } 358 } 359 360 } 361 | Popular Tags |