1 4 package com.tc.config.schema.dynamic; 5 6 import org.apache.xmlbeans.XmlObject; 7 8 import com.tc.config.schema.MockXmlObject; 9 import com.tc.config.schema.context.ConfigContext; 10 import com.tc.config.schema.context.MockConfigContext; 11 import com.tc.test.TCTestCase; 12 import com.tc.util.TCAssertionError; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 20 public class XPathBasedConfigItemTest extends TCTestCase { 21 22 private static class TestXPathBasedConfigItem extends XPathBasedConfigItem { 23 private int numFetchDataFromXmlObjects; 24 private List lastXmlObjects; 25 private Object [] returnedFetchDataFromXmlObject; 26 private int returnedFetchDataFromXmlObjectPos; 27 28 public TestXPathBasedConfigItem(ConfigContext context, String xpath, Object defaultValue) { 29 super(context, xpath, defaultValue); 30 this.lastXmlObjects = new ArrayList (); 31 this.returnedFetchDataFromXmlObject = null; 32 reset(); 33 } 34 35 public TestXPathBasedConfigItem(ConfigContext context, String xpath) { 36 super(context, xpath); 37 this.lastXmlObjects = new ArrayList (); 38 this.returnedFetchDataFromXmlObject = null; 39 reset(); 40 } 41 42 public void reset() { 43 this.numFetchDataFromXmlObjects = 0; 44 this.lastXmlObjects.clear(); 45 this.returnedFetchDataFromXmlObjectPos = 0; 46 } 47 48 protected Object fetchDataFromXmlObject(XmlObject xmlObject) { 49 ++this.numFetchDataFromXmlObjects; 50 this.lastXmlObjects.add(xmlObject); 51 int numReturned = this.returnedFetchDataFromXmlObject == null ? 0 : this.returnedFetchDataFromXmlObject.length; 52 if (this.returnedFetchDataFromXmlObjectPos >= numReturned) this.returnedFetchDataFromXmlObjectPos = 0; 53 if (this.returnedFetchDataFromXmlObject == null) return null; 54 else return this.returnedFetchDataFromXmlObject[this.returnedFetchDataFromXmlObjectPos++]; 55 } 56 57 public XmlObject getLastXmlObject() { 58 return (XmlObject) this.lastXmlObjects.get(this.lastXmlObjects.size() - 1); 59 } 60 61 public int getNumFetchDataFromXmlObjects() { 62 return numFetchDataFromXmlObjects; 63 } 64 65 public XmlObject[] getLastXmlObjects() { 66 return (XmlObject[]) this.lastXmlObjects.toArray(new XmlObject[this.lastXmlObjects.size()]); 67 } 68 69 public void setReturnedFetchDataFromXmlObject(Object [] returnedFetchDataFromXmlObject) { 70 this.returnedFetchDataFromXmlObject = returnedFetchDataFromXmlObject; 71 } 72 } 73 74 private MockConfigContext context; 75 private String xpath; 76 77 private TestXPathBasedConfigItem item; 78 79 private MockXmlObject bean; 80 private MockXmlObject subBean; 81 private Object convertedValue; 82 83 private MockConfigItemListener listener1; 84 private MockConfigItemListener listener2; 85 86 public void setUp() throws Exception { 87 this.context = new MockConfigContext(); 88 this.xpath = "foobar/baz"; 89 90 this.item = new TestXPathBasedConfigItem(this.context, this.xpath); 91 92 this.bean = new MockXmlObject(); 93 this.context.setReturnedBean(this.bean); 94 95 this.subBean = new MockXmlObject(); 96 this.bean.setReturnedSelectPath(new XmlObject[] { this.subBean }); 97 98 this.convertedValue = new Object (); 99 this.item.setReturnedFetchDataFromXmlObject(new Object [] { this.convertedValue }); 100 101 this.listener1 = new MockConfigItemListener(); 102 this.listener2 = new MockConfigItemListener(); 103 104 this.item.defaultValue(); } 106 107 public void testConstruction() throws Exception { 108 try { 109 new TestXPathBasedConfigItem(null, this.xpath); 110 fail("Didn't get NPE on no context"); 111 } catch (NullPointerException npe) { 112 } 114 115 try { 116 new TestXPathBasedConfigItem(this.context, null); 117 fail("Didn't get NPE on no XPath"); 118 } catch (NullPointerException npe) { 119 } 121 122 try { 123 new TestXPathBasedConfigItem(this.context, ""); 124 fail("Didn't get IAE on empty context"); 125 } catch (IllegalArgumentException iae) { 126 } 128 129 try { 130 new TestXPathBasedConfigItem(this.context, " "); 131 fail("Didn't get TCAE on blank context"); 132 } catch (IllegalArgumentException iae) { 133 } 135 } 136 137 public void testInitialSetup() throws Exception { 138 assertEquals(1, this.context.getNumItemCreateds()); 139 assertSame(this.item, this.context.getLastItemCreated()); 140 141 assertEquals(1, this.context.getNumHasDefaultFors()); 142 assertEquals(this.xpath, this.context.getLastHasDefaultForXPath()); 143 144 assertEquals(0, this.context.getNumBeans()); 145 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 146 } 147 148 public void testComponents() throws Exception { 149 assertSame(this.context, this.item.context()); 150 assertSame(this.xpath, this.item.xpath()); 151 assertNull(this.item.defaultValue()); 152 } 153 154 public void testFetchObject() throws Exception { 155 assertEquals(0, this.context.getNumBeans()); 156 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 157 assertEquals(0, this.bean.getNumSelectPaths()); 158 159 this.context.reset(); 160 161 assertEquals(0, this.context.getNumItemCreateds()); 162 assertEquals(0, this.context.getNumHasDefaultFors()); 163 164 assertSame(this.convertedValue, this.item.getObject()); 165 166 assertEquals(0, this.context.getNumItemCreateds()); 167 assertEquals(0, this.context.getNumHasDefaultFors()); 168 assertEquals(1, this.context.getNumBeans()); 169 assertEquals(1, this.bean.getNumSelectPaths()); 170 assertEquals(this.xpath, this.bean.getLastSelectPath()); 171 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 172 assertSame(this.subBean, this.item.getLastXmlObject()); 173 174 this.context.reset(); 176 this.bean.reset(); 177 this.item.reset(); 178 179 assertSame(this.convertedValue, this.item.getObject()); 180 assertEquals(0, this.context.getNumItemCreateds()); 181 assertEquals(0, this.context.getNumHasDefaultFors()); 182 assertEquals(0, this.context.getNumBeans()); 183 assertEquals(0, this.bean.getNumSelectPaths()); 184 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 185 } 186 187 public void testFetchObjectWithDefaultsWithValue() throws Exception { 188 Object defaultValue = new Object (); 189 190 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 191 this.item.setReturnedFetchDataFromXmlObject(new Object [] { this.convertedValue }); 192 193 assertEquals(0, this.context.getNumBeans()); 194 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 195 assertEquals(0, this.bean.getNumSelectPaths()); 196 197 this.context.reset(); 198 199 assertEquals(0, this.context.getNumItemCreateds()); 200 assertEquals(0, this.context.getNumHasDefaultFors()); 201 202 assertSame(this.convertedValue, this.item.getObject()); 203 204 assertEquals(0, this.context.getNumItemCreateds()); 205 assertEquals(0, this.context.getNumHasDefaultFors()); 206 assertEquals(1, this.context.getNumBeans()); 207 assertEquals(1, this.bean.getNumSelectPaths()); 208 assertEquals(this.xpath, this.bean.getLastSelectPath()); 209 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 210 assertSame(this.subBean, this.item.getLastXmlObject()); 211 212 this.context.reset(); 214 this.bean.reset(); 215 this.item.reset(); 216 217 assertSame(this.convertedValue, this.item.getObject()); 218 assertEquals(0, this.context.getNumItemCreateds()); 219 assertEquals(0, this.context.getNumHasDefaultFors()); 220 assertEquals(0, this.context.getNumBeans()); 221 assertEquals(0, this.bean.getNumSelectPaths()); 222 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 223 } 224 225 public void testFetchObjectWithDefaultsWithNoValueInXPath() throws Exception { 226 Object defaultValue = new Object (); 227 228 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 229 this.item.setReturnedFetchDataFromXmlObject(new Object [] { this.convertedValue }); 230 231 assertEquals(0, this.context.getNumBeans()); 232 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 233 assertEquals(0, this.bean.getNumSelectPaths()); 234 235 this.context.reset(); 236 237 assertEquals(0, this.context.getNumItemCreateds()); 238 assertEquals(0, this.context.getNumHasDefaultFors()); 239 240 this.bean.setReturnedSelectPath(null); 241 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 242 assertSame(defaultValue, this.item.getObject()); 243 244 assertEquals(1, this.context.getNumItemCreateds()); 245 assertEquals(0, this.context.getNumHasDefaultFors()); 246 assertEquals(1, this.context.getNumBeans()); 247 assertEquals(1, this.bean.getNumSelectPaths()); 248 assertEquals(this.xpath, this.bean.getLastSelectPath()); 249 250 this.context.reset(); 252 this.bean.reset(); 253 this.item.reset(); 254 255 assertSame(defaultValue, this.item.getObject()); 256 assertEquals(0, this.context.getNumItemCreateds()); 257 assertEquals(0, this.context.getNumHasDefaultFors()); 258 assertEquals(0, this.context.getNumBeans()); 259 assertEquals(0, this.bean.getNumSelectPaths()); 260 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 261 } 262 263 public void testFetchObjectWithDefaultsWithNoConvertedValue() throws Exception { 264 Object defaultValue = new Object (); 265 266 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 267 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null }); 268 269 assertEquals(0, this.context.getNumBeans()); 270 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 271 assertEquals(0, this.bean.getNumSelectPaths()); 272 273 this.context.reset(); 274 275 assertEquals(0, this.context.getNumItemCreateds()); 276 assertEquals(0, this.context.getNumHasDefaultFors()); 277 278 assertSame(defaultValue, this.item.getObject()); 279 280 assertEquals(0, this.context.getNumItemCreateds()); 281 assertEquals(0, this.context.getNumHasDefaultFors()); 282 assertEquals(1, this.context.getNumBeans()); 283 assertEquals(1, this.bean.getNumSelectPaths()); 284 assertEquals(this.xpath, this.bean.getLastSelectPath()); 285 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 286 assertSame(this.subBean, this.item.getLastXmlObject()); 287 288 this.context.reset(); 290 this.bean.reset(); 291 this.item.reset(); 292 293 assertSame(defaultValue, this.item.getObject()); 294 assertEquals(0, this.context.getNumItemCreateds()); 295 assertEquals(0, this.context.getNumHasDefaultFors()); 296 assertEquals(0, this.context.getNumBeans()); 297 assertEquals(0, this.bean.getNumSelectPaths()); 298 assertEquals(0, this.item.getNumFetchDataFromXmlObjects()); 299 } 300 301 public void testListenerDefaultBeforehandNoConvertedValue() throws Exception { 302 Object defaultValue = new Object (); 303 304 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 305 Object newValue = new Object (); 306 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null, newValue }); 307 308 this.context.reset(); 309 310 MockXmlObject newBean = new MockXmlObject(); 311 MockXmlObject newSubBean = new MockXmlObject(); 312 newBean.setReturnedSelectPath(new XmlObject[] { newSubBean }); 313 this.item.addListener(this.listener1); 314 315 this.item.configurationChanged(this.bean, newBean); 316 317 assertEquals(1, this.listener1.getNumValueChangeds()); 318 assertSame(defaultValue, this.listener1.getLastOldValue()); 319 assertSame(newValue, this.listener1.getLastNewValue()); 320 321 assertSame(newValue, this.item.getObject()); 322 } 323 324 public void testListenerDefaultBeforehandNoXPath() throws Exception { 325 Object defaultValue = new Object (); 326 327 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 328 Object newValue = new Object (); 329 this.bean.setReturnedSelectPath(null); 330 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null, newValue }); 331 332 this.context.reset(); 333 334 MockXmlObject newBean = new MockXmlObject(); 335 MockXmlObject newSubBean = new MockXmlObject(); 336 newBean.setReturnedSelectPath(new XmlObject[] { newSubBean }); 337 this.item.addListener(this.listener1); 338 339 this.item.configurationChanged(this.bean, newBean); 340 341 assertEquals(1, this.listener1.getNumValueChangeds()); 342 assertSame(defaultValue, this.listener1.getLastOldValue()); 343 assertSame(newValue, this.listener1.getLastNewValue()); 344 345 assertSame(newValue, this.item.getObject()); 346 } 347 348 public void testListenerDefaultAfterwardsNoConvertedValue() throws Exception { 349 Object defaultValue = new Object (); 350 351 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 352 this.item.setReturnedFetchDataFromXmlObject(new Object [] { this.convertedValue, null }); 353 354 this.context.reset(); 355 356 MockXmlObject newBean = new MockXmlObject(); 357 MockXmlObject newSubBean = new MockXmlObject(); 358 newBean.setReturnedSelectPath(new XmlObject[] { newSubBean }); 359 this.item.addListener(this.listener1); 360 361 this.item.configurationChanged(this.bean, newBean); 362 363 assertEquals(1, this.listener1.getNumValueChangeds()); 364 assertSame(this.convertedValue, this.listener1.getLastOldValue()); 365 assertSame(defaultValue, this.listener1.getLastNewValue()); 366 367 assertSame(defaultValue, this.item.getObject()); 368 } 369 370 public void testListenerDefaultAfterwardsNoXPath() throws Exception { 371 Object defaultValue = new Object (); 372 373 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 374 Object newValue = new Object (); 375 this.item.setReturnedFetchDataFromXmlObject(new Object [] { this.convertedValue, null, newValue }); 376 377 this.context.reset(); 378 379 MockXmlObject newBean = new MockXmlObject(); 380 newBean.setReturnedSelectPath(null); 381 this.item.addListener(this.listener1); 382 383 this.item.configurationChanged(this.bean, newBean); 384 385 assertEquals(1, this.listener1.getNumValueChangeds()); 386 assertSame(this.convertedValue, this.listener1.getLastOldValue()); 387 assertSame(defaultValue, this.listener1.getLastNewValue()); 388 389 assertSame(defaultValue, this.item.getObject()); 390 } 391 392 public void testListenerDefaultBeforeAndAfterNoConvertedValue() throws Exception { 393 Object defaultValue = new Object (); 394 395 this.item = new TestXPathBasedConfigItem(this.context, this.xpath, defaultValue); 396 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null, null }); 397 398 this.context.reset(); 399 400 MockXmlObject newBean = new MockXmlObject(); 401 MockXmlObject newSubBean = new MockXmlObject(); 402 newBean.setReturnedSelectPath(new XmlObject[] { newSubBean }); 403 this.item.addListener(this.listener1); 404 405 this.item.configurationChanged(this.bean, newBean); 406 407 assertEquals(0, this.listener1.getNumValueChangeds()); 408 409 assertSame(defaultValue, this.item.getObject()); 410 } 411 412 public void testPathReturnsRObjects() throws Exception { 413 this.context.reset(); 414 415 assertEquals(0, this.context.getNumItemCreateds()); 416 assertEquals(0, this.context.getNumHasDefaultFors()); 417 418 this.bean.setReturnedSelectPath(null); 419 420 assertSame(this.convertedValue, this.item.getObject()); 421 422 assertEquals(0, this.context.getNumItemCreateds()); 423 assertEquals(0, this.context.getNumHasDefaultFors()); 424 assertEquals(1, this.context.getNumBeans()); 425 assertEquals(1, this.bean.getNumSelectPaths()); 426 assertEquals(this.xpath, this.bean.getLastSelectPath()); 427 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 428 } 429 430 public void testPathReturnsZeroLengthArray() throws Exception { 431 this.context.reset(); 432 433 assertEquals(0, this.context.getNumItemCreateds()); 434 assertEquals(0, this.context.getNumHasDefaultFors()); 435 436 this.bean.setReturnedSelectPath(new XmlObject[0]); 437 438 assertSame(this.convertedValue, this.item.getObject()); 439 440 assertEquals(0, this.context.getNumItemCreateds()); 441 assertEquals(0, this.context.getNumHasDefaultFors()); 442 assertEquals(1, this.context.getNumBeans()); 443 assertEquals(1, this.bean.getNumSelectPaths()); 444 assertEquals(this.xpath, this.bean.getLastSelectPath()); 445 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 446 } 447 448 public void testPathReturnsMultipleObjects() throws Exception { 449 this.context.reset(); 450 451 assertEquals(0, this.context.getNumItemCreateds()); 452 assertEquals(0, this.context.getNumHasDefaultFors()); 453 454 this.bean.setReturnedSelectPath(new XmlObject[] { new MockXmlObject(), new MockXmlObject() }); 455 456 try { 457 this.item.getObject(); 458 fail("Didn't get TCAE on multiple return values"); 459 } catch (TCAssertionError tcae) { 460 } 462 } 463 464 public void testListeners() throws Exception { 465 checkListeners(false, false, false, null); 466 467 resetItem(); 468 this.item.addListener(this.listener1); 469 checkListeners(true, false, false, null); 470 471 resetItem(); 472 this.item.addListener(this.listener1); 473 this.item.addListener(this.listener2); 474 checkListeners(true, true, false, null); 475 476 resetItem(); 477 this.item.addListener(this.listener1); 478 this.item.addListener(this.listener2); 479 this.item.removeListener(this.listener1); 480 checkListeners(false, true, false, null); 481 482 resetItem(); 483 this.item.addListener(this.listener1); 484 this.item.addListener(this.listener2); 485 this.item.removeListener(this.listener1); 486 this.item.removeListener(this.listener2); 487 this.item.removeListener(this.listener2); 488 this.item.removeListener(this.listener1); 489 checkListeners(false, false, false, null); 490 } 491 492 public void testListenersWithDataAlready() throws Exception { 493 Object curVal = this.convertedValue; 494 495 assertSame(this.convertedValue, this.item.getObject()); 496 curVal = checkListeners(false, false, true, curVal); 497 498 this.item.addListener(this.listener1); 499 curVal = checkListeners(true, false, true, curVal); 500 501 this.item.addListener(this.listener2); 502 curVal = checkListeners(true, true, true, curVal); 503 504 this.item.removeListener(this.listener2); 505 curVal = checkListeners(true, false, true, curVal); 506 507 this.item.removeListener(this.listener1); 508 curVal = checkListeners(false, false, true, curVal); 509 510 this.item.removeListener(this.listener1); 511 curVal = checkListeners(false, false, true, curVal); 512 } 513 514 public void testNoListenerTriggerOnEqualObjects() throws Exception { 515 Integer one = new Integer (24); 516 Integer two = new Integer (24); 517 518 assertNotSame(one, two); 519 520 this.item.addListener(this.listener1); 521 this.item.setReturnedFetchDataFromXmlObject(new Object [] { one, two }); 522 523 MockXmlObject newBean = new MockXmlObject(); 524 newBean.setReturnedSelectPath(new XmlObject[] { new MockXmlObject() }); 525 526 this.item.configurationChanged(this.bean, newBean); 527 528 assertEquals(0, this.listener1.getNumValueChangeds()); 529 } 530 531 public void testNoListenerTriggerOnBothNull() throws Exception { 532 this.item.addListener(this.listener1); 533 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null, null }); 534 535 MockXmlObject newBean = new MockXmlObject(); 536 newBean.setReturnedSelectPath(new XmlObject[] { new MockXmlObject() }); 537 538 this.item.configurationChanged(this.bean, newBean); 539 540 assertEquals(0, this.listener1.getNumValueChangeds()); 541 } 542 543 public void testListenerTriggerOnNullToSomething() throws Exception { 544 Integer two = new Integer (24); 545 546 this.item.addListener(this.listener1); 547 this.item.setReturnedFetchDataFromXmlObject(new Object [] { null, two }); 548 549 MockXmlObject newBean = new MockXmlObject(); 550 newBean.setReturnedSelectPath(new XmlObject[] { new MockXmlObject() }); 551 552 this.item.configurationChanged(this.bean, newBean); 553 554 assertEquals(1, this.listener1.getNumValueChangeds()); 555 assertNull(this.listener1.getLastOldValue()); 556 assertSame(two, this.listener1.getLastNewValue()); 557 } 558 559 public void testListenerTriggerOnSomethingToNull() throws Exception { 560 Integer one = new Integer (24); 561 562 this.item.addListener(this.listener1); 563 this.item.setReturnedFetchDataFromXmlObject(new Object [] { one, null }); 564 565 MockXmlObject newBean = new MockXmlObject(); 566 newBean.setReturnedSelectPath(new XmlObject[] { new MockXmlObject() }); 567 568 this.item.configurationChanged(this.bean, newBean); 569 570 assertEquals(1, this.listener1.getNumValueChangeds()); 571 assertSame(one, this.listener1.getLastOldValue()); 572 assertNull(this.listener1.getLastNewValue()); 573 } 574 575 private void resetItem() throws Exception { 576 this.item = new TestXPathBasedConfigItem(this.context, this.xpath); 577 } 578 579 private Object checkListeners(boolean expectedOne, boolean expectedTwo, boolean hasDataAlready, Object oldData) { 580 this.listener1.reset(); 581 this.listener2.reset(); 582 this.item.reset(); 583 584 MockXmlObject oldBean = new MockXmlObject(); 585 MockXmlObject newBean = new MockXmlObject(); 586 587 MockXmlObject oldSubBean = new MockXmlObject(); 588 MockXmlObject newSubBean = new MockXmlObject(); 589 590 oldBean.setReturnedSelectPath(new XmlObject[] { oldSubBean }); 591 newBean.setReturnedSelectPath(new XmlObject[] { newSubBean }); 592 593 Object oldObject = new Object (); 594 Object newObject = new Object (); 595 596 if (!hasDataAlready) this.item.setReturnedFetchDataFromXmlObject(new Object [] { oldObject, newObject }); 597 else this.item.setReturnedFetchDataFromXmlObject(new Object [] { newObject }); 598 599 this.item.configurationChanged(oldBean, newBean); 600 601 if (!hasDataAlready) { 602 assertEquals(1, oldBean.getNumSelectPaths()); 603 assertEquals(this.xpath, oldBean.getLastSelectPath()); 604 605 assertEquals(1, newBean.getNumSelectPaths()); 606 assertEquals(this.xpath, newBean.getLastSelectPath()); 607 608 assertEquals(2, this.item.getNumFetchDataFromXmlObjects()); 609 assertSame(oldSubBean, this.item.getLastXmlObjects()[0]); 610 assertSame(newSubBean, this.item.getLastXmlObjects()[1]); 611 } else { 612 assertEquals(1, newBean.getNumSelectPaths()); 613 assertEquals(this.xpath, newBean.getLastSelectPath()); 614 615 assertEquals(1, this.item.getNumFetchDataFromXmlObjects()); 616 assertSame(newSubBean, this.item.getLastXmlObjects()[0]); 617 } 618 619 if (expectedOne) { 620 assertEquals(1, this.listener1.getNumValueChangeds()); 621 if (hasDataAlready) assertSame(oldData, this.listener1.getLastOldValue()); 622 else assertSame(oldObject, this.listener1.getLastOldValue()); 623 assertSame(newObject, this.listener1.getLastNewValue()); 624 } else { 625 assertEquals(0, this.listener1.getNumValueChangeds()); 626 } 627 628 if (expectedTwo) { 629 assertEquals(1, this.listener2.getNumValueChangeds()); 630 if (hasDataAlready) assertSame(oldData, this.listener2.getLastOldValue()); 631 else assertSame(oldObject, this.listener2.getLastOldValue()); 632 assertSame(newObject, this.listener2.getLastNewValue()); 633 } else { 634 assertEquals(0, this.listener2.getNumValueChangeds()); 635 } 636 637 return newObject; 638 } 639 640 public void testToString() throws Exception { 641 this.item.toString(); 642 } 643 644 } 645
| Popular Tags
|