1 17 package org.apache.ws.jaxme.js.junit; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 import java.util.Observable ; 22 import java.util.Observer ; 23 24 import junit.framework.TestCase; 25 26 27 39 public class MultipleInheritanceTest extends TestCase implements Observer { 40 public class MyObservableList extends ObservableList { 41 MyObservableList(List pList) { 42 super(pList); 43 } 44 public boolean add(Object o) { 45 boolean result = super.add(o); 46 setChanged(); 47 notifyObservers(); 48 clearChanged(); 49 return result; 50 } 51 } 52 53 private int size; 54 public void update(Observable o, Object arg) { 55 size = ((List ) o).size(); 56 } 57 58 public MultipleInheritanceTest(String arg0) { 59 super(arg0); 60 } 61 62 public void testObserver() { 63 size = 0; 64 MyObservableList mol = new MyObservableList(new ArrayList ()); 65 mol.add("s"); 66 assertEquals(0, size); 67 mol.addObserver(this); 68 mol.add("t"); 69 assertEquals(2, size); 70 mol.add(new Integer (4)); 71 assertEquals(3, size); 72 } 73 } 74 | Popular Tags |