1 4 package org.oddjob.structural; 5 6 import junit.framework.TestCase; 7 8 11 public class ChildHelperTest extends TestCase { 12 13 public void testReplaceChild() { 14 class MyL implements StructuralListener { 15 int added; 16 int removed; 17 public void childAdded(StructuralEvent event) { 18 added = event.getIndex(); 19 } 20 public void childRemoved(StructuralEvent event) { 21 removed = event.getIndex(); 22 } 23 24 } 25 26 Object o1 = new Object (); 27 Object o2 = new Object (); 28 Object o3 = new Object (); 29 30 ChildHelper test = new ChildHelper(this); 31 MyL l = new MyL(); 32 test.addStructuralListener(l); 33 34 test.addChild(o1); 35 test.addChild(o2); 36 37 test.replaceChild(o1, o3); 38 39 assertEquals("replace and in right place.", o3, test.getChildren()[0]); 40 assertEquals("notify correct removed index.", 0, l.removed); 41 assertEquals("notify correct added index.", 0, l.added); 42 } 43 } 44 | Popular Tags |